(self, path, data=None, method=None,
             return_for_status=[], headers=None)
return response
The wrapper over `requests` library.
        :param path: url_path
        :param data: Post data, None in case of GET
        :type data: json/dict
        :param method: None or GET/POST
        :type method: str
        :param return_for_status: Status codes which should be raised instead of
            being handled here, so that calling method can handle it in it's
            own custom way.
        :type return_for_status: str/list
        :param headers: Add parameters to header
        :type headers: dict
        :return:
The wrapper over `requests` library.
        :param path: url_path
        :param data: Post data, None in case of GET
        :type data: json/dict
        :param method: None or GET/POST
        :type method: str
        :param return_for_status: Status codes which should be raised instead of
            being handled here, so that calling method can handle it in it's
            own custom way.
        :type return_for_status: str/list
        :param headers: Add parameters to header
        :type headers: dict
        :return:
The wrapper over requests library . : param path : url_path : param data : Post data None in case of GET : type data : json / dict : param method : None or GET / POST : type method : str : param return_for_status : Status codes which should be raised instead of being handled here so that calling method can handle it in it s own custom way . : type return_for_status : str / list : param headers : Add parameters to header : type headers : dict : return :
def call(self, path, data=None, method=None,
             return_for_status=[], headers=None):
        """
        The wrapper over `requests` library.
        :param path: url_path
        :param data: Post data, None in case of GET
        :type data: json/dict
        :param method: None or GET/POST
        :type method: str
        :param return_for_status: Status codes which should be raised instead of
            being handled here, so that calling method can handle it in it's
            own custom way.
        :type return_for_status: str/list
        :param headers: Add parameters to header
        :type headers: dict
        :return:
        """
        header_params = self.header
        header_params.update({'User-Agent': 'Pygmy API REST client'})
        if headers:
            header_params.update(headers)

        request_param = dict(
            url=self.makeurl(self.rest_url, path), auth=self.basic_auth, headers=header_params
        )

        _call = requests.get
        if method is None:
            method = 'GET' if data is None else 'POST'
        if method.upper() == 'POST':
            _call = requests.post
            if self.request_data_type == 'json':
                request_param['json'] = data
            else:
                request_param['data'] = data
        # Make rest call and handle the response
        response = _call(**request_param)

        if return_for_status and not isinstance(return_for_status, list):
            return_for_status = [return_for_status]
        return_for_status = self.return_for_status + return_for_status
        if response.status_code in return_for_status:
            return response

        error_object = self.error_object_from_response(response)
        if error_object is not None:
            logger.debug('Reveived error response: %s', response.text)
            raise error_object
        return response
def call ( self , path , data = None , method = None , return_for_status = [ ] , headers = None ) : header_params = self . header header_params . update ( { 'User-Agent' : 'Pygmy API REST client' } ) if headers : header_params . update ( headers ) request_param = dict ( url = self . makeurl ( self . rest_url , path ) , auth = self . basic_auth , headers = header_params ) _call = requests . get if method is None : method = 'GET' if data is None else 'POST' if method . upper ( ) == 'POST' : _call = requests . post if self . request_data_type == 'json' : request_param [ 'json' ] = data else : request_param [ 'data' ] = data # Make rest call and handle the response response = _call ( * * request_param ) if return_for_status and not isinstance ( return_for_status , list ) : return_for_status = [ return_for_status ] return_for_status = self . return_for_status + return_for_status if response . status_code in return_for_status : return response error_object = self . error_object_from_response ( response ) if error_object is not None : logger . debug ( 'Reveived error response: %s' , response . text ) raise error_object return response