Skip to content

Commit

Permalink
Merge pull request #5 from xebialabs-community/CheckStatusChangeRequest
Browse files Browse the repository at this point in the history
Added CR to checkStatus Task
  • Loading branch information
magichome committed May 30, 2019
2 parents 42a4ecb + 6f542d6 commit 09814a3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/main/resources/remedy/RemedyClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ def get_entry(self, form_name, entry_id):
print "get_entry error %s" % (response)
self.throw_error(response)

# https://docs.bmc.com/docs/pages/releaseview.action?pageId=517036478#id-/entry/{formName}/{entryId}-Getsingleentry
def get_change_request(self, form_name, change_id):
# example: /api/arsys/v1/entry/CHG:ChangeInterface?q=%27Infrastructure%20Change%20ID%27%3d%22CRQ000000152848%22
remedy_api_url = '%s/%s?q=%27Infrastructure%20Change%20ID%27%3d%22%s%22' % (URI_PREFIX, form_name, change_id)
print 'Remedy CR API is: %s' % remedy_api_url
response = self.httpRequest.get(remedy_api_url, contentType='application/json; charset=utf-8', headers = self.headers)

if response.getStatus() == RESULT_STATUS:
data = json.loads(response.getResponse())
return data['values']
else:
print "get_entry error %s" % (response)
self.throw_error(response)

# https://docs.bmc.com/docs/pages/releaseview.action?pageId=517036472#id-/entry/{formName}-GETmultipleentries
def query_entrys(self, form_name, query):
remedy_api_url = '%s/%s?q=%s' % (URI_PREFIX, form_name, urllib.quote_plus(query))
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/remedy/checkStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

client = RemedyClient.create_client(remedyServer, username, password)

data = client.get_entry(formName, entryId)
if matchChangId:
print "Matching Change Request ID: %s" % entryId
data = client.get_change_request(formName, entryId)

else:
print "Matching Entry ID: %s" % entryId
data = client.get_entry(formName, entryId)

if statusField not in data:
sys.exit("Field with name [%s] not found in entry [%s], data [%s].\n" % (statusField, data['Request ID'], str(data)))
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@
<property name="scriptLocation" default="remedy/checkStatus.py" hidden="true"/>

<property name="formName" category="input" label="Form Name" required="true"/>
<property name="entryId" category="input" label="Entry Id" required="true"/>
<property name="statusField" category="input" label="Status Field" default="Status" description="Name of the Status field for this form"/>
<property name="entryId" category="input" label='Entry/Change Id' required="true" description="Entry ID or Change Request ID"/>
<property name="matchChangId" category="input" required="false" kind="boolean" default="false" description="When checked Change ID will be matched insted of Entry ID" />
<property name="statusField" category="input" label="Status Field" default="Status" description='Status field for this form: For Entry "Status" for Chang Requests "Change Request Status" '/>

<property name="status" category="output"/>
</type>
Expand Down

0 comments on commit 09814a3

Please sign in to comment.