Skip to main content

JIRA AS

PyPI version Python 3.10+ License: MIT

A Python library and CLI for JIRA REST API automation, providing HTTP client, configuration management, error handling, and utilities for the JIRA Assistant Skills Claude Code plugin.

Installation

pip install jira-as

With optional keyring support for secure credential storage:

pip install jira-as[keyring]

Features

  • CLI (jira-as): Command-line interface for JIRA operations
  • JiraClient: HTTP client with automatic retry logic and exponential backoff
  • ConfigManager: Multi-source configuration (env vars > keychain > settings.local.json > settings.json > defaults)
  • Error Handling: Exception hierarchy mapping HTTP status codes to domain exceptions
  • Validators: Input validation for issue keys, project keys, JQL queries, URLs, and more
  • Formatters: Output formatting for tables, JSON, CSV export
  • ADF Helper: Atlassian Document Format conversion (markdown/text to ADF and back)
  • Time Utils: JIRA time format parsing and formatting (e.g., '2h', '1d 4h 30m')
  • Cache: SQLite-based caching with TTL support for API responses
  • Credential Manager: Secure credential storage via system keychain or JSON fallback
  • Mock Client: Full mock implementation for testing without JIRA access

Quick Start

Configuration

Set environment variables:

export JIRA_API_TOKEN="your-api-token"  # Get from https://id.atlassian.com/manage-profile/security/api-tokens
export JIRA_EMAIL="your-email@company.com"
export JIRA_SITE_URL="https://your-company.atlassian.net"

CLI Usage

# Get an issue
jira-as issue get PROJ-123

# Search issues
jira-as search query "project = PROJ AND status = Open"

# Create an issue
jira-as issue create PROJ --summary "New task" --type Task

# Transition an issue
jira-as lifecycle transition PROJ-123 "In Progress"

# See all commands
jira-as --help

Library Usage

from jira_as import get_jira_client, handle_errors

@handle_errors
def main():
    # Get a configured JIRA client (use as context manager)
    with get_jira_client() as client:
        # Fetch an issue
        issue = client.get_issue('PROJ-123')
        print(f"Summary: {issue['fields']['summary']}")

        # Search issues with JQL
        results = client.search_issues('project = PROJ AND status = Open')
        for issue in results['issues']:
            print(f"{issue['key']}: {issue['fields']['summary']}")

if __name__ == '__main__':
    main()

Core Components

JiraClient

from jira_as import JiraClient

# Direct instantiation (prefer get_jira_client() for config management)
client = JiraClient(
    base_url="https://your-company.atlassian.net",
    email="your-email@company.com",
    api_token="your-api-token"
)

# Use as context manager
with client:
    issue = client.get_issue('PROJ-123')
    client.create_issue(project_key='PROJ', summary='New issue', issue_type='Task')
    client.transition_issue('PROJ-123', 'Done')

Error Handling

from jira_as import (
    JiraError,
    AuthenticationError,
    PermissionError,
    NotFoundError,
    handle_errors
)

@handle_errors
def main():
    # Exceptions are caught and formatted nicely
    pass

# Or handle manually
try:
    with get_jira_client() as client:
        client.get_issue('INVALID-999')
except NotFoundError as e:
    print(f"Issue not found: {e}")
except AuthenticationError as e:
    print(f"Auth failed: {e}")
except JiraError as e:
    print(f"JIRA error: {e}")

Validators

from jira_as import (
    validate_issue_key,
    validate_project_key,
    validate_jql,
    validate_url,
    ValidationError
)

try:
    key = validate_issue_key('PROJ-123')  # Returns 'PROJ-123'
    key = validate_issue_key('invalid')   # Raises ValidationError
except ValidationError as e:
    print(f"Invalid input: {e}")

ADF Helper

from jira_as import (
    markdown_to_adf,
    text_to_adf,
    adf_to_text
)

# Convert markdown to ADF for JIRA
adf = markdown_to_adf("**Bold** and *italic* text")

# Convert plain text to ADF
adf = text_to_adf("Simple text content")

# Extract text from ADF
text = adf_to_text(adf_document)

Time Utils

from jira_as import (
    parse_time_string,
    format_seconds,
    parse_relative_date
)

# Parse JIRA time format to seconds
seconds = parse_time_string('2h 30m')  # 9000

# Format seconds to JIRA time format
time_str = format_seconds(9000)  # '2h 30m'

# Parse relative dates
dt = parse_relative_date('yesterday')
dt = parse_relative_date('2025-01-15')

Mock Mode

For testing without JIRA access:

export JIRA_MOCK_MODE=true
jira-as issue get DEMO-85  # Returns mock data
import os
os.environ['JIRA_MOCK_MODE'] = 'true'

from jira_as import get_jira_client

with get_jira_client() as client:  # Returns MockJiraClient
    issue = client.get_issue('DEMO-85')  # Mock data

Development

# Clone the repository
git clone https://github.com/grandcamel/jira-as.git
cd jira-as

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code (black formats; ruff sorts imports)
black src tests
ruff check --fix src tests

# Type checking
mypy src

License

MIT License - see LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jira_as-1.1.3.tar.gz (252.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jira_as-1.1.3-py3-none-any.whl (281.4 kB view details)

Uploaded Python 3

File details

Details for the file jira_as-1.1.3.tar.gz.

File metadata

  • Download URL: jira_as-1.1.3.tar.gz
  • Upload date:
  • Size: 252.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for jira_as-1.1.3.tar.gz
Algorithm Hash digest
SHA256 c442c0206b325bc5433c4456b5320ff76be74bb84097904e5b3311205ec07e48
MD5 0f1f0078521f6047f38142db7fb28055
BLAKE2b-256 270dd9c450012fefb6a8d38bb61b876aabece6904d994b5bd9041af8a270408d

See more details on using hashes here.

Provenance

The following attestation bundles were made for jira_as-1.1.3.tar.gz:

Publisher: publish.yml on grandcamel/jira-as

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jira_as-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: jira_as-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 281.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for jira_as-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 db68b705b8d515b9877cdc9f49e5b22efb021317ade5d8acc130046fd461d91d
MD5 c1a380f26491c997675a05c319fcfe83
BLAKE2b-256 7162b8a95182b71a41ce9aa981e280f80245f19f8bd34c4c1c6ecdac03f74129

See more details on using hashes here.

Provenance

The following attestation bundles were made for jira_as-1.1.3-py3-none-any.whl:

Publisher: publish.yml on grandcamel/jira-as

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page