# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from io import IOBase
import sys
from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload

from azure.core.exceptions import (
    ClientAuthenticationError,
    HttpResponseError,
    ResourceExistsError,
    ResourceNotFoundError,
    ResourceNotModifiedError,
    map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict

from .._serialization import Serializer
from .._vendor import AutoRestResourceFlatteningTestServiceMixinABC

if sys.version_info >= (3, 9):
    from collections.abc import MutableMapping
else:
    from typing import MutableMapping  # type: ignore  # pylint: disable=ungrouped-imports
JSON = MutableMapping[str, Any]  # pylint: disable=unsubscriptable-object
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False


def build_auto_rest_resource_flattening_test_service_put_array_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/array"

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_get_array_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/array"

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_put_wrapped_array_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/wrappedarray"

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_get_wrapped_array_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/wrappedarray"

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_put_dictionary_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/dictionary"

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_get_dictionary_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/dictionary"

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_put_resource_collection_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/resourcecollection"

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_get_resource_collection_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/resourcecollection"

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_put_simple_product_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/customFlattening"

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_post_flattened_simple_product_request(  # pylint: disable=name-too-long
    **kwargs: Any,
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/customFlattening"

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)


def build_auto_rest_resource_flattening_test_service_put_simple_product_with_grouping_request(  # pylint: disable=name-too-long
    name: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})

    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = "/model-flatten/customFlattening/parametergrouping/{name}/"
    path_format_arguments = {
        "name": _SERIALIZER.url("name", name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)


class AutoRestResourceFlatteningTestServiceOperationsMixin(  # pylint: disable=name-too-long
    AutoRestResourceFlatteningTestServiceMixinABC
):
    @overload
    def put_array(  # pylint: disable=inconsistent-return-statements
        self, resource_array: Optional[List[JSON]] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """Put External Resource as an Array.

        .. seealso::
           - http://tempuri.org

        :param resource_array: External Resource as an Array to put. Default value is None.
        :type resource_array: list[JSON]
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                resource_array = [
                    {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                ]
        """

    @overload
    def put_array(  # pylint: disable=inconsistent-return-statements
        self, resource_array: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """Put External Resource as an Array.

        .. seealso::
           - http://tempuri.org

        :param resource_array: External Resource as an Array to put. Default value is None.
        :type resource_array: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def put_array(  # pylint: disable=inconsistent-return-statements
        self, resource_array: Optional[Union[List[JSON], IO]] = None, **kwargs: Any
    ) -> None:
        """Put External Resource as an Array.

        .. seealso::
           - http://tempuri.org

        :param resource_array: External Resource as an Array to put. Is either a [JSON] type or a IO
         type. Default value is None.
        :type resource_array: list[JSON] or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[None] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(resource_array, (IOBase, bytes)):
            _content = resource_array
        else:
            if resource_array is not None:
                _json = resource_array
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_put_array_request(
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if cls:
            return cls(pipeline_response, None, {})

    @distributed_trace
    def get_array(self, **kwargs: Any) -> List[JSON]:
        """Get External Resource as an Array.

        .. seealso::
           - http://tempuri.org

        :return: list of JSON object
        :rtype: list[JSON]
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == [
                    {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "properties": {
                            "p.name": "str",  # Optional.
                            "provisioningState": "str",  # Optional.
                            "provisioningStateValues": "str",  # Optional. Known values
                              are: "Succeeded", "Failed", "canceled", "Accepted", "Creating",
                              "Created", "Updating", "Updated", "Deleting", "Deleted", and "OK".
                            "type": "str"  # Optional.
                        },
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                ]
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = kwargs.pop("headers", {}) or {}
        _params = kwargs.pop("params", {}) or {}

        cls: ClsType[List[JSON]] = kwargs.pop("cls", None)

        request = build_auto_rest_resource_flattening_test_service_get_array_request(
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(List[JSON], deserialized), {})

        return cast(List[JSON], deserialized)

    @overload
    def put_wrapped_array(  # pylint: disable=inconsistent-return-statements
        self, resource_array: Optional[List[JSON]] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """No need to have a route in Express server for this operation. Used to verify the type flattened
        is not removed if it's referenced in an array.

        .. seealso::
           - http://tempuri.org

        :param resource_array: External Resource as an Array to put. Default value is None.
        :type resource_array: list[JSON]
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                resource_array = [
                    {
                        "value": "str"  # Optional. the product value.
                    }
                ]
        """

    @overload
    def put_wrapped_array(  # pylint: disable=inconsistent-return-statements
        self, resource_array: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """No need to have a route in Express server for this operation. Used to verify the type flattened
        is not removed if it's referenced in an array.

        .. seealso::
           - http://tempuri.org

        :param resource_array: External Resource as an Array to put. Default value is None.
        :type resource_array: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def put_wrapped_array(  # pylint: disable=inconsistent-return-statements
        self, resource_array: Optional[Union[List[JSON], IO]] = None, **kwargs: Any
    ) -> None:
        """No need to have a route in Express server for this operation. Used to verify the type flattened
        is not removed if it's referenced in an array.

        .. seealso::
           - http://tempuri.org

        :param resource_array: External Resource as an Array to put. Is either a [JSON] type or a IO
         type. Default value is None.
        :type resource_array: list[JSON] or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[None] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(resource_array, (IOBase, bytes)):
            _content = resource_array
        else:
            if resource_array is not None:
                _json = resource_array
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_put_wrapped_array_request(
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if cls:
            return cls(pipeline_response, None, {})

    @distributed_trace
    def get_wrapped_array(self, **kwargs: Any) -> List[JSON]:
        """No need to have a route in Express server for this operation. Used to verify the type flattened
        is not removed if it's referenced in an array.

        .. seealso::
           - http://tempuri.org

        :return: list of JSON object
        :rtype: list[JSON]
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == [
                    {
                        "property": {
                            "value": "str"  # Optional. the product value.
                        }
                    }
                ]
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = kwargs.pop("headers", {}) or {}
        _params = kwargs.pop("params", {}) or {}

        cls: ClsType[List[JSON]] = kwargs.pop("cls", None)

        request = build_auto_rest_resource_flattening_test_service_get_wrapped_array_request(
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(List[JSON], deserialized), {})

        return cast(List[JSON], deserialized)

    @overload
    def put_dictionary(  # pylint: disable=inconsistent-return-statements
        self,
        resource_dictionary: Optional[Dict[str, JSON]] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any,
    ) -> None:
        """Put External Resource as a Dictionary.

        .. seealso::
           - http://tempuri.org

        :param resource_dictionary: External Resource as a Dictionary to put. Default value is None.
        :type resource_dictionary: dict[str, JSON]
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                resource_dictionary = {
                    "str": {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "properties": {
                            "p.name": "str",  # Optional.
                            "provisioningState": "str",  # Optional.
                            "provisioningStateValues": "str",  # Optional. Known values
                              are: "Succeeded", "Failed", "canceled", "Accepted", "Creating",
                              "Created", "Updating", "Updated", "Deleting", "Deleted", and "OK".
                            "type": "str"  # Optional.
                        },
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                }
        """

    @overload
    def put_dictionary(  # pylint: disable=inconsistent-return-statements
        self, resource_dictionary: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """Put External Resource as a Dictionary.

        .. seealso::
           - http://tempuri.org

        :param resource_dictionary: External Resource as a Dictionary to put. Default value is None.
        :type resource_dictionary: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def put_dictionary(  # pylint: disable=inconsistent-return-statements
        self, resource_dictionary: Optional[Union[Dict[str, JSON], IO]] = None, **kwargs: Any
    ) -> None:
        """Put External Resource as a Dictionary.

        .. seealso::
           - http://tempuri.org

        :param resource_dictionary: External Resource as a Dictionary to put. Is either a {str: JSON}
         type or a IO type. Default value is None.
        :type resource_dictionary: dict[str, JSON] or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[None] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(resource_dictionary, (IOBase, bytes)):
            _content = resource_dictionary
        else:
            if resource_dictionary is not None:
                _json = resource_dictionary
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_put_dictionary_request(
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if cls:
            return cls(pipeline_response, None, {})

    @distributed_trace
    def get_dictionary(self, **kwargs: Any) -> Dict[str, JSON]:
        """Get External Resource as a Dictionary.

        .. seealso::
           - http://tempuri.org

        :return: dict mapping str to JSON object
        :rtype: dict[str, JSON]
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == {
                    "str": {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "properties": {
                            "p.name": "str",  # Optional.
                            "provisioningState": "str",  # Optional.
                            "provisioningStateValues": "str",  # Optional. Known values
                              are: "Succeeded", "Failed", "canceled", "Accepted", "Creating",
                              "Created", "Updating", "Updated", "Deleting", "Deleted", and "OK".
                            "type": "str"  # Optional.
                        },
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                }
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = kwargs.pop("headers", {}) or {}
        _params = kwargs.pop("params", {}) or {}

        cls: ClsType[Dict[str, JSON]] = kwargs.pop("cls", None)

        request = build_auto_rest_resource_flattening_test_service_get_dictionary_request(
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(Dict[str, JSON], deserialized), {})

        return cast(Dict[str, JSON], deserialized)

    @overload
    def put_resource_collection(  # pylint: disable=inconsistent-return-statements
        self, resource_complex_object: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """Put External Resource as a ResourceCollection.

        .. seealso::
           - http://tempuri.org

        :param resource_complex_object: External Resource as a ResourceCollection to put. Default value
         is None.
        :type resource_complex_object: JSON
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                resource_complex_object = {
                    "arrayofresources": [
                        {
                            "id": "str",  # Optional. Resource Id.
                            "location": "str",  # Optional. Resource Location.
                            "name": "str",  # Optional. Resource Name.
                            "properties": {
                                "p.name": "str",  # Optional.
                                "provisioningState": "str",  # Optional.
                                "provisioningStateValues": "str",  # Optional. Known
                                  values are: "Succeeded", "Failed", "canceled", "Accepted",
                                  "Creating", "Created", "Updating", "Updated", "Deleting", "Deleted",
                                  and "OK".
                                "type": "str"  # Optional.
                            },
                            "tags": {
                                "str": "str"  # Optional. Dictionary of
                                  :code:`<string>`.
                            },
                            "type": "str"  # Optional. Resource Type.
                        }
                    ],
                    "dictionaryofresources": {
                        "str": {
                            "id": "str",  # Optional. Resource Id.
                            "location": "str",  # Optional. Resource Location.
                            "name": "str",  # Optional. Resource Name.
                            "properties": {
                                "p.name": "str",  # Optional. Dictionary of
                                  :code:`<FlattenedProduct>`.
                                "provisioningState": "str",  # Optional. Dictionary
                                  of :code:`<FlattenedProduct>`.
                                "provisioningStateValues": "str",  # Optional. Known
                                  values are: "Succeeded", "Failed", "canceled", "Accepted",
                                  "Creating", "Created", "Updating", "Updated", "Deleting", "Deleted",
                                  and "OK".
                                "type": "str"  # Optional. Dictionary of
                                  :code:`<FlattenedProduct>`.
                            },
                            "tags": {
                                "str": "str"  # Optional. Dictionary of
                                  :code:`<string>`.
                            },
                            "type": "str"  # Optional. Resource Type.
                        }
                    },
                    "productresource": {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "properties": {
                            "p.name": "str",  # Optional. Flattened product.
                            "provisioningState": "str",  # Optional. Flattened product.
                            "provisioningStateValues": "str",  # Optional. Known values
                              are: "Succeeded", "Failed", "canceled", "Accepted", "Creating",
                              "Created", "Updating", "Updated", "Deleting", "Deleted", and "OK".
                            "type": "str"  # Optional. Flattened product.
                        },
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                }
        """

    @overload
    def put_resource_collection(  # pylint: disable=inconsistent-return-statements
        self, resource_complex_object: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> None:
        """Put External Resource as a ResourceCollection.

        .. seealso::
           - http://tempuri.org

        :param resource_complex_object: External Resource as a ResourceCollection to put. Default value
         is None.
        :type resource_complex_object: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def put_resource_collection(  # pylint: disable=inconsistent-return-statements
        self, resource_complex_object: Optional[Union[JSON, IO]] = None, **kwargs: Any
    ) -> None:
        """Put External Resource as a ResourceCollection.

        .. seealso::
           - http://tempuri.org

        :param resource_complex_object: External Resource as a ResourceCollection to put. Is either a
         JSON type or a IO type. Default value is None.
        :type resource_complex_object: JSON or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: None
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                resource_complex_object = {
                    "arrayofresources": [
                        {
                            "id": "str",  # Optional. Resource Id.
                            "location": "str",  # Optional. Resource Location.
                            "name": "str",  # Optional. Resource Name.
                            "properties": {
                                "p.name": "str",  # Optional.
                                "provisioningState": "str",  # Optional.
                                "provisioningStateValues": "str",  # Optional. Known
                                  values are: "Succeeded", "Failed", "canceled", "Accepted",
                                  "Creating", "Created", "Updating", "Updated", "Deleting", "Deleted",
                                  and "OK".
                                "type": "str"  # Optional.
                            },
                            "tags": {
                                "str": "str"  # Optional. Dictionary of
                                  :code:`<string>`.
                            },
                            "type": "str"  # Optional. Resource Type.
                        }
                    ],
                    "dictionaryofresources": {
                        "str": {
                            "id": "str",  # Optional. Resource Id.
                            "location": "str",  # Optional. Resource Location.
                            "name": "str",  # Optional. Resource Name.
                            "properties": {
                                "p.name": "str",  # Optional. Dictionary of
                                  :code:`<FlattenedProduct>`.
                                "provisioningState": "str",  # Optional. Dictionary
                                  of :code:`<FlattenedProduct>`.
                                "provisioningStateValues": "str",  # Optional. Known
                                  values are: "Succeeded", "Failed", "canceled", "Accepted",
                                  "Creating", "Created", "Updating", "Updated", "Deleting", "Deleted",
                                  and "OK".
                                "type": "str"  # Optional. Dictionary of
                                  :code:`<FlattenedProduct>`.
                            },
                            "tags": {
                                "str": "str"  # Optional. Dictionary of
                                  :code:`<string>`.
                            },
                            "type": "str"  # Optional. Resource Type.
                        }
                    },
                    "productresource": {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "properties": {
                            "p.name": "str",  # Optional. Flattened product.
                            "provisioningState": "str",  # Optional. Flattened product.
                            "provisioningStateValues": "str",  # Optional. Known values
                              are: "Succeeded", "Failed", "canceled", "Accepted", "Creating",
                              "Created", "Updating", "Updated", "Deleting", "Deleted", and "OK".
                            "type": "str"  # Optional. Flattened product.
                        },
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                }
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[None] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(resource_complex_object, (IOBase, bytes)):
            _content = resource_complex_object
        else:
            if resource_complex_object is not None:
                _json = resource_complex_object
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_put_resource_collection_request(
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if cls:
            return cls(pipeline_response, None, {})

    @distributed_trace
    def get_resource_collection(self, **kwargs: Any) -> JSON:
        """Get External Resource as a ResourceCollection.

        .. seealso::
           - http://tempuri.org

        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == {
                    "arrayofresources": [
                        {
                            "id": "str",  # Optional. Resource Id.
                            "location": "str",  # Optional. Resource Location.
                            "name": "str",  # Optional. Resource Name.
                            "properties": {
                                "p.name": "str",  # Optional.
                                "provisioningState": "str",  # Optional.
                                "provisioningStateValues": "str",  # Optional. Known
                                  values are: "Succeeded", "Failed", "canceled", "Accepted",
                                  "Creating", "Created", "Updating", "Updated", "Deleting", "Deleted",
                                  and "OK".
                                "type": "str"  # Optional.
                            },
                            "tags": {
                                "str": "str"  # Optional. Dictionary of
                                  :code:`<string>`.
                            },
                            "type": "str"  # Optional. Resource Type.
                        }
                    ],
                    "dictionaryofresources": {
                        "str": {
                            "id": "str",  # Optional. Resource Id.
                            "location": "str",  # Optional. Resource Location.
                            "name": "str",  # Optional. Resource Name.
                            "properties": {
                                "p.name": "str",  # Optional. Dictionary of
                                  :code:`<FlattenedProduct>`.
                                "provisioningState": "str",  # Optional. Dictionary
                                  of :code:`<FlattenedProduct>`.
                                "provisioningStateValues": "str",  # Optional. Known
                                  values are: "Succeeded", "Failed", "canceled", "Accepted",
                                  "Creating", "Created", "Updating", "Updated", "Deleting", "Deleted",
                                  and "OK".
                                "type": "str"  # Optional. Dictionary of
                                  :code:`<FlattenedProduct>`.
                            },
                            "tags": {
                                "str": "str"  # Optional. Dictionary of
                                  :code:`<string>`.
                            },
                            "type": "str"  # Optional. Resource Type.
                        }
                    },
                    "productresource": {
                        "id": "str",  # Optional. Resource Id.
                        "location": "str",  # Optional. Resource Location.
                        "name": "str",  # Optional. Resource Name.
                        "properties": {
                            "p.name": "str",  # Optional. Flattened product.
                            "provisioningState": "str",  # Optional. Flattened product.
                            "provisioningStateValues": "str",  # Optional. Known values
                              are: "Succeeded", "Failed", "canceled", "Accepted", "Creating",
                              "Created", "Updating", "Updated", "Deleting", "Deleted", and "OK".
                            "type": "str"  # Optional. Flattened product.
                        },
                        "tags": {
                            "str": "str"  # Optional. Dictionary of :code:`<string>`.
                        },
                        "type": "str"  # Optional. Resource Type.
                    }
                }
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = kwargs.pop("headers", {}) or {}
        _params = kwargs.pop("params", {}) or {}

        cls: ClsType[JSON] = kwargs.pop("cls", None)

        request = build_auto_rest_resource_flattening_test_service_get_resource_collection_request(
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(JSON, deserialized), {})

        return cast(JSON, deserialized)

    @overload
    def put_simple_product(
        self, simple_body_product: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> JSON:
        """Put Simple Product with client flattening true on the model.

        .. seealso::
           - http://tempuri.org

        :param simple_body_product: Simple body product to put. Default value is None.
        :type simple_body_product: JSON
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                simple_body_product = {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """

    @overload
    def put_simple_product(
        self, simple_body_product: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> JSON:
        """Put Simple Product with client flattening true on the model.

        .. seealso::
           - http://tempuri.org

        :param simple_body_product: Simple body product to put. Default value is None.
        :type simple_body_product: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """

    @distributed_trace
    def put_simple_product(self, simple_body_product: Optional[Union[JSON, IO]] = None, **kwargs: Any) -> JSON:
        """Put Simple Product with client flattening true on the model.

        .. seealso::
           - http://tempuri.org

        :param simple_body_product: Simple body product to put. Is either a JSON type or a IO type.
         Default value is None.
        :type simple_body_product: JSON or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                simple_body_product = {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[JSON] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(simple_body_product, (IOBase, bytes)):
            _content = simple_body_product
        else:
            if simple_body_product is not None:
                _json = simple_body_product
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_put_simple_product_request(
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(JSON, deserialized), {})

        return cast(JSON, deserialized)

    @overload
    def post_flattened_simple_product(
        self, simple_body_product: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> JSON:
        """Put Flattened Simple Product with client flattening true on the parameter.

        .. seealso::
           - http://tempuri.org

        :param simple_body_product: Simple body product to post. Default value is None.
        :type simple_body_product: JSON
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                simple_body_product = {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """

    @overload
    def post_flattened_simple_product(
        self, simple_body_product: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
    ) -> JSON:
        """Put Flattened Simple Product with client flattening true on the parameter.

        .. seealso::
           - http://tempuri.org

        :param simple_body_product: Simple body product to post. Default value is None.
        :type simple_body_product: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """

    @distributed_trace
    def post_flattened_simple_product(
        self, simple_body_product: Optional[Union[JSON, IO]] = None, **kwargs: Any
    ) -> JSON:
        """Put Flattened Simple Product with client flattening true on the parameter.

        .. seealso::
           - http://tempuri.org

        :param simple_body_product: Simple body product to post. Is either a JSON type or a IO type.
         Default value is None.
        :type simple_body_product: JSON or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                simple_body_product = {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[JSON] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(simple_body_product, (IOBase, bytes)):
            _content = simple_body_product
        else:
            if simple_body_product is not None:
                _json = simple_body_product
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_post_flattened_simple_product_request(
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(JSON, deserialized), {})

        return cast(JSON, deserialized)

    @overload
    def put_simple_product_with_grouping(
        self,
        name: str,
        simple_body_product: Optional[JSON] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any,
    ) -> JSON:
        """Put Simple Product with client flattening true on the model.

        .. seealso::
           - http://tempuri.org

        :param name: Product name with value 'groupproduct'. Required.
        :type name: str
        :param simple_body_product: Simple body product to put. Default value is None.
        :type simple_body_product: JSON
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                simple_body_product = {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """

    @overload
    def put_simple_product_with_grouping(
        self,
        name: str,
        simple_body_product: Optional[IO] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any,
    ) -> JSON:
        """Put Simple Product with client flattening true on the model.

        .. seealso::
           - http://tempuri.org

        :param name: Product name with value 'groupproduct'. Required.
        :type name: str
        :param simple_body_product: Simple body product to put. Default value is None.
        :type simple_body_product: IO
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """

    @distributed_trace
    def put_simple_product_with_grouping(
        self, name: str, simple_body_product: Optional[Union[JSON, IO]] = None, **kwargs: Any
    ) -> JSON:
        """Put Simple Product with client flattening true on the model.

        .. seealso::
           - http://tempuri.org

        :param name: Product name with value 'groupproduct'. Required.
        :type name: str
        :param simple_body_product: Simple body product to put. Is either a JSON type or a IO type.
         Default value is None.
        :type simple_body_product: JSON or IO
        :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
         Default value is None.
        :paramtype content_type: str
        :return: JSON object
        :rtype: JSON
        :raises ~azure.core.exceptions.HttpResponseError:

        Example:
            .. code-block:: python

                # JSON input template you can fill out and use as your body input.
                simple_body_product = {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }

                # response body for status code(s): 200
                response == {
                    "base_product_id": "str",  # Unique identifier representing a specific
                      product for a given latitude & longitude. For example, uberX in San Francisco
                      will have a different product_id than uberX in Los Angeles. Required.
                    "base_product_description": "str",  # Optional. Description of product.
                    "details": {
                        "max_product_capacity": "Large",  # Default value is "Large".
                          Capacity of product. For example, 4 people. Required.
                        "max_product_display_name": "str",  # Display name of product.
                          Required.
                        "max_product_image": {
                            "@odata.value": "str",  # Optional. URL value.
                            "generic_value": "str"  # Optional. Generic URL value.
                        }
                    }
                }
        """
        error_map = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = kwargs.pop("params", {}) or {}

        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[JSON] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(simple_body_product, (IOBase, bytes)):
            _content = simple_body_product
        else:
            if simple_body_product is not None:
                _json = simple_body_product
            else:
                _json = None

        request = build_auto_rest_resource_flattening_test_service_put_simple_product_with_grouping_request(
            name=name,
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        request.url = self._client.format_url(request.url)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200]:
            if _stream:
                response.read()  # Load the body in memory and close the socket
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.content:
            deserialized = response.json()
        else:
            deserialized = None

        if cls:
            return cls(pipeline_response, cast(JSON, deserialized), {})

        return cast(JSON, deserialized)
