def latestUserCase(account, user, transformer=None): retrieveData = {"ruleSet":"ECBase", "userId":user} params = {"account":account} if transformer !=None: params["transformer"]=transformer res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/userId/"+retrieveData["userId"]+"/latest", params).strip() return "["+res+"]"
def binCases(account, bin, transformer=None): retrieveData = {"ruleSet":"ECBase","bin":bin} params = {"account":account} if transformer !=None: params["transformer"]=transformer res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/bin/"+retrieveData["bin"],params).strip() return res
def users(account, recent=None): retrieveData = {"ruleSet":"ECBase"} params = {"account":account} if recent!=None: params["recent"]=recent res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/userId/", params).strip() return res
def latestSessionCase(account, session, transformer=None): params = {"account":account} if transformer !=None: params["transformer"]=transformer retrieveData = {"ruleSet":"ECBase", "sessionId":session} res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/sessionId/"+retrieveData["sessionId"]+"/latest", params).strip() return "["+res+"]"
def accountCases(account): retrieveData = {"ruleSet": "ECBase"} res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/case", { "account": account }).strip() return res
def sessionCases(account, session): retrieveData = {"ruleSet": "ECBase", "sessionId": session} res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/sessionId/" + retrieveData["sessionId"], { "account": account }).strip() return res
def query1(account): retrieveData = { "ruleSet": "ECBase", "query": '{ "case.browser": "firefox" }' } res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/query/", { "query": retrieveData["query"], "account": account }).strip() return res
def query2(account): retrieveData = { "ruleSet": "ECBase", "query": '{ "tags": "WinXX", "case.userId" : "mikeytest"}' } res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/query/", { "query": retrieveData["query"], "account": account }).strip() return res
def queryPlatform(account, platform): retrieveData = { "ruleSet": "ECBase", "query": '{ "case.device.platform": ' + platform + ' }' } res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/query/", { "query": retrieveData["query"], "account": account }).strip() return res
def createSubscription(customerId): service = "/customers/"+customerId+"/subscriptions" params = { "plan":"eCKB-t", } res = HttpCall.callHttpPOST(uri, service, params, contentType=None, username="******") res2 = res.replace("\r", "") null=None false=0 true=1 dict = eval(res2) return dict["id"]
def loadTemplate(case, name="", uid="", trace=0): contextExtension = "" if (uid!=""): contextExtension=uid if (name!=""): contextExtension="name/"+name if trace: print case print name print uid response = HttpCall.callHttpPOST(server, "objectology/template/"+contextExtension, {"data":case}).strip() return response
def createCustomer(): service = "/customers" params = { "card":getCardToken(), "description":"test example for revsys", } res = HttpCall.callHttpPOST(uri, service, params, contentType=None, username="******") res2 = res.replace("\r", "") null=None false=0 true=1 dict = eval(res2) return dict["id"]
def queryRecent(account, mins): mins_ago = Date().getTime() - mins * 60 * 1000 retrieveData = { "ruleSet": "ECBase", "query": '{ "timeStamp": { "$gt": "' + str(mins_ago) + '"} }' } print retrieveData["query"] res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/query/", { "query": retrieveData["query"], "account": account }).strip() return res
def getCardToken(): service = "/tokens" params = { "card[number]":"4242424242424242", "card[exp_month]":"12", "card[exp_year]":"2015", "card[cvc]":"123", } res = HttpCall.callHttpPOST(uri, service, params, contentType=None, username="******") res2 = res.replace("\r", "") null=None false=0 true=1 cardDict = eval(res2) return cardDict["id"]
def query3(account): mins_ago = Date().getTime() - 18 * 60 * 1000 retrieveData = { "ruleSet": "ECBase", "query": '{ "tags": "WinXX", "case.userId" : "mikeytest", "timeStamp": { "$gt": "' + str(mins_ago) + '"} }' } res = HttpCall.callHttpGET( uri, service + "/" + retrieveData["ruleSet"] + "/query/", { "query": retrieveData["query"], "account": account }).strip() return res
def createSubscription(customerId): service = "/customers/" + customerId + "/subscriptions" params = { "plan": "eCKB-t", } res = HttpCall.callHttpPOST(uri, service, params, contentType=None, username="******") res2 = res.replace("\r", "") null = None false = 0 true = 1 dict = eval(res2) return dict["id"]
def createCustomer(): service = "/customers" params = { "card": getCardToken(), "description": "test example for revsys", } res = HttpCall.callHttpPOST(uri, service, params, contentType=None, username="******") res2 = res.replace("\r", "") null = None false = 0 true = 1 dict = eval(res2) return dict["id"]
def getCardToken(): service = "/tokens" params = { "card[number]": "4242424242424242", "card[exp_month]": "12", "card[exp_year]": "2015", "card[cvc]": "123", } res = HttpCall.callHttpPOST(uri, service, params, contentType=None, username="******") res2 = res.replace("\r", "") null = None false = 0 true = 1 cardDict = eval(res2) return cardDict["id"]
def getTemplates(): response = HttpCall.callHttpGET(server, "objectology/template/", {}).strip() return response
def getInstance(instanceType, id): response = HttpCall.callHttpGET(server, "objectology/"+instanceType+"/"+id, {}).strip() return response
'{ "browser":"safari", "platform":"ios", "sessionId": "{sessionId}", "userId": "{userId}" }', '{ "browser":"safari", "platform":"Android", "sessionId": "{sessionId}", "userId": "{userId}" }', '{ "browser":"safari", "platform":"MacOS", "sessionId": "{sessionId}", "userId": "{userId}" }', '{ "browser":"chrome", "platform":"Win32", "screen": {"availWidth": 1600}, "sessionId": "{sessionId}", "userId": "{userId}" }', '{ "browser":"chrome", "platform":"Win32", "screen": {"availWidth": 550}, "sessionId": "{sessionId}", "userId": "{userId}" }', '{ "browser":"chrome", "platform":"Win64", "availWidth": 550, "sessionId": "{sessionId}", "userId": "{userId}" }', '{ "browser":"chrome", "platform":"Win64", "screen": {"availWidth": 500}, "sessionId": "{sessionId}", "userId": "{userId}" }', ] #clearData = {"ruleSet":"ECBaseRules.txt", "action":"clear"} #HttpCall.callHttpGET(uri, service+"/ruleSet/"+clearData["ruleSet"], clearData).strip() retrieveData = {"ruleSet":"ECBaseRules.txt"} fullUri = uri+service+"/ruleSet/"+retrieveData["ruleSet"]+"/bin/reload" print fullUri res = HttpCall.callHttpGET(uri, service+"/ruleSet/"+retrieveData["ruleSet"]+"/bin/reload",{}).strip() print res print print Date() for i in range(1): for case in sampleData: data = {"ruleSet":"ECBaseRules.txt", "case":case.replace('{sessionId}', sessions[8 * i%len(sessions)]).replace('{userId}', users[i%len(users)])} res=HttpCall.callHttpGET(uri, service+"/ruleSet/"+data["ruleSet"], data).strip() print res print print Date() retrieveData = {"ruleSet":"ECBaseRules.txt"}
def getInstanceSummaries(type): response = HttpCall.callHttpGET(server, "objectology/{type}/".replace("{type}", type), {"view":"summary"}).strip() return response
def userCases(account): retrieveData = {"ruleSet":"ECBase", "userId":"a123"} res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/userId/"+retrieveData["userId"], {"account":account}).strip() return res
subscriptions = ["eCK-1000", "eCK-1001", "eCK-1002", "eCK-1003", "eCK-1004", "eCK-1005"] sampleData = [ '{ "case":"1000" }', '{ "browser":"chrome", "platform":"Win", "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"firefox", "platform":"Win32", "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"safari", "platform":"ios", "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"safari", "platform":"Android", "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"safari", "platform":"MacOS", "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"chrome", "platform":"Win32", "screen": {"availWidth": 1600}, "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"chrome", "platform":"Win32", "screen": {"availWidth": 550}, "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"chrome", "platform":"Win64", "availWidth": 550, "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', '{ "browser":"chrome", "platform":"Win64", "screen": {"availWidth": 500}, "sessionId": "{sessionId}", "userId": "{userId}", "accountId": "{accountId}" }', ] clearData = {"ruleSet":"ECBase", "action":"clear"} HttpCall.callHttpGET(uri, service+"/"+clearData["ruleSet"], clearData).strip() retrieveData = {"ruleSet":"ECBase"} fullUri = uri+service+"/"+retrieveData["ruleSet"]+"/bin/reload" print fullUri res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/bin/reload",{}).strip() print res print print Date() for i in range(1): for case in sampleData: data = {"ruleSet":"ECBase", "case":case.replace('{sessionId}', sessions[8 * i%len(sessions)]).replace('{userId}', users[i%len(users)]).replace('{accountId}', subscriptions[i%len(subscriptions)])} res=HttpCall.callHttpGET(uri, service+"/"+data["ruleSet"], data).strip()
def createInstance(instanceType, case, contentType="text/xml"): response = HttpCall.callHttpPOST(server, "objectology/"+instanceType+"/", {"data":case}, contentType=contentType).strip() return response
def getInstances(type): response = HttpCall.callHttpGET(server, "objectology/{type}/".replace("{type}", type), {}).strip() return response
def deleteInstance(instanceType, uid): response = HttpCall.callHttpDELETE(server, "objectology/"+instanceType+"/"+uid, {}).strip() return response
def deleteTemplate(uid): response = HttpCall.callHttpDELETE(server, "objectology/template/"+uid, {}).strip() return response
def getTemplateByName(name): response = HttpCall.callHttpGET(server, "objectology/template/name/"+urllib.quote(name), {}).strip() return response
def deleteTemplateByName(name): response = HttpCall.callHttpDELETE(server, "objectology/template/name/"+name, {}).strip() return response
def getInstanceByProperty(instanceType, propertyName, value): response = HttpCall.callHttpGET(server, "objectology/"+instanceType+"/query", {propertyName: value}).strip() return response
def applyDelta(instanceTypeAndId, case, contentType="text/xml"): response = HttpCall.callHttpPOST(server, "objectology/"+instanceTypeAndId+"/", {"data":case}, contentType=contentType).strip() return response
def binCases(account, bin): retrieveData = {"ruleSet":"ECBase","bin":bin} res = HttpCall.callHttpGET(uri, service+"/"+retrieveData["ruleSet"]+"/bin/"+retrieveData["bin"],{"account":account}).strip() return res
def makeQuery(instanceType, case): response = HttpCall.callHttpPOST(server, "objectology/"+instanceType+"/query", {"data":case}, contentType="application/json").strip() null = None instances = eval(response) return instances
def getInstanceIds(type): response = HttpCall.callHttpGET(server, "objectology/{type}/".replace("{type}", type), {"view":"identifier"}).strip() return getIdsFromIdResponse(response)
import setPath reload(setPath) import HttpCall reload(HttpCall) from java.io import File from java.util import Date uri = "http://localhost:8080" service = "/oddball-service" sampleData = [ "Y304RPD", "Z304RAX", "ABC304R", "RE02UBD", "423ABC113", "123X113", "89HJ67", "RE52UAD", "ABC123", "AB12CD", "123D113", "AB12CD", ] for case in sampleData: data = {"ruleSet": "Reg.txt", "case": case} print HttpCall.callHttpGET(uri, service, data)