How to use the jira.resources.GreenHopperResource 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 / jira / client.py View on Github external
:param maxResults: the maximum number of sprints to return
        :param state: Filters results to sprints in specified states. Valid values: future, active, closed.
            You can define multiple states separated by commas

        :rtype: dict
        :return: (content depends on API version, but always contains id, name, state, startDate and endDate)
            When old GreenHopper private API is used, paging is not enabled,
            and `startAt`, `maxResults` and `state` parameters are ignored.
        """
        params = {}
        if state:
            if isinstance(state, string_types):
                state = state.split(",")
            params['state'] = state

        if self._options['agile_rest_path'] == GreenHopperResource.GREENHOPPER_REST_PATH:
            r_json = self._get_json('sprintquery/%s?includeHistoricSprints=true&includeFutureSprints=true' % board_id,
                                    base=self.AGILE_BASE_URL)

            if params:
                warnings.warn('Old private GreenHopper API is used, parameters %s will be ignored.' % params, Warning)

            if extended:
                sprints = [Sprint(self._options, self._session, self.sprint_info(None, raw_sprints_json['id']))
                           for raw_sprints_json in r_json['sprints']]
            else:
                sprints = [Sprint(self._options, self._session, raw_sprints_json)
                           for raw_sprints_json in r_json['sprints']]

            return ResultList(sprints, 0, len(sprints), len(sprints), True)
        else:
            return self._fetch_pages(Sprint, 'values', 'board/%s/sprint' % board_id, startAt, maxResults, params,
github pycontribs / jira / jira / client.py View on Github external
"""User interface to JIRA.

    Clients interact with JIRA by constructing an instance of this object and calling its methods. For addressable
    resources in JIRA -- those with "self" links -- an appropriate subclass of :py:class:`Resource` will be returned
    with customized ``update()`` and ``delete()`` methods, along with attribute access to fields. This means that calls
    of the form ``issue.fields.summary`` will be resolved into the proper lookups to return the JSON value at that
    mapping. Methods that do not return resources will return a dict constructed from the JSON response or a scalar
    value; see each method's documentation for details on what that method returns.
    """

    DEFAULT_OPTIONS = {
        "server": "http://localhost:2990/jira",
        "context_path": "/",
        "rest_path": "api",
        "rest_api_version": "2",
        "agile_rest_path": GreenHopperResource.GREENHOPPER_REST_PATH,
        "agile_rest_api_version": "1.0",
        "verify": True,
        "resilient": True,
        "async": False,
        "client_cert": None,
        "check_update": False,
        "headers": {
            'Cache-Control': 'no-cache',
            # 'Accept': 'application/json;charset=UTF-8',  # default for REST
            'Content-Type': 'application/json',  # ;charset=UTF-8',
            # 'Accept': 'application/json',  # default for REST
            # 'Pragma': 'no-cache',
            # 'Expires': 'Thu, 01 Jan 1970 00:00:00 GMT'
            'X-Atlassian-Token': 'no-check'}}

    checked_version = False
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        GreenHopperResource.__init__(self, "sprint/{0}", options, session, raw)

    def find(self, id, params=None):
        if (
            self._options["agile_rest_path"]
            != GreenHopperResource.GREENHOPPER_REST_PATH
        ):
            Resource.find(self, id, params)
        else:
            # Old, private GreenHopper API had non-standard way of loading Sprint
            url = self._get_url("sprint/%s/edit/model" % id)
            self._load(url, params=params, path="sprint")


class Board(GreenHopperResource):
    """A GreenHopper board."""

    def __init__(self, options, session, raw=None):
        path = (
            "rapidview/{0}"
            if options["agile_rest_path"] == self.GREENHOPPER_REST_PATH
            else "board/{id}"
        )
        GreenHopperResource.__init__(self, path, options, session, raw)

    def delete(self, params=None):
        if (
            self._options["agile_rest_path"]
            != GreenHopperResource.GREENHOPPER_REST_PATH
        ):
            raise NotImplementedError(
github pycontribs / jira / jira / resources.py View on Github external
""" 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:
            self._parse_raw(raw)
            # Old GreenHopper API did not contain self - create it for backward compatibility.
            if not self.self:
                self.self = self._get_url(path.format(raw["id"]))


class Sprint(GreenHopperResource):
    """A GreenHopper sprint."""

    def __init__(self, options, session, raw=None):
        GreenHopperResource.__init__(self, "sprint/{0}", options, session, raw)

    def find(self, id, params=None):
        if (
            self._options["agile_rest_path"]
            != GreenHopperResource.GREENHOPPER_REST_PATH
        ):
            Resource.find(self, id, params)
        else:
            # Old, private GreenHopper API had non-standard way of loading Sprint
            url = self._get_url("sprint/%s/edit/model" % id)
            self._load(url, params=params, path="sprint")
github pycontribs / jira / jira / resources.py View on Github external
def __init__(self, options, session, raw=None):
        path = (
            "rapidview/{0}"
            if options["agile_rest_path"] == self.GREENHOPPER_REST_PATH
            else "board/{id}"
        )
        GreenHopperResource.__init__(self, path, options, session, raw)
github pycontribs / jira / jira / client.py View on Github external
"""Rank an issue before another using the default Ranking field, the one named 'Rank'.

        :param issue: issue key of the issue to be ranked before the second one.
        :param next_issue: issue key of the second issue.
        """
        if not self._rank:
            for field in self.fields():
                if field['name'] == 'Rank':
                    if field['schema']['custom'] == "com.pyxis.greenhopper.jira:gh-lexo-rank":
                        self._rank = field['schema']['customId']
                        break
                    elif field['schema']['custom'] == "com.pyxis.greenhopper.jira:gh-global-rank":
                        # Obsolete since JIRA v6.3.13.1
                        self._rank = field['schema']['customId']

        if self._options['agile_rest_path'] == GreenHopperResource.AGILE_BASE_REST_PATH:
            url = self._get_url('issue/rank', base=self.AGILE_BASE_URL)
            payload = {'issues': [issue], 'rankBeforeIssue': next_issue, 'rankCustomFieldId': self._rank}
            try:
                return self._session.put(url, data=json.dumps(payload))
            except JIRAError as e:
                if e.status_code == 404:
                    warnings.warn('Status code 404 may mean, that too old JIRA Agile version is installed.'
                                  ' At least version 6.7.10 is required.')
                raise
        elif self._options['agile_rest_path'] == GreenHopperResource.GREENHOPPER_REST_PATH:
            # {"issueKeys":["ANERDS-102"],"rankBeforeKey":"ANERDS-94","rankAfterKey":"ANERDS-7","customFieldId":11431}
            data = {
                "issueKeys": [issue], "rankBeforeKey": next_issue, "customFieldId": self._rank}
            url = self._get_url('rank', base=self.AGILE_BASE_URL)
            return self._session.put(url, data=json.dumps(data))
        else:
github pycontribs / jira / jira / resources.py View on Github external
def delete(self, params=None):
        if (
            self._options["agile_rest_path"]
            != GreenHopperResource.GREENHOPPER_REST_PATH
        ):
            raise NotImplementedError(
                "JIRA Agile Public API does not support Board removal"
            )

        Resource.delete(self, params)