Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel
titleContents

Table of Contents
maxLevel2
minLevel2



Panel
Trigger saving a

Create suspect configuration


The following script will update the projects create a suspect configuration on a give project.

In this example, the script will configure the create a suspect for project Sand Castle 'SC'. Refer to the parameters in Main for the settings that will be set in the suspect.

Expand
Function
Code Block
languagepy
themeConfluence
linenumberstrue
def configurecreate_suspect(host_url, username, password, project_key, fieldsconfig_listname, linknotify_type_idassignee, scope, notify_assigneereporter,
                      notify_reporter, notify_project_lead, notify_user_listnotify_project_lead, user_keys, link_type_ids, use_all_link_types, field, stream, scope):
    """
    This method is used allows to create suspect configuration on a project
    """

    # The REST API path to configureallow the Requirementscreation Suspectof Configurationsuspect configuration for a project
Query parameters:   path_uri  [project_key] the project key= '/rest/com.easesolutions.jira.plugins.requirements/1.0/{}/suspectconfiguration'.format(project_key)

    # The request body
    json_data Query parameters= {'configName': config_name, 'notifyAssignee': notify_assignee,  [fields_list] fields that trigger a suspect
   'notifyReporter': notify_reporter,
                 'notifyProjectLead': notify_project_lead, 'userKeys': [user_keys], 'linkTypeIds': [link_type_idids] link types that should be affected if a field change
    [scope] define if a change in an issue will trigger suspect. Accepts 'both' or 'downstream'
    [notify_assignee] notify assignee if set to true
    [notify_reporter] notify reporter if set to true
    [notify_project_lead] notify project lead if set to true
    [notify_user_list] the jira,
                 'useAllLinktypes': use_all_link_types, 'suspectConfigItems': [{'field': field, 'stream': stream}],
                 'scope': scope}

    # Send and return the POST request
    try:
        return requests.post(host_url + path_uri, json=json_data, auth=HTTPBasicAuth(username, password))
    except requests.exceptions.RequestException as e:
        print e
