Created
January 22, 2014 23:57
-
-
Save KyleAMathews/8570085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path: /sites/<site-uuid>/tickets/ | |
class YggdrasilSiteTickets(Resource): | |
@ProfileByMethod(modify_prefix=False) | |
def getChild(self, path, request): | |
print path | |
if path == '': | |
return self | |
return YggdrasilSiteTicketAttachments(path) | |
def __init__(self, site): | |
Resource.__init__(self) | |
self.site = site | |
def render_GET(self, request): | |
# Create elasticsearch client object | |
es = ConnectionSubclass( | |
baseURL=DESK_ELASTICSEARCH['baseUrl'], | |
index=DESK_ELASTICSEARCH['index'], | |
username=DESK_ELASTICSEARCH['username'], | |
password=DESK_ELASTICSEARCH['password'], | |
) | |
request.setHeader('Content-Type', 'application/json') | |
def callback1(res): | |
request.write(json.dumps(res)) | |
request.finish() | |
def errback1(failure): | |
log.err(failure) | |
request.write(json.dumps("Unknown error")) | |
request.finish() | |
options = {} | |
options['filters'] = [] | |
#print request.args | |
if "from" in request.args: | |
options['from'] = request.args.get('from')[0] | |
if "size" in request.args: | |
options['size'] = request.args.get('size')[0] | |
if "id" in request.args: | |
options['filters'].append({ "id": request.args.get('id')[0] }) | |
if "filter_people" in request.args: | |
options['filters'].append({ "people": request.args.get('filter_people')[0] }) | |
if "filter_status" in request.args: | |
options['filters'].append({ "status": request.args.get('filter_status')[0] }) | |
if "filter_month" in request.args: | |
options['filters'].append({ "month": request.args.get('filter_month')[0].split('***') }) | |
if "filter_query" in request.args: | |
options['query'] = request.args.get('filter_query')[0] | |
if PANTHEON_ENVIRONMENT != "onebox": | |
options['filters'].append({ "site": self.site }) | |
#print options | |
d = es.query(options) | |
d.addCallback(callback1) | |
d.addErrback(errback1) | |
return NOT_DONE_YET | |
# Path: /sites/<site-uuid>/tickets/<ticket-id>/attachments | |
class YggdrasilSiteTicketAttachments(proxy.ReverseProxyResource): | |
isLeaf = True | |
def __init__(self, caseId): | |
#self.caseId = caseId | |
print "hi" | |
#proxy.ReverseProxyResource.__init__(self, host="techmeme.com", path="", port=80, reactor=reactor) | |
def render(self, request): | |
request.setHost(host="techmeme.com", port=80, ssl=0) | |
print request.__dict__ | |
p = proxy.ReverseProxyResource(host="techmeme.com", path="", port=80, reactor=reactor) | |
return p.render(request) | |
#return proxy.ReverseProxyResource.render(self, request) | |
#def render_GET(self, request): | |
#def callback(res): | |
#print res.__dict__ | |
#request.write(res.body) | |
#request.finish() | |
#def errback(failure): | |
#log.err(failure) | |
#request.write(json.dumps("Unknown error")) | |
#request.finish() | |
#requester = api.request_factory(host="pantheon-systems.desk.com/api/v2/cases/%s/attachments" % str(self.caseId)) | |
#requester.scheme = "https" | |
#requester.port = 443 | |
#requester.cert_basepath = None | |
#requester.certname = None | |
#requester.user = "[email protected]" | |
#requester.password = "stencil690" | |
#d = requester.run() | |
##d = CaseAttachments(self.caseId) | |
#d.addCallback(callback) | |
#d.addErrback(errback) | |
#return NOT_DONE_YET | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment