# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.1.3, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import json
import logging
from pprint import pprint
from typing import TYPE_CHECKING
import warnings

from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse

from .. import models as _models

if TYPE_CHECKING:
    # pylint: disable=unused-import,ungrouped-imports
    from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union

    T = TypeVar('T')
    ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

class LayersOperations(object):
    """LayersOperations operations.

    You should not instantiate this class directly. Instead, you should create a Client instance that
    instantiates it for you and attaches it as an attribute.

    :ivar models: Alias to model classes used in this operation group.
    :type models: ~layers_manager.models
    :param client: Client for service requests.
    :param config: Configuration of service client.
    :param serializer: An object model serializer.
    :param deserializer: An object model deserializer.
    """

    models = _models

    def __init__(self, client, config, serializer, deserializer):
        self._client = client
        self._serialize = serializer
        self._deserialize = deserializer
        self._config = config

    def post(
        self,
        body,  # type: "_models.Layer"
        log: logging.Logger = logging.getLogger(),
        **kwargs  # type: Any
    ):
        # type: (...) -> Optional["_models.Layer"]
        """Insert a layer.

        Insert a layer.

        :param body:
        :type body: ~layers_manager.models.Layer
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Layer, or the result of cls(response)
        :rtype: ~layers_manager.models.Layer or None
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Optional["_models.Layer"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        content_type = kwargs.pop("content_type", "application/json")
        accept = "application/json"

        # Construct URL
        url = self.post.metadata['url']  # type: ignore

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        body_content_kwargs = {}  # type: Dict[str, Any]
        body_content = self._serialize.body(body, 'Layer')
        body_content_kwargs['content'] = body_content
        log.debug(f"sending post for {url} with query parameters: {query_parameters}, header: {header_parameters} and body {json.dumps(body_content_kwargs, indent=2)}")
        request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        deserialized = None
        if response.status_code == 200:
            deserialized = self._deserialize('Layer', pipeline_response)

        log.debug(f"got response for post operation with {response.status_code} and content {deserialized}")

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

        return deserialized
    post.metadata = {'url': '/layers'}  # type: ignore

    def get(
        self,
        log:logging.Logger = logging.getLogger(),
        subset=None,  # type: Optional[str]
        **kwargs  # type: Any
    ):
        # type: (...) -> Union[List["_models.Layer"], "_models.Error"]
        """Get a list of layers.

        Get a list of layers.

        :param subset: A subset of layer ids, colon separated.
        :type subset: str
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: list of Layer or Error, or the result of cls(response)
        :rtype: list[~layers_manager.models.Layer] or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union[List["_models.Layer"], "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        accept = "application/json"

        # Construct URL
        url = self.get.metadata['url']  # type: ignore

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]
        if subset is not None:
            query_parameters['subset'] = self._serialize.query("subset", subset, 'str')

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
        log.debug(f"sending get for {url} with query parameters: {query_parameters}, header: {header_parameters}")

        request = self._client.get(url, query_parameters, header_parameters)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('[Layer]', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

        log.debug(f"got response for post operation with {response.status_code} and content {deserialized}")

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

        return deserialized
    get.metadata = {'url': '/layers'}  # type: ignore

    def layer_id_put(
        self,
        layer_id,  # type: str
        body,  # type: "_models.Layer"
        log: logging.Logger = logging.getLogger(),
        **kwargs  # type: Any
    ):
        # type: (...) -> Union["_models.Layer", "_models.Error"]
        """Update a layer by id.

        Update a layer by id.

        :param layer_id: Layer's id.
        :type layer_id: str
        :param body:
        :type body: ~layers_manager.models.Layer
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Layer or Error, or the result of cls(response)
        :rtype: ~layers_manager.models.Layer or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union["_models.Layer", "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        content_type = kwargs.pop("content_type", "application/json")
        accept = "application/json"

        # Construct URL
        url = self.layer_id_put.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        body_content_kwargs = {}  # type: Dict[str, Any]
        body_content = self._serialize.body(body, 'Layer')
        body_content_kwargs['content'] = body_content
        log.debug(f"sending put for {url} with query parameters: {query_parameters}, header: {header_parameters} and body {json.dumps(body_content_kwargs, indent=2)}")
        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 404, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('Layer', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 404:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

        log.debug(f"got response for put operation with {response.status_code} and content {deserialized}")

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

        return deserialized
    layer_id_put.metadata = {'url': '/layers/{layerId}'}  # type: ignore

    def layer_id_get(
        self,
        layer_id,  # type: str
        log: logging.Logger = logging.getLogger(),
        **kwargs  # type: Any
    ):
        # type: (...) -> Union["_models.Layer", "_models.Error"]
        """Get a layer by id.

        Get a layer by id.

        :param layer_id: Layer's id.
        :type layer_id: str
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Layer or Error, or the result of cls(response)
        :rtype: ~layers_manager.models.Layer or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union["_models.Layer", "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        accept = "application/json"

        # Construct URL
        url = self.layer_id_get.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
        log.debug(f"sending get for {url} with query parameters: {query_parameters}, header: {header_parameters}")

        request = self._client.get(url, query_parameters, header_parameters)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 404, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('Layer', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 404:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

        log.debug(f"got response for post operation with {response.status_code} and content {deserialized}")

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

        return deserialized
    layer_id_get.metadata = {'url': '/layers/{layerId}'}  # type: ignore

    def layer_id_delete(
        self,
        layer_id,  # type: str
        **kwargs  # type: Any
    ):
        # type: (...) -> Union["_models.Layer", "_models.Error"]
        """Delete a layer by id.

        Delete a layer by id.

        :param layer_id: Layer's id.
        :type layer_id: str
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Layer or Error, or the result of cls(response)
        :rtype: ~layers_manager.models.Layer or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union["_models.Layer", "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        accept = "application/json"

        # Construct URL
        url = self.layer_id_delete.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        request = self._client.delete(url, query_parameters, header_parameters)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 404, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('Layer', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 404:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

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

        return deserialized
    layer_id_delete.metadata = {'url': '/layers/{layerId}'}  # type: ignore

    def query_post(
        self,
        body,  # type: "_models.LayerQuery"
        **kwargs  # type: Any
    ):
        # type: (...) -> Union[List["_models.Layer"], "_models.Error"]
        """Query a subset of layers and their entities, by a timestamp and a bounding box.

        Query a subset of layers and their entities, by a timestamp and a bounding box.

        :param body:
        :type body: ~layers_manager.models.LayerQuery
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: list of Layer or Error, or the result of cls(response)
        :rtype: list[~layers_manager.models.Layer] or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union[List["_models.Layer"], "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        content_type = kwargs.pop("content_type", "application/json")
        accept = "application/json"

        # Construct URL
        url = self.query_post.metadata['url']  # type: ignore

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        body_content_kwargs = {}  # type: Dict[str, Any]
        body_content = self._serialize.body(body, 'LayerQuery')
        body_content_kwargs['content'] = body_content
        request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('[Layer]', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

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

        return deserialized
    query_post.metadata = {'url': '/layers/query'}  # type: ignore

    def layer_id_entities_post(
        self,
        layer_id,  # type: str
        body,  # type: List["_models.Entity"]
        **kwargs  # type: Any
    ):
        # type: (...) -> Union[List["_models.Entity"], "_models.Error"]
        """Insert entities in a batch.

        Insert entities in a batch.

        :param layer_id: Layer's id.
        :type layer_id: str
        :param body:
        :type body: list[~layers_manager.models.Entity]
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: list of Entity or Error, or the result of cls(response)
        :rtype: list[~layers_manager.models.Entity] or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union[List["_models.Entity"], "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        content_type = kwargs.pop("content_type", "application/json")
        accept = "application/json"

        # Construct URL
        url = self.layer_id_entities_post.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        body_content_kwargs = {}  # type: Dict[str, Any]
        body_content = self._serialize.body(body, '[Entity]')
        body_content_kwargs['content'] = body_content
        request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('[Entity]', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

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

        return deserialized
    layer_id_entities_post.metadata = {'url': '/layers/{layerId}/entities'}  # type: ignore

    def layer_id_entities_entity_id_put(
        self,
        layer_id,  # type: str
        entity_id,  # type: str
        body,  # type: "_models.Entity"
        **kwargs  # type: Any
    ):
        # type: (...) -> Union["_models.Entity", "_models.Error"]
        """Update an entity by id.

        Update an entity by id.

        :param layer_id: Layer's id.
        :type layer_id: str
        :param entity_id: Entity's id.
        :type entity_id: str
        :param body:
        :type body: ~layers_manager.models.Entity
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Entity or Error, or the result of cls(response)
        :rtype: ~layers_manager.models.Entity or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union["_models.Entity", "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        content_type = kwargs.pop("content_type", "application/json")
        accept = "application/json"

        # Construct URL
        url = self.layer_id_entities_entity_id_put.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
            'entityId': self._serialize.url("entity_id", entity_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        body_content_kwargs = {}  # type: Dict[str, Any]
        body_content = self._serialize.body(body, 'Entity')
        body_content_kwargs['content'] = body_content
        request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 404, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('Entity', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 404:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

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

        return deserialized
    layer_id_entities_entity_id_put.metadata = {'url': '/layers/{layerId}/entities/{entityId}'}  # type: ignore

    def layer_id_entities_entity_id_get(
        self,
        layer_id,  # type: str
        entity_id,  # type: str
        **kwargs  # type: Any
    ):
        # type: (...) -> Union["_models.Entity", "_models.Error"]
        """Get an entity by id.

        Get an entity by id.

        :param layer_id: Layer's id.
        :type layer_id: str
        :param entity_id: Entity's id.
        :type entity_id: str
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Entity or Error, or the result of cls(response)
        :rtype: ~layers_manager.models.Entity or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union["_models.Entity", "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        accept = "application/json"

        # Construct URL
        url = self.layer_id_entities_entity_id_get.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
            'entityId': self._serialize.url("entity_id", entity_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        request = self._client.get(url, query_parameters, header_parameters)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 404, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('Entity', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 404:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

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

        return deserialized
    layer_id_entities_entity_id_get.metadata = {'url': '/layers/{layerId}/entities/{entityId}'}  # type: ignore

    def layer_id_entities_entity_id_delete(
        self,
        layer_id,  # type: str
        entity_id,  # type: str
        **kwargs  # type: Any
    ):
        # type: (...) -> Union["_models.Entity", "_models.Error"]
        """Delete an entity by id.

        Delete an entity by id.

        :param layer_id: Layer's id.
        :type layer_id: str
        :param entity_id: Entity's id.
        :type entity_id: str
        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: Entity or Error, or the result of cls(response)
        :rtype: ~layers_manager.models.Entity or ~layers_manager.models.Error
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType[Union["_models.Entity", "_models.Error"]]
        error_map = {
            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
        }
        error_map.update(kwargs.pop('error_map', {}))
        accept = "application/json"

        # Construct URL
        url = self.layer_id_entities_entity_id_delete.metadata['url']  # type: ignore
        path_format_arguments = {
            'layerId': self._serialize.url("layer_id", layer_id, 'str'),
            'entityId': self._serialize.url("entity_id", entity_id, 'str'),
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}  # type: Dict[str, Any]

        # Construct headers
        header_parameters = {}  # type: Dict[str, Any]
        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')

        request = self._client.delete(url, query_parameters, header_parameters)
        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
        response = pipeline_response.http_response

        if response.status_code not in [200, 400, 404, 500]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            raise HttpResponseError(response=response)

        if response.status_code == 200:
            deserialized = self._deserialize('Entity', pipeline_response)

        if response.status_code == 400:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 404:
            deserialized = self._deserialize('Error', pipeline_response)

        if response.status_code == 500:
            deserialized = self._deserialize('Error', pipeline_response)

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

        return deserialized
    layer_id_entities_entity_id_delete.metadata = {'url': '/layers/{layerId}/entities/{entityId}'}  # type: ignore