Main
Code Block
languagepy
themeConfluence
linenumberstrue
# ['SC'] the project key parameter where the suspect will be configured
# ['SC_Suspect'] suspect configuration name
# [False] true to notify assignee, otherwise false
# [False] true to notify reporter, otherwise false
# [False] true to notify project lead, otherwise false
# ['admin'] List of users to be notified if suspect is triggered
 """

    # The REST API path to configure the Requirements Suspect Configuration
    path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/' + project_key + '/suspectconfiguration?'

    # The query string to be added to the URI
    query_string = ""

    # The field-value pair/s for the query string of the URI
    if fields_list:
        query_string += 'fieldList=' + fields_list
    if link_type_id:
 # ['10002'] Define the link types that should be affected
# [False] true if use all link types, otherwise false
# ['assignee']Input the fieldId that trigger a suspect. Add to trigger on any field change.
# ['up'] Define if a change in an issue will trigger suspect to downstream relationships only or in both directions.
# Note: "stream" and "scope" must always have the same value.

response = create_suspect(HOST_URL, USERNAME, PASSWORD, 'SC', 'SC_Suspect', False, False, False, "admin",
                          "10002", False, "assignee", "up", "up")

if response.status_code == 200:
    print response.text
else:
    print 'Error code: ', response.status_code
    print response.text

Refer to Constant variable for information of the following constant variable: [HOST_URL, USERNAME, PASSWORD]

Output
Code Block
languagetext
themeConfluence
Suspect Configuration saved for SC





Panel

Update suspect configuration


The following script will udpate a suspect configuration on a give project.

In this example, the script will update a suspect for project Sand Castle 'SC'. Refer to the parameters in Main for the settings that will be set in the suspect.

Expand
Function
Code Block
languagepy
themeConfluence
linenumberstrue
def update_suspect(host_url, username, password, project_key, suspect_id, config_name, notify_assignee,
      if query_string:             query_string += '&linkTypeIds=' +notify_reporter, notify_project_lead, user_keys, link_type_idids, use_all_link_types,
                    elsefield, stream, scope):
    """
    This method allows  query_string += 'linkTypeIds=' + link_type_idto update suspect configuration on a project
    if"""
scope:
    # The REST API if query_string:
       path to allow update of suspect configuration for a project
    querypath_stringuri += '&scope=' + scope/rest/com.easesolutions.jira.plugins.requirements/1.0/{}/suspectconfiguration/{}'.\
        format(project_key, suspect_id)
else:
    # The request body
    queryjson_stringdata += 'scope=' + scope{'configName': config_name, 'notifyAssignee': notify_assignee, 'notifyReporter': notify_reporter,
                 if'notifyProjectLead': notify_assignee:project_lead, 'userKeys': [user_keys], 'linkTypeIds': [link_type_ids],
        if query_string:         'useAllLinktypes': use_all_link_types, 'suspectConfigItems': [{'field': field, 'stream': stream}],
               query_string += '&notifyAssignee=' + notify_assigneescope': scope}
    # Send and return the PUT request
 else:   try:
        return query_string += 'notifyAssignee=' + notify_assignee
    if notify_reporter:requests.put(host_url + path_uri, json=json_data, auth=HTTPBasicAuth(username, password))
    except requests.exceptions.RequestException as e:
         if query_string:
            query_string += '&notifyReporter=' + notify_reporter
        else:
            query_string += 'notifyReporter=' + notify_reporter
    if notify_project_lead:
        if query_string:
            query_string += '&notifyProjectLead=' + notify_project_lead
        else:
            query_string += 'notifyProjectLead=' + notify_project_lead
    if notify_user_list:print e
Main
Code Block
languagepy
themeConfluence
linenumberstrue
# ['SC'] the project key parameter where the suspect will be configured
# [17] The suspect configuration id to be updated
# ['SC_Suspect_Update'] suspect configuration name
# [True] true to notify assignee, otherwise false
# [False] true to notify reporter, otherwise false
# [False] true to notify project lead, otherwise false
# ['admin'] List of users to be notified if suspect is triggered
# ['10002'] Define the link types that should be affected
# [False] true if use all link types, otherwise false
# ['assignee']Input the fieldId that trigger a suspect. Add to trigger on any field change.
# ['up'] Define if a change in an issue will trigger suspect to downstream relationships only or in both directions.
# Note: "stream" and "scope" must always have the same value.

response = update_suspect(HOST_URL, USERNAME, PASSWORD, 'SC', 17, 'SC_Suspect_Update', True, False, False, "admin",
               if query_string:          "10002", False,  query_string += '&notifyUserList=' + notify_user_list
 "assignee", "up", "up")

if response.status_code == 200:
    print response.text
else:
    print 'Error code: ', response.status_code
     query_string += 'notifyUserList=' + notify_user_list

    # Send a PUT request to configure the Requirements Suspect Configurationprint response.text

Refer to Constant variable for information of the following constant variable: [HOST_URL, USERNAME, PASSWORD]

Output
Code Block
languagetext
themeConfluence
Suspect Configuration saved for SC





Panel

Get all suspect configuration of a project


The following script will get all suspect configuration on a give project.

In this example, the script will get all suspect for project Sand Castle 'SC'.

Expand
Function
Code Block
languagepy
themeConfluence
linenumberstrue
def get_suspect(host_url, username, password, project_key):
    """
    This method allows to get all suspect configuration on a project
    """

    # Return the result of the PUT The REST API path to get all suspect configuration of a project
    path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/{}/suspectconfigurations'.format(project_key)

    # Send and return the GET request
    try:
        return requests.putget(host_url + path_uri + query_string, auth=HTTPBasicAuth(username, password))
    except requests.exceptions.RequestException as e:
        print e
Main
Code Block
languagepy
themeConfluence
linenumberstrue
# ['SC'] the project key parameter where theall suspect configuration will be configured
# ['summary'] the field parameter for the fields list
# ['-1'] the id parameter to select all link types
# ['down'] The scope parameter of the configuration
# ['true'] boolean parameter for Assignee notification
# ['true'] boolean parameter for reporter notification
# ['true'] boolean parameter for project lead notification
# ['myUser'] users parameter for the users to be notified.
# Store the result of the POST request to [response]
response = configure_suspect(HOST_URL, USERNAME, PASSWORD, 'SC', 'summary', '-1', 'down', 'true',
                 fetched

response = get_suspect(HOST_URL, USERNAME, PASSWORD, 'SC')

if response.status_code == 200:
    parsed = json.loads(response.text)
    print json.dumps(parsed, indent=4, sort_keys=True)
else:
    print 'Error code: ', response.status_code
    print response.text

Refer to Constant variable for information of the following constant variable: [HOST_URL, USERNAME, PASSWORD]

Output
Code Block
languagetext
themeConfluence
[
    {
        "configId": 17, 
        "configName": "SC_Suspect_Update", 
        "linkTypeIds": [
            "10002"
        ], 
        "notifyAssignee": true, 
        "notifyProjectLead": false, 
        "notifyReporter": false, 
        "projectId": 10000, 
        "scope": "up", 
        "suspectConfigItems": [
            {
                "field": "assignee", 
                "stream": "up"
            }
        ], 
        "useAllLinktypes": false, 
        "userKeys": [
            "admin"
        ]
    }, 
    {
        "configId": 18, 
        "configName": "SC_Suspect", 
        "linkTypeIds": [
            "10002"
        ], 
        "notifyAssignee": false, 
        "notifyProjectLead": false, 
        "notifyReporter": false, 
        "projectId": 10000, 
        "scope": "up", 
        "suspectConfigItems": [
            {
                "field": "assignee", 
                "stream": "up"
            }
        ], 
        "useAllLinktypes": false, 
        "userKeys": [
            "admin"
        ]
    }
]





Panel

Delete suspect configuration


The following script will delete a suspect configuration on a give project.

In this example, the script will delete the suspect configuration with id 17 on project Sand Castle 'SC'.

Expand
Function
Code Block
languagepy
themeConfluence
linenumberstrue
def del_suspect(host_url, username, password, project_key, suspect_id):
    """
    This method allows to delete suspect configuration on a project
    """

    # The REST API path to delete a suspect configuration
    path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/{}/suspectconfiguration/{}'.\
        format(project_key, suspect_id)

    # Send and return the DELETE request
    try:
        return requests.delete(host_url +  'true', 'true', 'myUser')

# Check response if Suspect is configuredpath_uri, auth=HTTPBasicAuth(username, password))
    except requests.exceptions.RequestException as e:
        print e
Main
Code Block
languagepy
themeConfluence
linenumberstrue
# ['SC'] the project key parameter where the suspect configuration will be deleted
# [17] The suspect configuration id to be deleted

response = del_suspect(HOST_URL, USERNAME, PASSWORD, 'SC', 17)

if response.status_code == 200:
    print response.text
else:
    print 'Error code: ', response.status_code
    print response.text

Refer to Constant variable for information of the following constant variable: [HOST_URL, USERNAME, PASSWORD]

Output
Code Block
languagetext
themeConfluence
Suspect Configuration saveddeleted for SC