DATA CENTER AND SERVER | CLOUD

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

Contents


Create coverage view


The following script will trigger the creation of a coverage view. In this example, a coverage view for the GUI requirements will be created.

 Click here to expand...
Function
def create_coverage_view(host_url, username, password, project_id, filter_name, is_public, column_data, display_fields):
    """
    This method trigger the creation of a coverage view
    Template parameters:
    [project_id] the project the view to be created
    [filter_name] the name parameter of the view
    [is_public] the boolean parameter for the visibility of the view
    [column_data] an parameter of objects composed of column data
	[display_fields] the display fields for the view
    """

    # The REST API path to trigger the creation of a coverage view
    path_uri = '/rest/com.easesolutions.jira.plugins.coverage/1.0/filter/saveFilter'

	# The request body
    json_data = {'projectId': project_id,
                 'name': filter_name,
				 'isPublic': is_public,
				 'columnFilterJsonObject': column_data,
				 'addedFieldsJsonArray': display_fields}

    # Send a POST request to trigger the creation of a coverage view
    # Return the result of 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
    project_id = "10000"
    filter_name = "GUI Coverage"
    is_public = "true"

    columns = '{"label":"Level 1","jiraJql":"","jiraFilterId":"","linkTypes":[{"id":"-1","directions":{"in":true,"out":true}}],"currentIssueTypes":["-1"],"projects":["10000,PA,Project A","10002,PB,Project B"],"fromLevel":-1}, ' \
	'{"label":"Level 2","jiraJql":"","jiraFilterId":"10004","linkTypes":[{"id":"-1","directions":{"in":true,"out":true}}],"currentIssueTypes":[],"projects":["10000,PA,Project A"],"fromLevel":0}, ' \
	'{"label":"Level 3","jiraJql":"assignee IS NOT EMPTY","jiraFilterId":"","linkTypes":[{"id":"10001","directions":{"in":false,"out":true}}],"currentIssueTypes":[],"projects":["10000,PA,Project A"],"fromLevel":1}'
    column_data = '{"columns":[' + columns + '],"projectId":' + project_id + ',"fields":[],"folderIssueKeys":[],"filterId":0,"folderId":0,"folderName":"","fromColumn":0,"isFiltered":false}'
	
    display_fields = '["issuetype","issuekey","status","priority","summary","assignee","reporter"]'

    # Store the result of the POST request to [response]
    response = create_coverage_view(HOST_URL, USERNAME, PASSWORD, project_id, filter_name, is_public, column_data, display_fields)

    # Check response if coverage view is created
    if response.status_code == 201:
        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 (Success)
{"id":"1","name":"GUI Coverage"}
Output (Error)

403 Your license is invalid or has expired

403/401 Incompatible Jira Version

400 No permission to create public/private views in Coverage View

400 Name is invalid

400 Json data is invalid

400 Filter with name ''{0}'' already exists.

400 Project is invalid or hasn't been assigned to the Coverage View plugin

  • No labels