http request:put
# 定义函数:refresh segement # curl -X PUT -s --user "****:*****" -H ‘Content-Type: application/json‘ -d ‘{"startTime":1515283200000, "endTime":1515369600000, "buildType":"REFRESH"}‘ "*****/kylin/api/cubes/*****/rebuild" || { log "ERROR" "$project" "Build cube failed"; exit 1;} def refreshOneSegment( kylinBaseUrl,cubeName,userName,pwd,startTimestamp,endTimestamp): urlTemp=kylinBaseUrl+"/api/cubes/"+cubeName+"/rebuild" dataTemp ={"startTime":startTimestamp, "endTime":endTimestamp, "buildType":"REFRESH"} base64stringT = base64.encodestring(‘%s:%s‘ % (userName, pwd)).replace(‘\n‘, ‘‘) requestTemp=urllib2.Request(urlTemp) requestTemp.add_header("Authorization", "Basic %s" % base64stringT) requestTemp.add_header("Content-Type", "application/json;charset=UTF-8") requestTemp.add_data(json.dumps(dataTemp)) request2.get_method = lambda: ‘PUT‘ # or ‘DELETE‘ response2 = urllib2.urlopen(request2) data2 = response2.read() return data2;
http request :get
# 定义函数:get segements # curl -X GET --user "****:*****" -H ‘Content-Type: application/json‘ "*****/kylin/api/cubes/*****" def getSegmentsBetweenTimeRange(kylinBaseUrl,cubeName,userName,pwd): urlTemp=kylinBaseUrl+"/api/cubes/"+cubeName base64stringT = base64.encodestring(‘%s:%s‘ % (userName, pwd)).replace(‘\n‘, ‘‘) requestTemp=urllib2.Request(urlTemp) requestTemp.add_header("Authorization", "Basic %s" % base64stringT) requestTemp.add_header("Content-Type", "application/json") responseTemp = urllib2.urlopen(requestTemp) dataTemp = responseTemp.read() return dataTemp;