def reuse(host_url, username, password, source_folder, target_folder, rule_name):
"""
This method trigger a requirements reuse. Source and target may be in different projects.
Query parameters:
[source_folder] is the the source folder for reuse (e.g. Requirements Plugin/Implementation)
[target_folder] is the the target folder for the reuse (e.g. Requirements Plugin/Features/Baseline/Permissions)
[rule_name] is the the name of a reuse rule (e.g. "rule 27")
"""
# The REST API path to reuse a requirement
path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/tree/reuse?'
# The field-value pair/s for the query string of the URI
source_folder_field_value = 'sourceFolder=' + source_folder
target_folder_field_value = '&targetFolder=' + target_folder
rule_name_field_value = '&ruleName=' + rule_name
# The query string to be added to the URI
query_string = source_folder_field_value + target_folder_field_value + rule_name_field_value
# Send a POST request to reuse Requirements
# Return the result of the POST request
try:
return requests.post(host_url + path_uri + query_string, auth=HTTPBasicAuth(username, password))
except requests.exceptions.RequestException as e:
print e |