Talk:REST: Difference between revisions
Jump to navigation
Jump to search
(Created page with " Hi everyone, I'm trying to build a script that can report on multiple queues. I've gotten it to work for one single queue, but it returns an empty list when I try it on mu...") |
No edit summary |
||
Line 4: | Line 4: | ||
I'm trying to build a script that can report on multiple queues. I've gotten it to work for one single queue, but it returns an empty list when I try it on multiple queues at the same time. What am I missing? | I'm trying to build a script that can report on multiple queues. I've gotten it to work for one single queue, but it returns an empty list when I try it on multiple queues at the same time. What am I missing? | ||
<nowiki> | |||
<nowiki> | |||
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||
Line 47: | Line 46: | ||
# prints: [] | # prints: [] | ||
</nowiki> | </nowiki> | ||
If I use this query the results are as expected (so that would rule out connection of credential problems): | If I use this query the results are as expected (so that would rule out connection of credential problems): | ||
<nowiki> | |||
<nowiki> | |||
tickets = rtsystem.search(Queue='queue_a', raw_query="(Owner='nobody')+AND+(Status='Open'+OR+Status='New'+OR+Status='Stalled')") | tickets = rtsystem.search(Queue='queue_a', raw_query="(Owner='nobody')+AND+(Status='Open'+OR+Status='New'+OR+Status='Stalled')") | ||
</nowiki> | </nowiki> | ||
Anyone? | Anyone? |
Revision as of 09:21, 14 June 2016
Hi everyone,
I'm trying to build a script that can report on multiple queues. I've gotten it to work for one single queue, but it returns an empty list when I try it on multiple queues at the same time. What am I missing?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import rt from credentials import * # Contains rturl, rtuser, rtpass rtsystem = rt.Rt(rturl, rtuser, rtpass) queues = ['queue_a', 'queue_b', 'queue_c'] states = ['Open', 'New', 'Stalled'] def build_query(): queues_part = "(Queue='{}')".format("'+OR+Queue='".join(queues)) states_part = "(Status='{}')".format("'+OR+Status='".join(states)) query_items = [queues_part, states_part] raw_query = ("+AND+".join(query_items)) return raw_query def gettickets(): try: rtsystem.login() tickets = rtsystem.search(raw_query=build_query()) print('----->',tickets) except Exception as login_err: print('===> Failed to retrieve tickets. Reason:\n', str(login_err)) finally: rtsystem.logout() if __name__ == '__main__': # to check query for errors print(build_query()) # prints: (Queue='queue_a'+OR+Queue='queue_b'+OR+Queue='queue_c')+AND+(Status='Open'+OR+Status='New'+OR+Status='Stalled') # should return all new, open and stalled tickets in queue_a,b,c gettickets() # prints: []
If I use this query the results are as expected (so that would rule out connection of credential problems):
tickets = rtsystem.search(Queue='queue_a', raw_query="(Owner='nobody')+AND+(Status='Open'+OR+Status='New'+OR+Status='Stalled')")
Anyone?