def create_scheduled_job(host_url, username, password, project_key, job_name, folder_id, jql_or_filter, interval):
"""
This method allows the creation of jobs for the scheduled adding of existing issues
Query parameters:
[project_key] the project key
Query parameters:
[job_name] the name of the scheduled job
[folder_id] the folder id of the tree folder
[filter] the JQL or JIRA filter
[interval] the time interval in minutes
"""
# The REST API path to allow the creation of jobs for the scheduled adding of existing issues
path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/tree/' + project_key + '/createscheduledjob?'
# The field-value pair/s for the query string of the URI
job_name_field_value = 'name=' + job_name
folder_id_field_value = '&folderId=' + folder_id
filter_field_value = '&filter=' + jql_or_filter
interval_field_value = '&interval=' + interval
# The query string to be added to the URI
query_string = job_name_field_value + folder_id_field_value + filter_field_value + interval_field_value
# Send a POST request to allow the creation of jobs for the scheduled adding of existing issues
# 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 |