-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added get newest RT ticket #232
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,28 @@ def find(header): | |
status=find('Status'), | ||
) | ||
|
||
@classmethod | ||
def get_newest(cls, connection, queue): | ||
"""Returns the newest created RT ticket in the given queue""" | ||
resp = connection.get("https://rt.ocf.berkeley.edu/REST/1.0/search/ticket?query=Queue='{}'&orderby=-Created".format(queue)) | ||
assert resp.status_code == 200, resp.status_code | ||
assert '200 Ok' in resp.text | ||
|
||
lines = resp.text.splitlines() | ||
|
||
def find(header): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk this is legacy, it's elegant but comparatively inefficient i guess (need to do 4 passes instead of 1) |
||
for line in lines: | ||
if line.startswith(header + ': '): | ||
return line.split(': ', 1)[1] | ||
|
||
return cls( | ||
number=num, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably need to do something to find |
||
owner=find('Owner'), | ||
subject=find('Subject'), | ||
queue=find('Queue'), | ||
status=find('Status'), | ||
) | ||
|
||
@classmethod | ||
def create(cls, connection, queue, requestor, subject, text, **kwargs): | ||
"""Create an RT ticket and returns an instance of the result""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this would work since I can't seem to find relevant stuff in the docs (https://rt-wiki.bestpractical.com/wiki/REST#Ticket_Search), but I think it might return a bunch of tickets instead of one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.