![]() allowing read-only access for some API tokens and read-write for others). Some APIs also let you set an expiry date for tokens or configure permissions on a per-token basis (e.g. The Jira UI also displays the last time each token was used. That way, if that environment is compromised you can revoke access for the compromised token without affecting any other environments. Tokens can be independently revoked so create one for each environment where you’ll be accessing the API. You’ll only have access to the token string once, when creating it. If your account is using Two-factor authentication you’ll need to generate a token because your script doesn’t have access to the second factor. This means that if a server using one of your tokens is compromised you can revoke that token without affecting other servers.Īfter logging in with your username + password (+ 2FA if enabled) Jira allows you to create unique tokens to use in place of your password when authenticating via the API. It may be tempting to just use your normal user name and password in a script but I highly recommend, even if you’re just exploring the API, that you take a few seconds to generate a token instead.Ī token acts as a temporary password that you can revoke independently of all your other tokens. At the end, we’ll tie this all together by implementing a scenario. The Jira API is very rich but these basic building blocks open up a lot of opportunities for automation. We will also cover some basic write operations through the API: creating issues, transitioning issues, linking issues, and adding comments. From there you can clean, filter, chart, or store it. This article is going to cover the basics of interacting with the Jira API to retrieve data using Python and load it into a Pandas DataFrame. They separate access and control of your data from the UI that’s built around it. Jira API with Python and Pandas IntroductionĪPIs are great. search_issues ( "assignee=admin" )) # Find the top three projects containing issues reported by admin top_three = Counter (). application_properties () # Find all issues reported by the admin # Note: we cast() for mypy's benefit, as search_issues can also return the raw json ! # This is if the following argument is used: `json_result=True` issues = cast ( ResultList, jira. ![]() myself () # Get the mutable application properties for this server (requires # jira-system-administrators permission) props = jira. Server): the PAT token # auth=("admin", "admin"), # a username/password tuple for cookie auth ) # Who has authenticated myself = jira. """ from collections import Counter from typing import cast from jira import JIRA from jira.client import ResultList from jira.resources import Issue # Some Authentication Methods jira = JIRA ( basic_auth = ( "admin", "admin" ), # a username/password tuple # basic_auth=("email", "API token"), # Jira Cloud: a username/token tuple # token_auth="API token", # Self-Hosted Jira (e.g. id, issue2 )Īnother example with methods to authenticate with your Jira: issue ( "XX-23" ) # could also be another instance jira. delete () # Linking a remote jira issue (needs applinks to be configured to work) issue = jira. update ( fields = ) # Send the issue away for good. update ( notify = False, description = "Quiet summary update." ) # You can update the entire labels field like this issue. update ( summary = "I'm different!", description = "Changed the summary to be different." ) # Change the issue without sending updates issue. add_comment ( issue, "Comment text" ) # Change the issue's summary and description. atl_comments = # Add a comment to the issue. issue ( "JRA-1330" ) # Find all comments made by Atlassians on this issue. key for project in projects ) # Get an issue. projects () # Sort available project keys, then return the second, third, and fourth keys. jira = JIRA ( server = "" ) # Get all projects viewable by anonymous users. import re from jira import JIRA # By default, the client will connect to a Jira instance started from the Atlassian Plugin SDK # (see for details). # This script shows how to use the client in anonymous mode # against.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |