def getParamsForMultiRequest(self, multiRequestIndex): self.params.put('service', self.service) self.params.put('action', self.action) multiRequestParams = KalturaParams() multiRequestParams.add(multiRequestIndex, self.params.get()) return multiRequestParams.get()
def doHttpRequest(self, url, params=KalturaParams(), files=None): if not files: requestTimeout = self.config.requestTimeout else: # 10 seconds is a reasonable default timeout requestTimeout = 10 r = self.openRequestUrl(url, params, files, self.requestHeaders, requestTimeout) data = self.readHttpResponse(r) self.responseHeaders = r.headers return data
def queueServiceActionCall(self, service, action, returnType, params=KalturaParams(), files=None): for param in self.requestConfiguration: if isinstance(self.requestConfiguration[param], KalturaObjectBase): params.addObjectIfDefined( param, self.requestConfiguration[param]) else: params.put(param, self.requestConfiguration[param]) call = KalturaServiceActionCall(service, action, params, files) if (self.multiRequestReturnType is not None): self.multiRequestReturnType.append(returnType) self.callsQueue.append(call)
def __init__(self, service, action, params=KalturaParams(), files=None): self.service = service self.action = action self.params = params self.files = files
def getRequestParams(self): params = KalturaParams() files = {} for param in self.clientConfiguration: params.put(param, self.clientConfiguration[param]) params.put("format", self.config.format) url = self.config.serviceUrl + "/api_v3" if (self.multiRequestReturnType is not None): url += "/service/multirequest" for i, call in enumerate(self.callsQueue): callParams = call.getParamsForMultiRequest(i) callFiles = call.getFilesForMultiRequest(i) params.update(callParams) if callFiles: files.update(callFiles) else: call = self.callsQueue[0] url += "/service/" + call.service + "/action/" + call.action params.update(call.params.get()) if call.files: files.update(call.files) signature = params.signature() params.put("kalsig", signature) self.log("request url: [%s]" % url) self.log("request json: [%s]" % params.toJson()) return (url, params, files)