def _upload(  # pylint: disable=inconsistent-return-statements
        self,
        rule_id: str,
        stream: str,
        body: Union[List[JSON], IO],
        *,
        content_encoding: Optional[str] = None,
        **kwargs: Any
    ) -> None:
        """Ingestion API used to directly ingest data using Data Collection Rules.

        See error response code and error response message for more detail.

        :param rule_id: The immutable Id of the Data Collection Rule resource. Required.
        :type rule_id: str
        :param stream: The streamDeclaration name as defined in the Data Collection Rule. Required.
        :type stream: str
        :param body: An array of objects matching the schema defined by the provided stream. Is either
         a [JSON] type or a IO type. Required.
        :type body: list[JSON] or IO
        :keyword content_encoding: gzip. Default value is None.
        :paramtype content_encoding: str
        :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(body, (IOBase, bytes)):
            _content = body
        else:
            _json = body

        request = build_logs_ingestion_upload_request(
            rule_id=rule_id,
            stream=stream,
            content_encoding=content_encoding,
            content_type=content_type,
            api_version=self._config.api_version,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        request.url = self._client.format_url(request.url, **path_format_arguments)

        _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 [204]:
            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, {})
Ingestion API used to directly ingest data using Data Collection Rules.

        See error response code and error response message for more detail.

        :param rule_id: The immutable Id of the Data Collection Rule resource. Required.
        :type rule_id: str
        :param stream: The streamDeclaration name as defined in the Data Collection Rule. Required.
        :type stream: str
        :param body: An array of objects matching the schema defined by the provided stream. Is either
         a [JSON] type or a IO type. Required.
        :type body: list[JSON] or IO
        :keyword content_encoding: gzip. Default value is None.
        :paramtype content_encoding: str
        :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:
        
Solutions/CyberArkAudit/Data Connectors/.python_packages/lib/site-packages/azure/monitor/ingestion/_operations/_operations.py