alignak_backend_client/client.py
def get_response(self, method, endpoint, headers=None, json=None, params=None, data=None):
        # pylint: disable=too-many-arguments
        """
        Returns the response from the requested endpoint with the requested method
        :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...)
        :param endpoint: str. the relative endpoint to access
        :param params: (optional) Dictionary or bytes to be sent in the query string
        for the :class:`Request`.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        of the :class:`Request`.
        :param json: (optional) json to send in the body of the :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
        :return: Requests.response
        """
        logger.debug("Parameters for get_response:")
        logger.debug("\t - endpoint: %s", endpoint)
        logger.debug("\t - method: %s", method)
        logger.debug("\t - headers: %s", headers)
        logger.debug("\t - json: %s", json)
        logger.debug("\t - params: %s", params)
        logger.debug("\t - data: %s", data)

        url = self.get_url(endpoint)

        # First stage. Errors are connection errors (timeout, no session, ...)
        try:
            response = self.session.request(method=method, url=url, headers=headers, json=json,
                                            params=params, data=data, proxies=self.proxies,
                                            timeout=self.timeout)
            logger.debug("response headers: %s", response.headers)
            logger.debug("response content: %s", response.content)
        except RequestException as e:
            response = {"_status": "ERR",
                        "_error": {"message": e, "code": BACKEND_ERROR},
                        "_issues": {"message": e, "code": BACKEND_ERROR}}
            raise BackendException(code=BACKEND_ERROR,
                                   message=e,
                                   response=response)
        else:
            return response
def get_response(self, method, endpoint, headers=None, json=None, params=None, data=None):
        # pylint: disable=too-many-arguments
        """
        Returns the response from the requested endpoint with the requested method
        :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...)
        :param endpoint: str. the relative endpoint to access
        :param params: (optional) Dictionary or bytes to be sent in the query string
        for the :class:`Request`.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        of the :class:`Request`.
        :param json: (optional) json to send in the body of the :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
        :return: Requests.response
        """
        logger.debug("Parameters for get_response:")
        logger.debug("\t - endpoint: %s", endpoint)
        logger.debug("\t - method: %s", method)
        logger.debug("\t - headers: %s", headers)
        logger.debug("\t - json: %s", json)
        logger.debug("\t - params: %s", params)
        logger.debug("\t - data: %s", data)

        url = self.get_url(endpoint)

        # First stage. Errors are connection errors (timeout, no session, ...)
        try:
            response = self.session.request(method=method, url=url, headers=headers, json=json,
                                            params=params, data=data, proxies=self.proxies,
                                            timeout=self.timeout)
            logger.debug("response headers: %s", response.headers)
            logger.debug("response content: %s", response.content)
        except RequestException as e:
            response = {"_status": "ERR",
                        "_error": {"message": e, "code": BACKEND_ERROR},
                        "_issues": {"message": e, "code": BACKEND_ERROR}}
            raise BackendException(code=BACKEND_ERROR,
                                   message=e,
                                   response=response)
        else:
            return response
Returns the response from the requested endpoint with the requested method
        :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...)
        :param endpoint: str. the relative endpoint to access
        :param params: (optional) Dictionary or bytes to be sent in the query string
        for the :class:`Request`.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body
        of the :class:`Request`.
        :param json: (optional) json to send in the body of the :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
        :return: Requests.response