Exemplo n.º 1
0
def get_project_versions(jira_host, project_key):
    """
    Returns all versions of the specified project.

    jira_host -- JIRA host to contact.
    project_key -- project which versions should be returned.
    """
    response = https_helper.get(jira_host, project_versions_path % project_key)
    if response.status != 200:
        raise ValueError('Project does not exist: project=%s' % (project_key))
    return json.loads(response.read())
Exemplo n.º 2
0
def get_project_versions(jira_host, project_key):
    """
    Returns all versions of the specified project.

    jira_host -- JIRA host to contact.
    project_key -- project which versions should be returned.
    """
    response = https_helper.get(jira_host, project_versions_path % project_key)
    if response.status != 200:
        raise ValueError('Version does not exist: project=%s, version=%s' % (project_key, version_name))
    return json.loads(response.read())
Exemplo n.º 3
0
def get_project(jira_host, project_key):
    """
    Returns project based on the key.

    jira_host -- JIRA host to contact.
    project_key -- project key to identify the project.
    """
    response = https_helper.get(jira_host, project_path % project_key)
    if response.status != 200:
        raise ValueError('Failed to get project %s: %s %s' % (project_key, response.status, response.reason))
    return json.loads(response.read())
Exemplo n.º 4
0
def get_project_components(jira_host, project_key):
    """
    Returns all components of the specified project.

    jira_host -- JIRA host to contact.
    project_key -- project which components should be returned.
    """
    response = https_helper.get(jira_host, project_components_path % project_key)
    if response.status != 200:
        raise ValueError('Project does not exist: project={0}'.format(project_key))
    return json.loads(response.read())
Exemplo n.º 5
0
def get_issues(jira_host, query):
    """
    Returns issues based on the provided search query.

    jira_host -- JIRA host to contact
    query -- search query to filter the issues
    """
    response = https_helper.get(jira_host, issues_path % query)
    if response.status != 200:
        logging.debug('Did not find any issues with the query: %s', query)
        return []
    return json.loads(response.read())['issues']
Exemplo n.º 6
0
def get_issues(jira_host, query):
    """
    Returns issues based on the provided search query.

    jira_host -- JIRA host to contact
    query -- search query to filter the issues
    """
    response = https_helper.get(jira_host, issues_path % query)
    if response.status != 200:
        logging.debug('Did not find any issues with the query: %s', query)
        return []
    return json.loads(response.read())['issues']
Exemplo n.º 7
0
def get_project(jira_host, project_key):
    """
    Returns project based on the key.

    jira_host -- JIRA host to contact.
    project_key -- project key to identify the project.
    """
    response = https_helper.get(jira_host, project_path % project_key)
    if response.status != 200:
        raise ValueError('Failed to get project %s: %s %s' %
                         (project_key, response.status, response.reason))
    return json.loads(response.read())
Exemplo n.º 8
0
def get_issue_type_by_name(jira_host, type_name):
    """
    Returns JIRA issue type based on the name

    jira_host -- JIRA host to contact.
    type_name -- type name to filter.
    """
    response = https_helper.get(jira_host, issue_types_path)
    if response.status != 200:
        raise ValueError('Failed to get issue types: status={0}, reason={1}'.format(response.status, response.reason))
    matches = filter(lambda x: x['name'] == type_name, json.loads(response.read()))
    if not matches:
        raise ValueError('Requested type does not exist: {0}'.format(type_name))
    return matches.pop()
Exemplo n.º 9
0
def get_transitions(jira_host, username, password, issue_id):
    """
    Returns transitions of the issue.

    jira_host -- JIRA host to contact
    username -- JIRA username with administrative permissions.
    password -- password of the username.
    issue_id -- id of the issue which transitions should be returned.
    """
    headers = get_auth_header(username, password)
    response = https_helper.get(jira_host, issue_transitions_path % issue_id, None, headers)
    if response.status != 200:
        logging.debug('Did not find any transitions for issue: %s', issue_id)
        return []
    return json.loads(response.read())['transitions']
Exemplo n.º 10
0
def get_transitions(jira_host, username, password, issue_id):
    """
    Returns transitions of the issue.

    jira_host -- JIRA host to contact
    username -- JIRA username with administrative permissions.
    password -- password of the username.
    issue_id -- id of the issue which transitions should be returned.
    """
    headers = get_auth_header(username, password)
    response = https_helper.get(jira_host, issue_transitions_path % issue_id,
                                None, headers)
    if response.status != 200:
        logging.debug('Did not find any transitions for issue: %s', issue_id)
        return []
    return json.loads(response.read())['transitions']
Exemplo n.º 11
0
def get_issue_type_by_name(jira_host, type_name):
    """
    Returns JIRA issue type based on the name

    jira_host -- JIRA host to contact.
    type_name -- type name to filter.
    """
    response = https_helper.get(jira_host, issue_types_path)
    if response.status != 200:
        raise ValueError(
            'Failed to get issue types: status={0}, reason={1}'.format(
                response.status, response.reason))
    matches = filter(lambda x: x['name'] == type_name,
                     json.loads(response.read()))
    if not matches:
        raise ValueError(
            'Requested type does not exist: {0}'.format(type_name))
    return matches.pop()