How to use the jira.resources.Resource function in jira

To help you get started, we’ve selected a few jira examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pycontribs / jira / tests / tests.py View on Github external
def test_cls_for_resource(self):
        self.assertEqual(cls_for_resource('https://jira.atlassian.com/rest/\
                api/latest/issue/JRA-1330'), Issue)
        self.assertEqual(cls_for_resource('http://localhost:2990/jira/rest/\
                api/latest/project/BULK'), Project)
        self.assertEqual(cls_for_resource('http://imaginary-jira.com/rest/\
                api/latest/project/IMG/role/10002'), Role)
        self.assertEqual(cls_for_resource('http://customized-jira.com/rest/\
                plugin-resource/4.5/json/getMyObject'), Resource)
github pycontribs / jira / jira / resources.py View on Github external
"""Update this project version from the server. It is prior used to archive versions."""
        data = {}
        for field in args:
            data[field] = args[field]

        super(Version, self).update(**data)

    def __eq__(self, other):
        """Comparison."""
        return self.id == other.id and self.name == other.name


# GreenHopper


class GreenHopperResource(Resource):
    """A generic GreenHopper resource."""

    AGILE_BASE_URL = "{server}/rest/{agile_rest_path}/{agile_rest_api_version}/{path}"

    GREENHOPPER_REST_PATH = "greenhopper"
    """ Old, private API. Deprecated and will be removed from JIRA on the 1st February 2016. """
    AGILE_EXPERIMENTAL_REST_PATH = "greenhopper/experimental-api"
    """ Experimental API available in JIRA Agile 6.7.3 - 6.7.6, basically the same as Public API """
    AGILE_BASE_REST_PATH = "agile"
    """ Public API introduced in JIRA Agile 6.7.7. """

    def __init__(self, path, options, session, raw):
        self.self = None

        Resource.__init__(self, path, options, session, self.AGILE_BASE_URL)
        if raw:
github pycontribs / jira / jira / resources.py View on Github external
if moveIssuesTo is not None:
            params["moveIssuesTo"] = moveIssuesTo

        super(Component, self).delete(params)


class CustomFieldOption(Resource):
    """An existing option for a custom issue field."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "customFieldOption/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Dashboard(Resource):
    """A JIRA dashboard."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "dashboard/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Filter(Resource):
    """An issue navigator filter."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "filter/{0}", options, session)
        if raw:
            self._parse_raw(raw)
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        Resource.__init__(self, "dashboard/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Filter(Resource):
    """An issue navigator filter."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "filter/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Issue(Resource):
    """A JIRA issue."""

    class _IssueFields(object):
        def __init__(self):
            self.attachment = None
            """ :type : list[Attachment] """
            self.description = None
            """ :type : str """
            self.project = None
            """ :type : Project """
            self.comment = None
            """ :type : list[Comment] """
            self.issuelinks = None
            """ :type : list[IssueLink] """
            self.worklog = None
            """ :type : list[Worklog] """
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        Resource.__init__(self, "group?groupname={0}", options, session)
        if raw:
            self._parse_raw(raw)

    def __hash__(self):
        """Hash calculation."""
        return hash(str(self.name))

    def __eq__(self, other):
        """Equality by name."""
        return str(self.name) == str(other.name)


class Version(Resource):
    """A version of a project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "version/{0}", options, session)
        if raw:
            self._parse_raw(raw)

    def delete(self, moveFixIssuesTo=None, moveAffectedIssuesTo=None):
        """Delete this project version from the server.

        If neither of the arguments are specified, the version is
            removed from all issues it is attached to.

        :param moveFixIssuesTo: in issues for which this version is a fix
            version, add this argument version to the fix version list
        :param moveAffectedIssuesTo: in issues for which this version is an
github pycontribs / jira / jira / resources.py View on Github external
:param users: a user or users to add to the role
        :type users: string, list or tuple
        :param groups: a group or groups to add to the role
        :type groups: string, list or tuple
        """

        if users is not None and isinstance(users, str):
            users = (users,)
        if groups is not None and isinstance(groups, str):
            groups = (groups,)

        data = {"user": users}
        self._session.post(self.self, data=json.dumps(data))


class Resolution(Resource):
    """A resolution for an issue."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "resolution/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class SecurityLevel(Resource):
    """A security level for an issue or project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "securitylevel/{0}", options, session)
        if raw:
            self._parse_raw(raw)
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        Resource.__init__(self, "issuetype/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Priority(Resource):
    """Priority that can be set on an issue."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "priority/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Project(Resource):
    """A JIRA project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "project/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Role(Resource):
    """A role inside a project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "project/{0}/role/{1}", options, session)
        if raw:
            self._parse_raw(raw)
github pycontribs / jira / jira / resources.py View on Github external
groups = (groups,)

        data = {"user": users}
        self._session.post(self.self, data=json.dumps(data))


class Resolution(Resource):
    """A resolution for an issue."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "resolution/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class SecurityLevel(Resource):
    """A security level for an issue or project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "securitylevel/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Status(Resource):
    """Status for an issue."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "status/{0}", options, session)
        if raw:
            self._parse_raw(raw)
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        Resource.__init__(self, "group?groupname={0}", options, session)
        if raw:
            self._parse_raw(raw)
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        Resource.__init__(self, "priority/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Project(Resource):
    """A JIRA project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "project/{0}", options, session)
        if raw:
            self._parse_raw(raw)


class Role(Resource):
    """A role inside a project."""

    def __init__(self, options, session, raw=None):
        Resource.__init__(self, "project/{0}/role/{1}", options, session)
        if raw:
            self._parse_raw(raw)

    def update(self, users=None, groups=None):
        """Add the specified users or groups to this project role. One of ``users`` or ``groups`` must be specified.

        :param users: a user or users to add to the role
        :type users: string, list or tuple
        :param groups: a group or groups to add to the role
        :type groups: string, list or tuple
        """