I have implemented a
REST interface for the AT extension to RT. It allows "rt" command querying,
editing, listing etc. of assets. You can do pretty much anything you would
expect from the command line or via a REST http conversation. Mail me if you'd
like to look at it since almost nobody has tested it much yet. It was developed
with RT 3.4.5 and AT 1.2.3. There is a patch for the "rt" command and also for a
dhandler in the RT REST tree because these were never written with types other
than Tickets in mind and there were some hard coded bits that needed to be
changed. Nothing major though and these patches don't break anything. If
anything, the dhandler patch fixes a bug in the REST interface which is only
apparent when trying to add a new type ...
I've attached the
README if anyone would like to see what you can do with it. I've also just added
support for AT custom link types so you can link/query links using custom
types from the command line. This needed another modification of the "rt"
command as there is a link type check in there which could never allow for
arbitrary custom link types as it has no information about them (it's REST,
after all ...)
PK
--
Philip Kime
NOPS Systems Architect
310 401 0407
Design notes
------------
Custom fields in the CLI use prefix "CF_". This makes them obvious and avoids
possible conflicts if people have Custom Fields named things like "Type" and
"Status". This doesn't apply to the usual TicketSQL search on Custom Fields
which are the usual "CF.{name}" format.
The ticket code for updates on Select* fields isn't great so I've augmented it
for assets with a check for a valid value before changes are made. Otherwise,
nasty things happen like - the update happens anyway and when the user next
edits the CFs in the GUI, the bad values are validated and deleted
automatically - nasty suprise.
The history display code for tickets allows a meaningless thing like this
rt show ticket/<tid>/history/id/<transid>
where Transaction <transid> has nothing to do with Ticket <tid>. You can
effectively look at any transaction via any ticket, which makes no sense and is
a potential security hole. You can't do this with assets - there is a check to
make sure that the transaction(s) requested are from the asset specified
Usage
-----
Usage is pretty much what one would expect from the rt command. I've added
asset stuff to the rt command help function so "rt help asset" works and
several of the exampled include example for assets. Here's a summary and some
more extensive examples.
Assets can be specified as
asset/<id>
just like tickets,users etc. and attributes like links and history as:
asset/<id>/history
asset/<id>/history/links
asset/<id>/history/watchers
asset/<id>/history/customfield
asset/<id>/history/id/<transaction id>
asset/<id>/links
the "-t" flag to the rt command takes "asset" as a type too.
Some examples:
# open the forms editing interface for a new asset. No custom fields will be
available since the Type of the Asset isn't know at this time
rt new -t asset
# New asset non-interactively with the required fields on command line
rt new -t asset set Name=somename Type=Servers Status=production
# edit an asset interactively
rt edit asset/<id>
# edit an asset non-interactively, changing a CF
rt edit asset/<id> set CF_name="some value"
# edit an asset non-interactively, adding a CF value to a multi-valued CF
rt edit asset/<id> add CF_name="some value"
# edit an asset non-interactively, deletin a CF value
rt edit asset/<id> del CF_name="some value"
# show an asset in full or in part
rt show asset/<id>
rt show asset/<id>/watchers
rt show asset/<id>/customfields
rt show asset/<id>/history
# show only certain fields
rt show asset/<id> -f Name,Type,CF_CFname
# show details of a specific transaction
rt show asset/<id>/history/id/<transaction id>
# show an asset's links
rt show asset/<id>/links
# add/remove links to/from an asset (all asset link types supported including
custom types)
rt link -t asset <id1> ComponentOf <id2>
rt link -t asset <id1> DependsOn <id2>
rt link -d -t asset <id1> DependsOn <id2>
# search for assets with TicketSQL
rt list -t asset 'CF.{CFname} LIKE "%"' (returns just IDs)
rt list -t asset -l 'CF.{CFname} LIKE "%"' (returns all fields)
_______________________________________________ http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users Community help: http://wiki.bestpractical.com Commercial support: [EMAIL PROTECTED] Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com We're hiring! Come hack Perl for Best Practical: http://bestpractical.com/about/jobs.html
