How to use the jira.utils.json_loads 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
if str(customfield).isdigit():
            customfield = "customfield_%s" % customfield
        params = {
            # '_mode':'view',
            # 'validate':True,
            # '_search':False,
            # 'rows':100,
            # 'page':1,
            # 'sidx':'DEFAULT',
            # 'sord':'asc'
            '_issueId': issueid,
            '_fieldId': customfield,
            '_confSchemeId': schemeid}
        r = self._session.get(
            url, headers=self._options['headers'], params=params)
        return json_loads(r)
github pycontribs / jira / jira / client.py View on Github external
ids = []
            for p in project_ids.split(','):
                ids.append(self.project(p).id)
            project_ids = ','.join(ids)

        payload['name'] = name
        if isinstance(project_ids, string_types):
            project_ids = project_ids.split(',')
        payload['projectIds'] = project_ids
        payload['preset'] = preset
        url = self._get_url(
            'rapidview/create/presets', base=self.AGILE_BASE_URL)
        r = self._session.post(
            url, data=json.dumps(payload))

        raw_issue_json = json_loads(r)
        return Board(self._options, self._session, raw=raw_issue_json)
github pycontribs / jira / jira / resources.py View on Github external
def _load(self, url, headers=CaseInsensitiveDict(), params=None, path=None):
        """ Load a resource.

        :type url: str
        :type headers: CaseInsensitiveDict
        :type params: Optional[Dict[str,str]]
        :type path: Optional[str]

        """
        r = self._session.get(url, headers=headers, params=params)
        try:
            j = json_loads(r)
        except ValueError as e:
            logging.error("%s:\n%s" % (e, r.text))
            raise e
        if path:
            j = j[path]
        self._parse_raw(j)
github pycontribs / jira / jira / client.py View on Github external
url,
                files={
                    'file': (fname, attachment, 'application/octet-stream')},
                headers=CaseInsensitiveDict({'content-type': None, 'X-Atlassian-Token': 'nocheck'}))
        else:
            method = 'MultipartEncoder'

            def file_stream():
                return MultipartEncoder(
                    fields={
                        'file': (fname, attachment, 'application/octet-stream')})
            m = file_stream()
            r = self._session.post(
                url, data=m, headers=CaseInsensitiveDict({'content-type': m.content_type, 'X-Atlassian-Token': 'nocheck'}), retry_data=file_stream)

        js = json_loads(r)
        if not js or not isinstance(js, collections.Iterable):
            raise JIRAError("Unable to parse JSON: %s" % js)
        attachment = Attachment(self._options, self._session, js[0])
        if attachment.size == 0:
            raise JIRAError("Added empty attachment via %s method?!: r: %s\nattachment: %s" % (method, r, attachment))
        return attachment
github pycontribs / jira / jira / client.py View on Github external
def applicationlinks(self, cached=True):
        """List of application links.

        :return: json
        """
        # if cached, return the last result
        if cached and hasattr(self, '_applicationlinks'):
            return self._applicationlinks

        # url = self._options['server'] + '/rest/applinks/latest/applicationlink'
        url = self._options['server'] + \
            '/rest/applinks/latest/listApplicationlinks'

        r = self._session.get(url)

        o = json_loads(r)
        if 'list' in o:
            self._applicationlinks = o['list']
        else:
            self._applicationlinks = []
        return self._applicationlinks
github opennode / waldur-mastermind / src / waldur_jira / backend.py View on Github external
def get_project_templates(self):
        url = (
            self.manager._options['server'] + '/rest/project-templates/latest/templates'
        )

        response = self.manager._session.get(url)
        json_data = json_loads(response)
        return _get_template_list(json_data)
github pycontribs / jira / jira / client.py View on Github external
# check if the link comes from one of the configured application links
        for x in applicationlinks:
            if x['application']['displayUrl'] == self._options['server']:
                data['globalId'] = "appId=%s&issueId=%s" % (
                    x['application']['id'], destination.raw['id'])
                data['application'] = {
                    'name': x['application']['name'], 'type': "com.atlassian.jira"}
                break

        url = self._get_url('issue/' + str(issue) + '/remotelink')
        r = self._session.post(
            url, data=json.dumps(data))

        remote_link = RemoteLink(
            self._options, self._session, raw=json_loads(r))
        return remote_link
github pycontribs / jira / jira / client.py View on Github external
'projectTemplateModuleKey': template_key,
                   'lead': assignee,
                   # 'assigneeType': '2',
                   }

        if self._version[0] > 6:
            # JIRA versions before 7 will throw an error if we specify type parameter
            payload['type'] = type

        headers = CaseInsensitiveDict(
            {'Content-Type': 'application/x-www-form-urlencoded'})

        r = self._session.post(url, data=payload, headers=headers)

        if r.status_code == 200:
            r_json = json_loads(r)
            return r_json

        f = tempfile.NamedTemporaryFile(
            suffix='.html', prefix='python-jira-error-create-project-', delete=False)
        f.write(r.text)

        if self.logging:
            logging.error(
                "Unexpected result while running create project. Server response saved in %s for further investigation [HTTP response=%s]." % (
                    f.name, r.status_code))
        return False
github pycontribs / jira / jira / resources.py View on Github external
def get_error_list(r):
    error_list = []
    if r.status_code >= 400:
        if r.status_code == 403 and "x-authentication-denied-reason" in r.headers:
            error_list = [r.headers["x-authentication-denied-reason"]]
        elif r.text:
            try:
                response = json_loads(r)
                if "message" in response:
                    # JIRA 5.1 errors
                    error_list = [response["message"]]
                elif "errorMessages" in response and len(response["errorMessages"]) > 0:
                    # JIRA 5.0.x error messages sometimes come wrapped in this array
                    # Sometimes this is present but empty
                    errorMessages = response["errorMessages"]
                    if isinstance(errorMessages, (list, tuple)):
                        error_list = errorMessages
                    else:
                        error_list = [errorMessages]
                elif "errors" in response and len(response["errors"]) > 0:
                    # JIRA 6.x error messages are found in this array.
                    error_list = response["errors"].values()
                else:
                    error_list = [r.text]