python-irodsclient
python-irodsclient copied to clipboard
method for 'list tickets'
similar to functionality provided by:
iticket lsiticket ls-all
I've investigated today in this point. Since this informations are found in the iCAT database it's not too difficult to have it working:
- Add a Ticket class to the SQL models (
models.py) in your library:
class Ticket(Model):
""" see rodsGenQuery.h in irods """
id = Column(Integer, 'COL_TICKET_ID', 2200)
string = Column(String, 'COL_TICKET_STRING', 2201)
type = Column(String, 'COL_TICKET_TYPE', 2202)
user_id = Column(Integer, 'COL_TICKET_USER_ID', 2203)
object_id = Column(Integer, 'COL_TICKET_OBJECT_ID', 2204)
uses_limit = Column(Integer, 'COL_TICKET_USES_LIMIT', 2206)
uses_count = Column(Integer, 'COL_TICKET_USES_COUNT', 2207)
expiration = Column(DateTime, 'COL_TICKET_EXPIRY_TS', 2208)
# created = Column(DateTime, 'COL_TICKET_CREATE_TIME', 2209) # does not work in my test
- Make queries:
from irods.models import Ticket, DataObject, User
data = sess.query(
# Ticket.id,
Ticket.string, Ticket.type, User.name, DataObject.name,
Ticket.uses_limit, Ticket.uses_count,
Ticket.expiration
).all() # could trigger NoResultFound
COL_TICKET_CREATE_TIME should get handled correctly once https://github.com/irods/irods/issues/5929 is fixed/merged.
irods/irods#5929 was fixed/included in 4.2.11 and 4.3.0.
Still a little work to do it appears...
https://github.com/irods/python-irodsclient/blob/4818f65882245d053d9cb773e5aee5b00b7d7f64/irods/models.py#L248-L250