Python library for interacting with JIRA via REST APIs.
—
Administrative functions, server information, utility operations, and system maintenance tasks. These operations typically require administrative permissions in JIRA.
Operations for retrieving server and system information.
def server_info(self) -> dict:
"""
Get JIRA server information including version and build details.
Returns:
Dictionary containing server information
"""
def myself(self) -> User:
"""
Get information about the current authenticated user.
Returns:
User object representing the current user
"""
def client_info(self) -> dict:
"""
Get client connection information.
Returns:
Dictionary containing client connection details
"""
def current_user(self) -> User:
"""
Get current user information (alias for myself).
Returns:
User object representing the current user
"""Usage examples:
# Get server information
server_info = jira.server_info()
print(f"JIRA Version: {server_info['version']}")
print(f"Build Number: {server_info['buildNumber']}")
print(f"Build Date: {server_info['buildDate']}")
print(f"Server ID: {server_info['serverId']}")
print(f"Server Title: {server_info['serverTitle']}")
# Get current user information
current_user = jira.myself()
print(f"Current User: {current_user.displayName}")
print(f"Username: {current_user.name}")
print(f"Email: {current_user.emailAddress}")
print(f"Time Zone: {current_user.timeZone}")
# Get client connection info
client_info = jira.client_info()
print(f"Client info: {client_info}")Administrative operations for system maintenance and configuration.
def reindex(self, force: bool = False, background: bool = True) -> dict:
"""
Trigger a re-index of JIRA.
Parameters:
- force: Force re-index even if one is already running
- background: Run re-index in background
Returns:
Re-index operation status dictionary
"""
def backup(self, filename: str = 'backup.zip', attachments: bool = False) -> dict:
"""
Create a backup of JIRA.
Parameters:
- filename: Backup file name
- attachments: Include attachments in backup
Returns:
Backup operation status dictionary
"""
def backup_progress(self) -> dict:
"""
Get backup progress information.
Returns:
Backup progress dictionary
"""
def backup_complete(self) -> bool:
"""
Check if backup is complete.
Returns:
Boolean indicating backup completion status
"""
def backup_download(self, filename: str = None) -> bytes:
"""
Download backup file.
Parameters:
- filename: Backup filename to download
Returns:
Backup file content as bytes
"""Usage examples:
# Trigger system re-index
reindex_status = jira.reindex(background=True)
print(f"Re-index started: {reindex_status}")
# Create system backup
backup_status = jira.backup(
filename='jira_backup_20240315.zip',
attachments=True
)
print(f"Backup started: {backup_status}")
# Monitor backup progress
import time
while not jira.backup_complete():
progress = jira.backup_progress()
print(f"Backup progress: {progress}")
time.sleep(10)
print("Backup completed successfully")
# Download backup file
backup_data = jira.backup_download('jira_backup_20240315.zip')
with open('local_backup.zip', 'wb') as f:
f.write(backup_data)
print("Backup downloaded successfully")Manage JIRA application properties and configuration settings.
def application_properties(self, key: str = None) -> dict:
"""
Get application properties.
Parameters:
- key: Specific property key to retrieve
Returns:
Application properties dictionary
"""
def set_application_property(self, key: str, value: str) -> dict:
"""
Set an application property.
Parameters:
- key: Property key
- value: Property value
Returns:
Updated property dictionary
"""
def applicationlinks(self, cached: bool = True) -> list[dict]:
"""
Get application links.
Parameters:
- cached: Use cached results
Returns:
List of application link dictionaries
"""Usage examples:
# Get all application properties
properties = jira.application_properties()
for prop in properties:
print(f"{prop['id']}: {prop['value']}")
# Get specific property
base_url = jira.application_properties(key='jira.baseurl')
print(f"Base URL: {base_url}")
# Set application property
jira.set_application_property(
key='jira.title',
value='Company JIRA Instance'
)
# Get application links
links = jira.applicationlinks()
for link in links:
print(f"Application: {link['name']} -> {link['displayUrl']}")Operations for managing and retrieving dashboards.
def dashboards(
self,
filter: str = None,
startAt: int = 0,
maxResults: int = 20
) -> list[dict]:
"""
Get list of dashboards.
Parameters:
- filter: Dashboard name filter
- startAt: Starting index for pagination
- maxResults: Maximum number of results
Returns:
List of dashboard dictionaries
"""
def dashboard(self, id: str) -> dict:
"""
Get dashboard by ID.
Parameters:
- id: Dashboard ID
Returns:
Dashboard dictionary
"""Usage examples:
# Get all dashboards
dashboards = jira.dashboards()
for dashboard in dashboards:
print(f"Dashboard: {dashboard['name']}")
print(f"Owner: {dashboard['owner']['displayName']}")
# Search dashboards by name
dev_dashboards = jira.dashboards(filter='Development')
# Get specific dashboard
dashboard = jira.dashboard('10000')
print(f"Dashboard: {dashboard['name']}")
print(f"Description: {dashboard['description']}")Operations for managing saved filters.
def filter(self, id: str) -> dict:
"""
Get filter by ID.
Parameters:
- id: Filter ID
Returns:
Filter dictionary
"""
def favourite_filters(self) -> list[dict]:
"""
Get user's favorite filters.
Returns:
List of favorite filter dictionaries
"""
def create_filter(
self,
name: str = None,
description: str = None,
jql: str = None,
favourite: bool = None
) -> dict:
"""
Create a new filter.
Parameters:
- name: Filter name
- description: Filter description
- jql: JQL query string
- favourite: Mark as favorite
Returns:
Created filter dictionary
"""
def update_filter(
self,
filter_id: str,
name: str = None,
description: str = None,
jql: str = None,
favourite: bool = None
) -> dict:
"""
Update an existing filter.
Parameters:
- filter_id: Filter ID to update
- name: New filter name
- description: New filter description
- jql: New JQL query string
- favourite: Mark as favorite
Returns:
Updated filter dictionary
"""Usage examples:
# Get favorite filters
favorites = jira.favourite_filters()
for filter in favorites:
print(f"Favorite: {filter['name']} - {filter['jql']}")
# Create new filter
new_filter = jira.create_filter(
name='My Open Issues',
description='Issues assigned to me that are not resolved',
jql='assignee = currentUser() AND resolution = Unresolved',
favourite=True
)
print(f"Created filter: {new_filter['name']}")
# Update filter
updated_filter = jira.update_filter(
filter_id=new_filter['id'],
name='My Active Issues',
jql='assignee = currentUser() AND status in ("To Do", "In Progress")'
)
# Get specific filter
filter = jira.filter(new_filter['id'])
print(f"Filter JQL: {filter['jql']}")Various utility functions for system operations and data management.
def find(self, resource_format: str, ids: list[str] = None) -> dict:
"""
Find generic resource by format and IDs.
Parameters:
- resource_format: Resource format string
- ids: List of resource IDs
Returns:
Resource dictionary
"""
def async_do(self, size: int = 10) -> dict:
"""
Execute queued asynchronous operations.
Parameters:
- size: Batch size for async operations
Returns:
Async operation results dictionary
"""
def get_igrid(self, issueid: str, customfield: str, schemeid: str) -> dict:
"""
Get iDalko Grid data (specialized function for iDalko Grid plugin).
Parameters:
- issueid: Issue ID
- customfield: Custom field ID
- schemeid: Scheme ID
Returns:
Grid data dictionary
"""Usage examples:
# Execute async operations
async_results = jira.async_do(size=20)
print(f"Async operations completed: {async_results}")
# Find resources by format
resources = jira.find('issue/{0}', ids=['PROJ-123', 'PROJ-124'])
print(f"Found resources: {resources}")
# Get specialized plugin data (if iDalko Grid is installed)
try:
grid_data = jira.get_igrid('PROJ-123', 'customfield_10001', 'scheme1')
print(f"Grid data: {grid_data}")
except Exception as e:
print(f"iDalko Grid not available: {e}")Monitor system health and performance:
def system_health_check():
"""Perform comprehensive system health check."""
print("=== JIRA System Health Check ===")
# Server information
server_info = jira.server_info()
print(f"JIRA Version: {server_info['version']}")
print(f"Build: {server_info['buildNumber']}")
# Current user info
current_user = jira.myself()
print(f"Connected as: {current_user.displayName}")
# Test basic operations
try:
# Test project access
projects = jira.projects()
print(f"Accessible projects: {len(projects)}")
# Test issue search
recent_issues = jira.search_issues(
'created >= -7d',
maxResults=10
)
print(f"Recent issues (7 days): {len(recent_issues)}")
# Test user search
users = jira.search_users('a', maxResults=5)
print(f"User search working: {len(users)} users found")
except Exception as e:
print(f"Health check failed: {e}")
print("=== Health Check Complete ===")
# Run health check
system_health_check()Perform administrative tasks in batch:
def cleanup_old_filters(days_old=365):
"""Clean up old unused filters."""
from datetime import datetime, timedelta
# This is a conceptual example - actual implementation would
# require additional API endpoints for filter usage data
favorites = jira.favourite_filters()
print(f"Found {len(favorites)} favorite filters")
# In practice, you would need to check filter usage dates
# and remove filters that haven't been used recently
old_filters = []
for filter in favorites:
# Check if filter is old and unused
# This would require additional logic to determine usage
pass
print(f"Would clean up {len(old_filters)} old filters")
def backup_and_cleanup():
"""Automated backup and cleanup routine."""
# Create backup
backup_filename = f"jira_backup_{datetime.now().strftime('%Y%m%d')}.zip"
print("Starting backup...")
backup_status = jira.backup(filename=backup_filename, attachments=False)
# Wait for backup completion
while not jira.backup_complete():
time.sleep(30)
progress = jira.backup_progress()
print(f"Backup progress: {progress}")
print("Backup completed")
# Perform maintenance tasks
print("Starting re-index...")
jira.reindex(background=True)
print("Maintenance routine completed")
# Run automated maintenance (uncomment to execute)
# backup_and_cleanup()Manage JIRA configuration programmatically:
def export_configuration():
"""Export key JIRA configuration settings."""
config = {}
# Application properties
properties = jira.application_properties()
config['properties'] = {prop['id']: prop['value'] for prop in properties}
# Projects
projects = jira.projects()
config['projects'] = [
{
'key': p.key,
'name': p.name,
'lead': p.lead.name if p.lead else None
}
for p in projects
]
# Issue types
issue_types = jira.issue_types()
config['issue_types'] = [
{'name': it['name'], 'description': it['description']}
for it in issue_types
]
# Export to file
import json
with open('jira_config.json', 'w') as f:
json.dump(config, f, indent=2)
print("Configuration exported to jira_config.json")
return config
# Export current configuration
# config = export_configuration()