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

Version 1 Next »

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_key, name, is_public, columns):
    """
    This method trigger the creation of a coverage view
    Template parameters:
    [project_key] the project the view to be created
    Query parameters:
    [name] the name parameter of the view
    [is_public] the boolean parameter for the visibility of the view
    [columns] an array parameter of objects compose of name,
    type ("filter", "jql", or "issue types"), filter, and link types
    """

    # The REST API path to trigger the creation of a coverage view
    path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/coverage/' + project_key + '/createcoverageview?'

    # The field-value pair/s for the query string of the URI
    name_field_value = 'name=' + name
    is_public_field_value = '&isPublic=' + is_public
    columns_field_value = '&columns=' + columns

    # The query string to be added to the URI
    query_string = name_field_value + is_public_field_value + columns_field_value

    # 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 + query_string, auth=HTTPBasicAuth(username, password))
    except requests.exceptions.RequestException as e:
        print e
Main
# ['SC'] project key parameter where view will be created
# ['GUI Coverage'] the name parameter of the coverage
# ['true'] boolean parameter of the visibility of the view
# ['column'] the column parameter of the view that will be created
# an array of objects compose of name, type ("filter", "jql", or "issue types"), filter, and link types
column = '[{"name":"Column 1","type":"jql","filter":"issuetype in (bug, improvement)","linkTypes":[]},' \
         '{"name":"Column 2","type":"jql","filter":"issuetype = change","linkTypes":["relates to"]}]'

# Store the result of the POST request to [response]
response = create_coverage_view(HOST_URL, USERNAME, PASSWORD, 'SC', 'GUI Coverage', 'true', column)

# 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: 
View GUI Coverage has been successfully created
  • No labels