Skip to content

Commit 016c15a

Browse files
committed
[_120] function list_tickets
1 parent 498e398 commit 016c15a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

irods/ticket.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ def get_epoch_seconds(utc_timestamp):
2828
raise # final try at conversion, so a failure is an error
2929

3030

31+
def list_tickets(session, all=True):
32+
"""
33+
Enumerates (via GenQuery1) all tickets visible by, or owned by, the current user.
34+
35+
Args:
36+
session: An iRODSSession object for use in the query.
37+
all: True if a comprehensive list is desired; otherwise only those
38+
tickets owned by the calling user.
39+
40+
Returns:
41+
An iterator over a range of ticket objects.
42+
"""
43+
query = session.query(TicketQuery.Ticket)
44+
if not all:
45+
query = query.filter(
46+
TicketQuery.Ticket.user_id == session.users.get(session.username).id
47+
)
48+
yield from query
49+
50+
3151
class Ticket:
3252
def __init__(self, session, ticket="", result=None, allow_punctuation=False):
3353
self._session = session

0 commit comments

Comments
 (0)