def handle_api_error(self, rbody, rcode, resp): if rcode in [400, 404]: raise error.InvalidRequestError(rbody, rcode, resp) elif rcode == 401: raise error.AuthenticationError(rbody, rcode, resp) else: raise error.APIError(rbody, rcode, resp)
def instance_url(self): object_id = self.get('object_id') if not object_id: raise error.InvalidRequestError( 'Could not determine which URL to request: %s instance ' 'has invalid ID: %r' % (type(self).__name__, object_id), 'object_id') object_id = util.utf8(object_id) base = self.class_url() extn = urllib.quote_plus(object_id) return "%s/%s" % (base, extn)