IBM / ELM-Python-Client

Python client for IBM Enterprise Lifecycle Management applications with example commandline applications for OSLC Query export to CSV from DOORS Next (DN/DNG), Enterprise Workflow Management (EWM/RTC) and Enterprise Test Management (ETM/RQM), ReqIF import/export, and DOORS Next Reportable REST export to CSV/XML
Other
26 stars 13 forks source link

How to use elmclient to connect to RTC Server and Update Bug Information via Python Script? #66

Closed dmjndx closed 2 months ago

dmjndx commented 3 months ago

Hello barny,

I hope this message finds you well. I've been using your Python code library, which has been incredibly helpful for my projects. However, I'm currently facing a challenge that I'm hoping you can assist me with.

I'm trying to automate the process of updating bug information on an RTC (Rational Team Concert or similar) server through a Python script. After some research, I came across elmclient (or a similar library if elmclient is not the exact one), which I understand can be used for interacting with RTC servers. However, I'm having difficulty figuring out how to properly set up the connection and send PUT requests to update specific bug records.

My question is:

Is elmclient (or a similar library) suitable for connecting to an RTC server and performing CRUD operations like updating bug records? If so, could you provide a brief example or guide on how to set up the connection and use it to send a PUT request to update a bug's information (e.g., status, comments, etc.)? I've been trying to find resources and examples online, but the specific use case with elmclient and RTC servers seems to be less documented. I'm also open to alternative suggestions if elmclient is not the most suitable tool for this task.

Thank you very much for your time and for your contributions to the Python community. I appreciate any help or guidance you can provide.

Best regards,

Jay meng

barny commented 2 months ago

Hi Jay - apologies only just seen this.

Glad to hear you find elmclient useful.

Potentially elmclient can connect to EWM, using OSLC, but I don't have an example.The basic setup would be similar to the code in ccm_simple_attachmentdownload.py down to line 40 - that gives you a ccm app instance to do things with like in dn_simple_oslcquery.py line 46 which does an OSLC GET returning some xml. You probably want to find the WI using e.g. OSLC Query on the id to get its URL, then you can do things with the WI. See lines 71-79 although as ccm doesn't have config management you would query on the project and use query capability oslc_ccm:

I believe Ralph Schoon has written about using OSLC APIs with EWM - maybe see https://rsjazz.wordpress.com/2021/12/09/ewm-discovery/ for more details.

Something like this should work if workitemid has an existing id in your project proj: Once you have the workitem URI you can GET and PUT it.

# create our "server" which is how we connect to EWM
# first enable the proxy so if a proxy is running it can monitor the communication with server (this is ignored if proxy isn't running)
elmserver.setupproxy(jazzhost,proxyport=8888)
theserver = elmserver.JazzTeamServer(jazzhost, username, password, verifysslcerts=False, jtsappstring=f"jts:{jtscontext}", appstring='rm', cachingcontrol=caching)

# create the CMM application interface
ccmapp = theserver.find_app( f"ccm:{ccmcontext}", ok_to_create=True )

p = ccmapp.find_project( proj )

qcbase = p.get_query_capability_uri("oslc_cm1:ChangeRequest")

# query
results = p.execute_oslc_query(
    qcbase,
    whereterms=[['dcterms:identifier','=',f'"{workitemid}"']],
    select=['*'],
#    prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms'} # note this is reversed - url to prefix
    )

workitem_u = list(results.keys())[0]

print( f"Work item {workitemid} uri is {workitem_u}" )

# now retrieve it
workitem_x = p.execute_get_xml( workitem_u )

print( ET.tostring( workitem_x ) )
barny commented 2 months ago

Re: Ralph's blog, elmclient handles all the discovery, finding project, can do oslc query, etc. I guess you're most interested in an example of updating with a PUT, but with the snippet above you have the workitem URI and just need to update the retrieved XML and call p.execute_put_rdf_xml(). You might have to include a if-match header with the value (complete with surrounding ") of the Etag returned from the GET.

dmjndx commented 2 months ago

Dear barny,

I just wanted to take a moment to express my sincere gratitude for your quick and helpful response to my issue. Your solution worked perfectly(use execute_put_rdf_xml() to update my issue), and I was able to resolve the problem seamlessly. Your dedication to supporting users and maintaining your library is truly admirable.

Thank you again for your time and effort. Your work is invaluable to the community, and I appreciate your contributions. Best regards,

Jay