diff --git a/ChangeLog.md b/ChangeLog.md index 6e6e8b84d26..194fb67e033 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -13,6 +13,7 @@ **Bug Fixes** - Add default value consistently for parameters #1164 +- Make `content_type` param keyword-only if there are multiple content types #1167 ### 2022-02-09 - 5.12.6 diff --git a/autorest/codegen/models/operation.py b/autorest/codegen/models/operation.py index b6b9c965102..c3d092bc58d 100644 --- a/autorest/codegen/models/operation.py +++ b/autorest/codegen/models/operation.py @@ -303,6 +303,15 @@ def from_yaml(cls, yaml_data: Dict[str, Any], *, code_model) -> "Operation": parameters, multiple_content_type_parameters = create_parameters( yaml_data, code_model, parameter_creator ) + parameter_list = parameter_list_creator(code_model, parameters, schema_requests) + multiple_content_type_parameter_list = parameter_list_creator( + code_model, multiple_content_type_parameters, schema_requests + ) + + if len(parameter_list.content_types) > 1: + for p in parameter_list.parameters: + if p.rest_api_name == "Content-Type": + p.is_keyword_only = True return cls( code_model=code_model, @@ -310,10 +319,8 @@ def from_yaml(cls, yaml_data: Dict[str, Any], *, code_model) -> "Operation": name=name, description=yaml_data["language"]["python"]["description"], api_versions=set(value_dict["version"] for value_dict in yaml_data["apiVersions"]), - parameters=parameter_list_creator(code_model, parameters, schema_requests), - multiple_content_type_parameters=parameter_list_creator( - code_model, multiple_content_type_parameters, schema_requests - ), + parameters=parameter_list, + multiple_content_type_parameters=multiple_content_type_parameter_list, schema_requests=schema_requests, summary=yaml_data["language"]["python"].get("summary"), responses=[SchemaResponse.from_yaml(yaml) for yaml in yaml_data.get("responses", [])], diff --git a/autorest/codegen/models/parameter.py b/autorest/codegen/models/parameter.py index c588f947b79..0fdd685105c 100644 --- a/autorest/codegen/models/parameter.py +++ b/autorest/codegen/models/parameter.py @@ -68,7 +68,7 @@ def __init__( grouped_by: Optional["Parameter"] = None, original_parameter: Optional["Parameter"] = None, client_default_value: Optional[Any] = None, - keyword_only: bool = False, + keyword_only: Optional[bool] = None, content_types: Optional[List[str]] = None, ) -> None: super().__init__(yaml_data) @@ -99,6 +99,7 @@ def __init__( self.body_kwargs: List[Parameter] = [] self.is_body_kwarg = False self.need_import = True + self.is_kwarg = (self.rest_api_name == "Content-Type" or (self.constant and self.rest_api_name != "Accept")) def __hash__(self) -> int: return hash(self.serialized_name) @@ -302,19 +303,19 @@ 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.rest_api_name == "Content-Type" or (self.constant and self.rest_api_name != "Accept") - @property def is_keyword_only(self) -> bool: # this means in async mode, I am documented like def hello(positional_1, *, me!) - return self._keyword_only + return self._keyword_only or False + + @is_keyword_only.setter + def is_keyword_only(self, val: bool) -> None: + self._keyword_only = val + self.is_kwarg = False @property def is_hidden(self) -> bool: - return self.serialized_name in _HIDDEN_KWARGS or ( + return self.serialized_name in _HIDDEN_KWARGS and self.is_kwarg or ( self.yaml_data["implementation"] == "Client" and self.constant ) @@ -369,6 +370,8 @@ class ParameterOnlyPathAndBodyPositional(Parameter): @property def is_keyword_only(self) -> bool: + if self._keyword_only is not None: + return self._keyword_only return self.in_method_signature and not ( self.is_hidden or self.location == ParameterLocation.Path or @@ -377,6 +380,11 @@ def is_keyword_only(self) -> bool: self.is_kwarg ) + @is_keyword_only.setter + def is_keyword_only(self, val: bool) -> None: + self._keyword_only = val + self.is_kwarg = False + def get_parameter(code_model): if code_model.options["only_path_and_body_params_positional"]: return ParameterOnlyPathAndBodyPositional diff --git a/autorest/codegen/models/parameter_list.py b/autorest/codegen/models/parameter_list.py index c8cee042dbd..2c0aec1d5bc 100644 --- a/autorest/codegen/models/parameter_list.py +++ b/autorest/codegen/models/parameter_list.py @@ -207,7 +207,9 @@ def method(self) -> List[Parameter]: lambda parameter: parameter.implementation == self.implementation ) positional = [p for p in parameters_of_this_implementation if p.is_positional] - keyword_only = [p for p in parameters_of_this_implementation if p.is_keyword_only] + keyword_only = self._filter_out_multiple_content_type( + [p for p in parameters_of_this_implementation if p.is_keyword_only] + ) kwargs = self._filter_out_multiple_content_type( [p for p in parameters_of_this_implementation if p.is_kwarg] ) @@ -315,7 +317,9 @@ def method(self) -> List[Parameter]: file_and_data_params.append(data_param) method_params = [p for p in method_params if not p.is_multipart and not p.is_data_input] positional = [p for p in method_params if p.is_positional] - keyword_only = [p for p in method_params if p.is_keyword_only] + keyword_only = self._filter_out_multiple_content_type( + [p for p in method_params if p.is_keyword_only] + ) kwargs = self._filter_out_multiple_content_type( [p for p in method_params if p.is_kwarg] ) @@ -338,7 +342,9 @@ def method(self) -> List[Parameter]: """ # Client level should not be on Method, etc. positional = [p for p in self.parameters if p.is_positional] - keyword_only = [p for p in self.parameters if p.is_keyword_only] + keyword_only = self._filter_out_multiple_content_type( + [p for p in self.parameters if p.is_keyword_only] + ) kwargs = self._filter_out_multiple_content_type( [p for p in self.parameters if p.is_kwarg] ) diff --git a/autorest/codegen/models/request_builder_parameter.py b/autorest/codegen/models/request_builder_parameter.py index 10fa598755c..01cd66ad339 100644 --- a/autorest/codegen/models/request_builder_parameter.py +++ b/autorest/codegen/models/request_builder_parameter.py @@ -62,6 +62,11 @@ def default_value_declaration(self) -> Optional[str]: def is_keyword_only(self) -> bool: return not self.location == ParameterLocation.Path and not self.is_kwarg + @is_keyword_only.setter + def is_keyword_only(self, val: bool) -> None: + self._keyword_only = val + self.is_kwarg = False + @property def full_serialized_name(self) -> str: return self.serialized_name diff --git a/autorest/codegen/serializers/builder_serializer.py b/autorest/codegen/serializers/builder_serializer.py index 26dc0cbd75a..db0d7c445ad 100644 --- a/autorest/codegen/serializers/builder_serializer.py +++ b/autorest/codegen/serializers/builder_serializer.py @@ -152,12 +152,21 @@ def _serialize_flattened_body(builder) -> List[str]: return retval def _content_type_docstring(builder) -> 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)) + content_types = [f'"{c}"' for c in builder.parameters.content_types] + if len(content_types) == 2: + possible_values_str = " or ".join(content_types) + else: + possible_values_str = ", ".join( + content_types[: len(content_types) - 1] + ) + f", and {content_types[-1]}" + default_value = next( + p for p in builder.parameters.method if p.rest_api_name == "Content-Type" + ).default_value_declaration + return ( + ":keyword content_type: Media type of the body sent to the API. " + + f"Possible values are: {possible_values_str}. " + + f"Default value is {default_value}." ) - return content_type_str class _BuilderSerializerProtocol(ABC): @property @@ -304,13 +313,14 @@ def param_description(self, builder: Union[RequestBuilder, Operation]) -> List[s description_list.append( f":{param.docstring_type_keyword} { param.serialized_name }: { param.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)) + if len(builder.parameters.content_types) > 1: + description_list = [ + _content_type_docstring(builder) if l.startswith(":keyword content_type:") else l + for l in description_list + ] + if not any(l for l in description_list if l.startswith(":keyword content_type:")): + description_list.append(_content_type_docstring(builder)) return description_list def param_description_and_response_docstring(self, builder) -> List[str]: 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 ea8b8848116..dd420328d32 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 @@ -47,15 +47,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def test_four( # pylint: disable=inconsistent-return-statements self, input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", **kwargs: Any ) -> None: """TestFour should be in OperationGroupTwoOperations. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~azure.multiapi.sample.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -68,7 +71,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements error_map.update(kwargs.pop('error_map', {})) api_version = kwargs.pop('api_version', "3.0.0") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] _json = None _content = None 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 517e65c78b4..6de7eb9747e 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 @@ -120,9 +120,10 @@ def test_four( # pylint: disable=inconsistent-return-statements :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~azure.multiapi.sample.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None 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 index 0d24d2cefba..c48e49635e2 100644 --- 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 @@ -67,7 +67,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: @distributed_trace_async async def check_name_availability( - self, account_name: "_models.StorageAccountCheckNameAvailabilityParameters", **kwargs: Any + self, + account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> "_models.CheckNameAvailabilityResult": """Checks that account name is valid and is not in use. @@ -75,6 +79,9 @@ async def check_name_availability( 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 content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :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 @@ -85,7 +92,6 @@ async def check_name_availability( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") @@ -122,6 +128,8 @@ async def _create_initial( resource_group_name: str, account_name: str, parameters: "_models.StorageAccountCreateParameters", + *, + content_type: Optional[str] = "application/json", **kwargs: Any ) -> Optional["_models.StorageAccount"]: cls = kwargs.pop("cls", None) # type: ClsType[Optional["_models.StorageAccount"]] @@ -129,7 +137,6 @@ async def _create_initial( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = self._serialize.body(parameters, "StorageAccountCreateParameters") @@ -171,6 +178,8 @@ async def begin_create( resource_group_name: str, account_name: str, parameters: "_models.StorageAccountCreateParameters", + *, + content_type: Optional[str] = "application/json", **kwargs: Any ) -> AsyncLROPoller["_models.StorageAccount"]: """Asynchronously creates a new storage account with the specified parameters. Existing accounts @@ -186,6 +195,9 @@ async def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~storage.models.StorageAccountCreateParameters + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: 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 @@ -200,7 +212,6 @@ async def begin_create( :raises: ~azure.core.exceptions.HttpResponseError """ api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] 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) @@ -210,8 +221,8 @@ async def begin_create( resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - api_version=api_version, content_type=content_type, + api_version=api_version, cls=lambda x, y, z: x, **kwargs ) @@ -347,6 +358,8 @@ async def update( resource_group_name: str, account_name: str, parameters: "_models.StorageAccountUpdateParameters", + *, + content_type: Optional[str] = "application/json", **kwargs: Any ) -> "_models.StorageAccount": """Updates the account type or tags for a storage account. It can also be used to add a custom @@ -366,6 +379,9 @@ async def update( :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 content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: 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 @@ -376,7 +392,6 @@ async def update( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") @@ -601,6 +616,8 @@ async def regenerate_key( resource_group_name: str, account_name: str, key_name: Optional[Union[str, "_models.KeyName"]] = None, + *, + content_type: Optional[str] = "application/json", **kwargs: Any ) -> "_models.StorageAccountKeys": """Regenerates the access keys for the specified storage account. @@ -613,6 +630,9 @@ async def regenerate_key( :type account_name: str :param key_name: Default value is None. :type key_name: str or ~storage.models.KeyName + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: 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 @@ -623,7 +643,6 @@ async def regenerate_key( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - 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") 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 index 0c98cbb14fa..65b38e911b8 100644 --- 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 @@ -404,6 +404,9 @@ def check_name_availability( 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 content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :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 @@ -517,6 +520,9 @@ def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~storage.models.StorageAccountCreateParameters + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: 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 @@ -541,8 +547,8 @@ def begin_create( resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - api_version=api_version, content_type=content_type, + api_version=api_version, cls=lambda x, y, z: x, **kwargs ) @@ -706,6 +712,9 @@ def update( :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 content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: 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 @@ -964,6 +973,9 @@ def regenerate_key( :type account_name: str :param key_name: Default value is None. :type key_name: str or ~storage.models.KeyName + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: 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 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 index 77f19363123..0034562280e 100644 --- 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 @@ -48,6 +48,8 @@ def build_check_name_availability_request( resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -139,6 +141,8 @@ def build_create_request( a byte iterator, or stream input). The parameters to provide for the created account. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -479,6 +483,8 @@ def build_update_request( 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. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -978,6 +984,8 @@ def build_regenerate_key_request( a byte iterator, or stream input). Specifies name of the key which should be regenerated. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. 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 index 53b1c796d98..a8ad9823158 100644 --- 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 @@ -41,6 +41,8 @@ def build_check_name_availability_request( resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -136,6 +138,8 @@ def build_create_request( a byte iterator, or stream input). The parameters to provide for the created account. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -461,6 +465,8 @@ def build_update_request( 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. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -935,6 +941,8 @@ def build_regenerate_key_request( a byte iterator, or stream input). Specifies name of the key which should be regenerated. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. diff --git a/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/aio/operations/_operations.py b/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/aio/operations/_operations.py index 1b6ebe315ba..bfbd57166d7 100644 --- a/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/aio/operations/_operations.py +++ b/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/aio/operations/_operations.py @@ -62,13 +62,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._config = config @distributed_trace_async - async def check_name_availability(self, account_name: JSONType, **kwargs: Any) -> JSONType: + async def check_name_availability( + self, account_name: JSONType, *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> JSONType: """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: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSONType :raises: ~azure.core.exceptions.HttpResponseError @@ -100,7 +105,6 @@ async def check_name_availability(self, account_name: JSONType, **kwargs: Any) - error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = account_name @@ -132,14 +136,19 @@ async def check_name_availability(self, account_name: JSONType, **kwargs: Any) - return deserialized async def _create_initial( - self, resource_group_name: str, account_name: str, parameters: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + parameters: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> Optional[JSONType]: cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSONType]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = parameters @@ -176,7 +185,13 @@ async def _create_initial( @distributed_trace_async async def begin_create( - self, resource_group_name: str, account_name: str, parameters: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + parameters: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> AsyncLROPoller[JSONType]: """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 @@ -191,6 +206,9 @@ async def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :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 @@ -289,7 +307,6 @@ async def begin_create( } """ api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop("cls", None) # type: ClsType[JSONType] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -299,8 +316,8 @@ async def begin_create( resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - api_version=api_version, content_type=content_type, + api_version=api_version, cls=lambda x, y, z: x, **kwargs ) @@ -494,7 +511,13 @@ async def get_properties(self, resource_group_name: str, account_name: str, **kw @distributed_trace_async async def update( - self, resource_group_name: str, account_name: str, parameters: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + parameters: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> JSONType: """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 @@ -513,6 +536,9 @@ async def update( :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: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSONType :raises: ~azure.core.exceptions.HttpResponseError @@ -617,7 +643,6 @@ async def update( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = parameters @@ -996,7 +1021,13 @@ async def get_next(next_link=None): @distributed_trace_async async def regenerate_key( - self, resource_group_name: str, account_name: str, regenerate_key: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + regenerate_key: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> JSONType: """Regenerates the access keys for the specified storage account. @@ -1008,6 +1039,9 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated. :type regenerate_key: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSONType :raises: ~azure.core.exceptions.HttpResponseError @@ -1031,7 +1065,6 @@ async def regenerate_key( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = regenerate_key diff --git a/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py b/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py index 7e258572bf1..ce22aa4923f 100644 --- a/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py +++ b/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py @@ -373,13 +373,18 @@ def __init__(self, client, config, serializer, deserializer): self._config = config @distributed_trace - def check_name_availability(self, account_name: JSONType, **kwargs: Any) -> JSONType: + def check_name_availability( + self, account_name: JSONType, *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> JSONType: """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: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSONType :raises: ~azure.core.exceptions.HttpResponseError @@ -411,7 +416,6 @@ def check_name_availability(self, account_name: JSONType, **kwargs: Any) -> JSON error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = account_name @@ -443,14 +447,19 @@ def check_name_availability(self, account_name: JSONType, **kwargs: Any) -> JSON return deserialized def _create_initial( - self, resource_group_name: str, account_name: str, parameters: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + parameters: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> Optional[JSONType]: cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSONType]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = parameters @@ -487,7 +496,13 @@ def _create_initial( @distributed_trace def begin_create( - self, resource_group_name: str, account_name: str, parameters: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + parameters: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> LROPoller[JSONType]: """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 @@ -502,6 +517,9 @@ def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :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 @@ -600,7 +618,6 @@ def begin_create( } """ api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] cls = kwargs.pop("cls", None) # type: ClsType[JSONType] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -610,8 +627,8 @@ def begin_create( resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - api_version=api_version, content_type=content_type, + api_version=api_version, cls=lambda x, y, z: x, **kwargs ) @@ -804,7 +821,15 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: return deserialized @distributed_trace - def update(self, resource_group_name: str, account_name: str, parameters: JSONType, **kwargs: Any) -> JSONType: + def update( + self, + resource_group_name: str, + account_name: str, + parameters: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> JSONType: """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, @@ -822,6 +847,9 @@ def update(self, resource_group_name: str, account_name: str, parameters: JSONTy :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: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSONType :raises: ~azure.core.exceptions.HttpResponseError @@ -926,7 +954,6 @@ def update(self, resource_group_name: str, account_name: str, parameters: JSONTy error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = parameters @@ -1305,7 +1332,13 @@ def get_next(next_link=None): @distributed_trace def regenerate_key( - self, resource_group_name: str, account_name: str, regenerate_key: JSONType, **kwargs: Any + self, + resource_group_name: str, + account_name: str, + regenerate_key: JSONType, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> JSONType: """Regenerates the access keys for the specified storage account. @@ -1317,6 +1350,9 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated. :type regenerate_key: JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSONType :raises: ~azure.core.exceptions.HttpResponseError @@ -1340,7 +1376,6 @@ def regenerate_key( error_map.update(kwargs.pop("error_map", {})) api_version = kwargs.pop("api_version", "2015-05-01-preview") # type: str - content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] _json = regenerate_key diff --git a/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders.py b/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders.py index a3b7ce8ec87..fee3a8c6cdf 100644 --- a/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders.py +++ b/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders.py @@ -180,8 +180,8 @@ def build_post_parameters_request( a byte iterator, or stream input). I am a body parameter with a new content type. My only valid JSON entry is { url: "http://example.org/myimage.jpeg" }. Default value is None. :paramtype content: any - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "image/jpeg", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "image/jpeg" or "application/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. diff --git a/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders_py3.py b/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders_py3.py index 0f483acea07..0c50eb1e025 100644 --- a/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders_py3.py +++ b/test/dpg/low-level/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneLowLevel/dpgservicedrivenupdateonelowlevel/rest/params/_request_builders_py3.py @@ -138,8 +138,8 @@ def build_post_parameters_request(*, json: JSONType = None, content: Any = None, a byte iterator, or stream input). I am a body parameter with a new content type. My only valid JSON entry is { url: "http://example.org/myimage.jpeg" }. Default value is None. :paramtype content: any - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "image/jpeg", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "image/jpeg" or "application/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. diff --git a/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/aio/operations/_operations.py b/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/aio/operations/_operations.py index fb304e50e09..9bbd443dec0 100644 --- a/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/aio/operations/_operations.py +++ b/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/aio/operations/_operations.py @@ -188,14 +188,17 @@ async def put_required_optional( return deserialized @distributed_trace_async - async def post_parameters(self, parameter: Union[IO, JSONType], **kwargs: Any) -> Any: + async def post_parameters( + self, parameter: Union[IO, JSONType], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> Any: """POST a JSON or a JPEG. :param parameter: I am a body parameter with a new content type. My only valid JSON entry is { url: "http://example.org/myimage.jpeg" }. :type parameter: IO or JSONType - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "image/jpeg", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "image/jpeg" or "application/json". Default value is "application/json". + :paramtype content_type: str :return: any :rtype: any :raises: ~azure.core.exceptions.HttpResponseError @@ -204,8 +207,6 @@ async def post_parameters(self, parameter: Union[IO, JSONType], **kwargs: Any) - error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: diff --git a/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/operations/_operations.py b/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/operations/_operations.py index 8d059496683..10aeddf8930 100644 --- a/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/operations/_operations.py +++ b/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/operations/_operations.py @@ -298,14 +298,17 @@ def put_required_optional( return deserialized @distributed_trace - def post_parameters(self, parameter: Union[IO, JSONType], **kwargs: Any) -> Any: + def post_parameters( + self, parameter: Union[IO, JSONType], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> Any: """POST a JSON or a JPEG. :param parameter: I am a body parameter with a new content type. My only valid JSON entry is { url: "http://example.org/myimage.jpeg" }. :type parameter: IO or JSONType - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "image/jpeg", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "image/jpeg" or "application/json". Default value is "application/json". + :paramtype content_type: str :return: any :rtype: any :raises: ~azure.core.exceptions.HttpResponseError @@ -314,8 +317,6 @@ def post_parameters(self, parameter: Union[IO, JSONType], **kwargs: Any) -> Any: error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: 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 6cbd17293ed..4bde1c84b03 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 @@ -47,15 +47,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def test_four( # pylint: disable=inconsistent-return-statements self, input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", **kwargs: Any ) -> None: """TestFour should be in OperationGroupTwoOperations. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapi.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -68,7 +71,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements error_map.update(kwargs.pop('error_map', {})) api_version = kwargs.pop('api_version', "3.0.0") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] _json = None _content = None 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 de70cda6779..2162d85820d 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 @@ -120,9 +120,10 @@ def test_four( # pylint: disable=inconsistent-return-statements :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapi.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None 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 c1e898bce22..89493d574cb 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 @@ -47,15 +47,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def test_four( # pylint: disable=inconsistent-return-statements self, input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", **kwargs: Any ) -> None: """TestFour should be in OperationGroupTwoOperations. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapicredentialdefaultpolicy.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -68,7 +71,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements error_map.update(kwargs.pop('error_map', {})) api_version = kwargs.pop('api_version', "3.0.0") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] _json = None _content = None 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 fc3bdd7b46d..66ca68631a2 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 @@ -120,9 +120,10 @@ def test_four( # pylint: disable=inconsistent-return-statements :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapicredentialdefaultpolicy.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None 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 29de9e95a28..de9297135c6 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 @@ -46,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def test_four( # pylint: disable=inconsistent-return-statements self, input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", **kwargs: Any ) -> None: """TestFour should be in OperationGroupTwoOperations. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapidataplane.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -67,7 +70,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements error_map.update(kwargs.pop('error_map', {})) api_version = kwargs.pop('api_version', "3.0.0") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] _json = None _content = None 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 cdd7c0ae93e..df440ca1429 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 @@ -119,9 +119,10 @@ def test_four( # pylint: disable=inconsistent-return-statements :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapidataplane.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None 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 601ebb129ce..2240f32b6b5 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 @@ -120,9 +120,10 @@ def test_four( # pylint: disable=inconsistent-return-statements :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapinoasync.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None 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 57984839c7c..2bc11023be1 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 @@ -47,15 +47,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def test_four( # pylint: disable=inconsistent-return-statements self, input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", **kwargs: Any ) -> None: """TestFour should be in OperationGroupTwoOperations. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapiwithsubmodule.submodule.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -68,7 +71,6 @@ async def test_four( # pylint: disable=inconsistent-return-statements error_map.update(kwargs.pop('error_map', {})) api_version = kwargs.pop('api_version', "3.0.0") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[Union[str, "_models.ContentType"]] _json = None _content = None 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 66911c5d72e..1664d608c0a 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 @@ -120,9 +120,10 @@ def test_four( # pylint: disable=inconsistent-return-statements :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~multiapiwithsubmodule.submodule.v3.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None 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 index 775dcaf3681..874cc78ba1e 100644 --- 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 @@ -37,14 +37,21 @@ class MediaTypesClientOperationsMixin: @distributed_trace_async - async def analyze_body(self, input: Optional[Union[IO, "_models.SourcePath"]] = None, **kwargs: Any) -> str: + async def analyze_body( + self, + input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", + **kwargs: Any + ) -> str: """Analyze body, that could be different media types. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~mediatypes.models.ContentType :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 @@ -54,10 +61,6 @@ async def analyze_body(self, input: Optional[Union[IO, "_models.SourcePath"]] = error_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/json"]: @@ -100,16 +103,21 @@ async def analyze_body(self, input: Optional[Union[IO, "_models.SourcePath"]] = @distributed_trace_async async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statements - self, input: Optional[Union[IO, "_models.SourcePath"]] = None, **kwargs: Any + self, + input: Optional[Union[IO, "_models.SourcePath"]] = None, + *, + content_type: Optional[Union[str, "_models.ContentType"]] = "application/json", + **kwargs: Any ) -> None: """Analyze body, that could be different media types. Adds to AnalyzeBody by not having an accept type. :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~mediatypes.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -119,10 +127,6 @@ async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return- error_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/json"]: @@ -205,12 +209,17 @@ async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs content_type_with_encoding.metadata = {"url": "/mediatypes/contentTypeWithEncoding"} # type: ignore @distributed_trace_async - async def binary_body_with_two_content_types(self, message: IO, **kwargs: Any) -> str: + async def binary_body_with_two_content_types( + self, message: IO, *, content_type: Optional[Union[str, "_models.ContentType1"]] = None, **kwargs: Any + ) -> str: """Binary body with two content types. Pass in of {'hello': 'world'} for the application/json content type, and a byte stream of 'hello, world!' for application/octet-stream. :param message: The payload body. :type message: IO + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "application/octet-stream". Default value is None. + :paramtype content_type: str or ~mediatypes.models.ContentType1 :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 @@ -220,8 +229,6 @@ async def binary_body_with_two_content_types(self, message: IO, **kwargs: Any) - error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) - content_type = kwargs.pop("content_type", None) # type: Optional[Union[str, "_models.ContentType1"]] - _content = message request = build_binary_body_with_two_content_types_request( @@ -251,16 +258,23 @@ async def binary_body_with_two_content_types(self, message: IO, **kwargs: Any) - binary_body_with_two_content_types.metadata = {"url": "/mediatypes/binaryBodyTwoContentTypes"} # type: ignore @distributed_trace_async - async def binary_body_with_three_content_types(self, message: Union[IO, str], **kwargs: Any) -> str: + async def binary_body_with_three_content_types( + self, + message: Union[IO, str], + *, + content_type: Optional[Union[str, "_models.ContentType1"]] = "application/json", + **kwargs: Any + ) -> str: """Binary body with three content types. Pass in string 'hello, world' with content type 'text/plain', {'hello': world'} with content type 'application/json' and a byte string for 'application/octet-stream'. :param message: The payload body. :type message: IO or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "application/json", "application/octet-stream", - "text/plain." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json", "application/octet-stream", and "text/plain". Default value is + "application/json". + :paramtype content_type: str or ~mediatypes.models.ContentType1 :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 @@ -270,10 +284,6 @@ async def binary_body_with_three_content_types(self, message: Union[IO, 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.ContentType1"]] - _content = message request = build_binary_body_with_three_content_types_request( @@ -303,13 +313,16 @@ async def binary_body_with_three_content_types(self, message: Union[IO, str], ** binary_body_with_three_content_types.metadata = {"url": "/mediatypes/binaryBodyThreeContentTypes"} # type: ignore @distributed_trace_async - async def put_text_and_json_body(self, message: Union[str, str], **kwargs: Any) -> str: + async def put_text_and_json_body( + self, message: Union[str, str], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> str: """Body that's either text/plain or application/json. :param message: The payload body. :type message: str or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "text/plain", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain" or "application/json". Default value is "application/json". + :paramtype content_type: 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 @@ -319,8 +332,6 @@ async def put_text_and_json_body(self, message: Union[str, str], **kwargs: Any) error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: 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 index e4f5db95941..eff6d5d0ef0 100644 --- 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 @@ -190,9 +190,10 @@ def analyze_body( :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~mediatypes.models.ContentType :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 @@ -258,9 +259,10 @@ def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statem :param input: Input parameter. Default value is None. :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str or ~mediatypes.models.ContentType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -372,6 +374,9 @@ def binary_body_with_two_content_types( :param message: The payload body. :type message: IO + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "application/octet-stream". Default value is None. + :paramtype content_type: str or ~mediatypes.models.ContentType1 :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 @@ -424,9 +429,10 @@ def binary_body_with_three_content_types( :param message: The payload body. :type message: IO or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "application/json", "application/octet-stream", - "text/plain." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json", "application/octet-stream", and "text/plain". Default value is + "application/json". + :paramtype content_type: str or ~mediatypes.models.ContentType1 :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 @@ -479,8 +485,9 @@ def put_text_and_json_body( :param message: The payload body. :type message: str or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "text/plain", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain" or "application/json". Default value is "application/json". + :paramtype content_type: 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 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 index 4e1038220f3..7765a7d9080 100644 --- 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 @@ -38,9 +38,9 @@ def build_analyze_body_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Input parameter. Default value is None. :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." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -89,9 +89,9 @@ def build_analyze_body_no_accept_header_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Input parameter. Default value is None. :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." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -176,6 +176,8 @@ def build_binary_body_with_two_content_types_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). The payload body. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "application/octet-stream". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -225,9 +227,8 @@ def build_binary_body_with_three_content_types_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). The payload body. Default value is None. :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/json", "application/octet-stream", - "text/plain." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json", "application/octet-stream", and "text/plain". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -275,8 +276,8 @@ def build_put_text_and_json_body_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). The payload body. Default value is None. :paramtype content: any - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "text/plain", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain" or "application/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. 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 index 0485e33a888..36003fe37bc 100644 --- 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 @@ -30,9 +30,9 @@ def build_analyze_body_request(*, json: JSONType = None, content: Any = None, ** :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Input parameter. Default value is None. :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." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -75,9 +75,9 @@ def build_analyze_body_no_accept_header_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). Input parameter. Default value is None. :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." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -148,6 +148,8 @@ def build_binary_body_with_two_content_types_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). The payload body. Default value is None. :paramtype content: any + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "application/octet-stream". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -191,9 +193,8 @@ def build_binary_body_with_three_content_types_request( :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). The payload body. Default value is None. :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/json", "application/octet-stream", - "text/plain." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json", "application/octet-stream", and "text/plain". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. @@ -233,8 +234,8 @@ def build_put_text_and_json_body_request(*, json: JSONType = None, content: Any :keyword content: Pass in binary content you want in the body of the request (typically bytes, a byte iterator, or stream input). The payload body. Default value is None. :paramtype content: any - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "text/plain", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain" or "application/json". Default value is None. :return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's `send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_operations/_operations.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_operations/_operations.py index ce206ca2976..6e5fa3a02c5 100644 --- a/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_operations/_operations.py +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_operations/_operations.py @@ -132,14 +132,21 @@ def build_put_text_and_json_body_request(*, json: JSONType = None, content: Any class MediaTypesClientOperationsMixin(object): @distributed_trace - def analyze_body(self, input: Optional[Union[IO, JSONType]] = None, **kwargs: Any) -> str: + def analyze_body( + self, + input: Optional[Union[IO, JSONType]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> str: """Analyze body, that could be different media types. :param input: Input parameter. Default value is None. :type input: IO or JSONType - :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -156,8 +163,6 @@ def analyze_body(self, input: Optional[Union[IO, JSONType]] = None, **kwargs: An error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -199,16 +204,21 @@ def analyze_body(self, input: Optional[Union[IO, JSONType]] = None, **kwargs: An @distributed_trace def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statements - self, input: Optional[Union[IO, JSONType]] = None, **kwargs: Any + self, + input: Optional[Union[IO, JSONType]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> None: """Analyze body, that could be different media types. Adds to AnalyzeBody by not having an accept type. :param input: Input parameter. Default value is None. :type input: IO or JSONType - :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError @@ -225,8 +235,6 @@ def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statem error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -303,12 +311,17 @@ def content_type_with_encoding(self, input: Optional[str] = None, **kwargs: Any) return deserialized @distributed_trace - def binary_body_with_two_content_types(self, message: Union[IO, JSONType], **kwargs: Any) -> str: + def binary_body_with_two_content_types( + self, message: Union[IO, JSONType], *, content_type: Optional[str] = None, **kwargs: Any + ) -> str: """Binary body with two content types. Pass in of {'hello': 'world'} for the application/json content type, and a byte stream of 'hello, world!' for application/octet-stream. :param message: The payload body. :type message: IO or JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "application/octet-stream". Default value is None. + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -317,8 +330,6 @@ def binary_body_with_two_content_types(self, message: Union[IO, JSONType], **kwa 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] - _json = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -358,16 +369,19 @@ def binary_body_with_two_content_types(self, message: Union[IO, JSONType], **kwa return deserialized @distributed_trace - def binary_body_with_three_content_types(self, message: Union[IO, str], **kwargs: Any) -> str: + def binary_body_with_three_content_types( + self, message: Union[IO, str], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> str: """Binary body with three content types. Pass in string 'hello, world' with content type 'text/plain', {'hello': world'} with content type 'application/json' and a byte string for 'application/octet-stream'. :param message: The payload body. :type message: IO or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "application/json", "application/octet-stream", - "text/plain." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json", "application/octet-stream", and "text/plain". Default value is + "application/json". + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -376,8 +390,6 @@ def binary_body_with_three_content_types(self, message: Union[IO, str], **kwargs error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -417,13 +429,16 @@ def binary_body_with_three_content_types(self, message: Union[IO, str], **kwargs return deserialized @distributed_trace - def put_text_and_json_body(self, message: Union[str, str], **kwargs: Any) -> str: + def put_text_and_json_body( + self, message: Union[str, str], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> str: """Body that's either text/plain or application/json. :param message: The payload body. :type message: str or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "text/plain", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain" or "application/json". Default value is "application/json". + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -432,8 +447,6 @@ def put_text_and_json_body(self, message: Union[str, str], **kwargs: Any) -> 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 = None _content = None if content_type.split(";")[0] in ["application/json"]: diff --git a/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py b/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py index 8f93f325619..dc4facc259c 100644 --- a/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py +++ b/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py @@ -36,14 +36,21 @@ class MediaTypesClientOperationsMixin: @distributed_trace_async - async def analyze_body(self, input: Optional[Union[IO, JSONType]] = None, **kwargs: Any) -> str: + async def analyze_body( + self, + input: Optional[Union[IO, JSONType]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> str: """Analyze body, that could be different media types. :param input: Input parameter. Default value is None. :type input: IO or JSONType - :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -60,8 +67,6 @@ async def analyze_body(self, input: Optional[Union[IO, JSONType]] = None, **kwar error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -103,16 +108,21 @@ async def analyze_body(self, input: Optional[Union[IO, JSONType]] = None, **kwar @distributed_trace_async async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return-statements - self, input: Optional[Union[IO, JSONType]] = None, **kwargs: Any + self, + input: Optional[Union[IO, JSONType]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> None: """Analyze body, that could be different media types. Adds to AnalyzeBody by not having an accept type. :param input: Input parameter. Default value is None. :type input: IO or JSONType - :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 content_type: Media type of the body sent to the API. Possible values are: + "application/pdf", "image/jpeg", "image/png", "image/tiff", and "application/json". Default + value is "application/json". + :paramtype content_type: str :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError @@ -129,8 +139,6 @@ async def analyze_body_no_accept_header( # pylint: disable=inconsistent-return- error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -207,12 +215,17 @@ async def content_type_with_encoding(self, input: Optional[str] = None, **kwargs return deserialized @distributed_trace_async - async def binary_body_with_two_content_types(self, message: Union[IO, JSONType], **kwargs: Any) -> str: + async def binary_body_with_two_content_types( + self, message: Union[IO, JSONType], *, content_type: Optional[str] = None, **kwargs: Any + ) -> str: """Binary body with two content types. Pass in of {'hello': 'world'} for the application/json content type, and a byte stream of 'hello, world!' for application/octet-stream. :param message: The payload body. :type message: IO or JSONType + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json" or "application/octet-stream". Default value is None. + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -221,8 +234,6 @@ async def binary_body_with_two_content_types(self, message: Union[IO, JSONType], 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] - _json = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -262,16 +273,19 @@ async def binary_body_with_two_content_types(self, message: Union[IO, JSONType], return deserialized @distributed_trace_async - async def binary_body_with_three_content_types(self, message: Union[IO, str], **kwargs: Any) -> str: + async def binary_body_with_three_content_types( + self, message: Union[IO, str], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> str: """Binary body with three content types. Pass in string 'hello, world' with content type 'text/plain', {'hello': world'} with content type 'application/json' and a byte string for 'application/octet-stream'. :param message: The payload body. :type message: IO or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "application/json", "application/octet-stream", - "text/plain." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "application/json", "application/octet-stream", and "text/plain". Default value is + "application/json". + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -280,8 +294,6 @@ async def binary_body_with_three_content_types(self, message: Union[IO, 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 = None _content = None if content_type.split(";")[0] in ["application/json"]: @@ -321,13 +333,16 @@ async def binary_body_with_three_content_types(self, message: Union[IO, str], ** return deserialized @distributed_trace_async - async def put_text_and_json_body(self, message: Union[str, str], **kwargs: Any) -> str: + async def put_text_and_json_body( + self, message: Union[str, str], *, content_type: Optional[str] = "application/json", **kwargs: Any + ) -> str: """Body that's either text/plain or application/json. :param message: The payload body. :type message: str or str - :keyword str content_type: Media type of the body sent to the API. Default value is - "application/json". Allowed values are: "text/plain", "application/json." + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain" or "application/json". Default value is "application/json". + :paramtype content_type: str :return: str :rtype: str :raises: ~azure.core.exceptions.HttpResponseError @@ -336,8 +351,6 @@ async def put_text_and_json_body(self, message: Union[str, str], **kwargs: Any) error_map = {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 = None _content = None if content_type.split(";")[0] in ["application/json"]: