CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-atlassian-python-api

Python Atlassian REST API Wrapper providing comprehensive access to Jira, Confluence, Bitbucket, and other Atlassian products

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

administration.mddocs/

Administration

Comprehensive user directory management, cloud administration, and marketplace integration providing complete control over Atlassian ecosystem administration, user provisioning, and application lifecycle management.

Crowd - User Directory Management

Crowd REST API client for centralized user authentication, directory services, and single sign-on management across Atlassian applications.

Initialization

class Crowd(AtlassianRestAPI):
    def __init__(self, url: str, username: str = None, password: str = None,
                 token: str = None, **kwargs):
        """
        Initialize Crowd client.
        
        Parameters:
        - url (str): Base URL of Crowd instance
        - username (str, optional): Username for authentication
        - password (str, optional): Password for authentication
        - token (str, optional): Bearer token for authentication
        """

User Management

def get_users(self, start: int = 0, limit: int = 50) -> List[dict]:
    """
    Get all users.
    
    Parameters:
    - start: Starting index for pagination
    - limit: Maximum results to return
    
    Returns:
    List[dict]: Users list with profile information
    """

def get_user(self, username: str) -> T_resp_json:
    """
    Get user details.
    
    Parameters:
    - username: Username to retrieve
    
    Returns:
    dict: User profile with attributes and group memberships
    """

def create_user(self, username: str, email: str, first_name: str,
                last_name: str, display_name: Optional[str] = None,
                password: Optional[str] = None, active: bool = True) -> T_resp_json:
    """
    Create user.
    
    Parameters:
    - username: Unique username
    - email: Email address
    - first_name: First name
    - last_name: Last name
    - display_name: Display name (defaults to first + last name)
    - password: Initial password
    - active: User active status
    
    Returns:
    dict: Created user data
    """

def update_user(self, username: str, email: Optional[str] = None,
                first_name: Optional[str] = None, last_name: Optional[str] = None,
                display_name: Optional[str] = None, active: Optional[bool] = None) -> T_resp_json:
    """
    Update user.
    
    Parameters:
    - username: Username to update
    - email: New email address
    - first_name: New first name
    - last_name: New last name
    - display_name: New display name
    - active: New active status
    
    Returns:
    dict: Updated user data
    """

def delete_user(self, username: str) -> bool:
    """
    Delete user.
    
    Parameters:
    - username: Username to delete
    
    Returns:
    bool: True if deletion successful
    """

def search_users(self, query: str, start: int = 0, limit: int = 50) -> List[dict]:
    """
    Search users.
    
    Parameters:
    - query: Search query (username, email, name)
    - start: Starting index
    - limit: Maximum results
    
    Returns:
    List[dict]: Matching users
    """

Authentication

def authenticate_user(self, username: str, password: str) -> bool:
    """
    Authenticate user credentials.
    
    Parameters:
    - username: Username to authenticate
    - password: Password to verify
    
    Returns:
    bool: True if authentication successful
    """

def is_user_authenticated(self, username: str, token: str) -> bool:
    """
    Check if user token is valid.
    
    Parameters:
    - username: Username
    - token: Authentication token
    
    Returns:
    bool: True if token is valid
    """

def reset_user_password(self, username: str) -> T_resp_json:
    """
    Reset user password.
    
    Parameters:
    - username: Username to reset password for
    
    Returns:
    dict: Password reset result
    """

Group Management

def get_groups(self, start: int = 0, limit: int = 50) -> List[dict]:
    """
    Get all groups.
    
    Parameters:
    - start: Starting index
    - limit: Maximum results
    
    Returns:
    List[dict]: Groups list
    """

def create_group(self, name: str, description: Optional[str] = None,
                 active: bool = True) -> T_resp_json:
    """
    Create group.
    
    Parameters:
    - name: Group name
    - description: Group description
    - active: Group active status
    
    Returns:
    dict: Created group data
    """

def add_user_to_group(self, username: str, group_name: str) -> T_resp_json:
    """
    Add user to group.
    
    Parameters:
    - username: Username to add
    - group_name: Target group name
    
    Returns:
    dict: Operation result
    """

def remove_user_from_group(self, username: str, group_name: str) -> T_resp_json:
    """
    Remove user from group.
    
    Parameters:
    - username: Username to remove
    - group_name: Source group name
    
    Returns:
    dict: Operation result
    """

def get_group_members(self, group_name: str, start: int = 0,
                      limit: int = 50) -> List[dict]:
    """
    Get group members.
    
    Parameters:
    - group_name: Group name
    - start: Starting index
    - limit: Maximum results
    
    Returns:
    List[dict]: Group members
    """

Cloud Administration

Atlassian Cloud organization and user administration for enterprise-level management and compliance.

Organization Management

class CloudAdminOrgs(AtlassianRestAPI):
    def __init__(self, url: str, username: str = None, password: str = None,
                 token: str = None, **kwargs):
        """
        Initialize Cloud Admin Organizations client.
        
        Parameters:
        - url (str): Base URL of Atlassian Cloud admin API
        - username (str, optional): Username for authentication
        - password (str, optional): Password or API token
        - token (str, optional): Bearer token for authentication
        """

def get_orgs(self) -> List[dict]:
    """
    Get organizations.
    
    Returns:
    List[dict]: Organizations list with details
    """

def get_org(self, org_id: str) -> T_resp_json:
    """
    Get organization details.
    
    Parameters:
    - org_id: Organization ID
    
    Returns:
    dict: Organization information with settings and policies
    """

def get_org_users(self, org_id: str, start: int = 0, limit: int = 50) -> T_resp_json:
    """
    Get organization users.
    
    Parameters:
    - org_id: Organization ID
    - start: Starting index
    - limit: Maximum results
    
    Returns:
    dict: Organization users with roles and permissions
    """

def get_org_domains(self, org_id: str) -> List[dict]:
    """
    Get organization domains.
    
    Parameters:
    - org_id: Organization ID
    
    Returns:
    List[dict]: Verified domains for organization
    """

def get_org_policies(self, org_id: str) -> T_resp_json:
    """
    Get organization policies.
    
    Parameters:
    - org_id: Organization ID
    
    Returns:
    dict: Security and compliance policies
    """

User Administration

class CloudAdminUsers(AtlassianRestAPI):
    def __init__(self, url: str, username: str = None, password: str = None,
                 token: str = None, **kwargs):
        """
        Initialize Cloud Admin Users client.
        
        Parameters:
        - url (str): Base URL of Atlassian Cloud admin API
        - username (str, optional): Username for authentication
        - password (str, optional): Password or API token
        - token (str, optional): Bearer token for authentication
        """

def get_profile(self, account_id: str) -> T_resp_json:
    """
    Get user profile.
    
    Parameters:
    - account_id: User account ID
    
    Returns:
    dict: User profile information
    """

def get_manage_account(self, account_id: str) -> T_resp_json:
    """
    Get user account management info.
    
    Parameters:
    - account_id: User account ID
    
    Returns:
    dict: Account management details and permissions
    """

def get_api_tokens(self, account_id: str) -> List[dict]:
    """
    Get user API tokens.
    
    Parameters:
    - account_id: User account ID
    
    Returns:
    List[dict]: Active API tokens for user
    """

def suspend_user(self, account_id: str, reason: str) -> T_resp_json:
    """
    Suspend user account.
    
    Parameters:
    - account_id: User account ID
    - reason: Suspension reason
    
    Returns:
    dict: Suspension result
    """

def restore_user(self, account_id: str) -> T_resp_json:
    """
    Restore suspended user.
    
    Parameters:
    - account_id: User account ID
    
    Returns:
    dict: Restoration result
    """

Marketplace Integration

Atlassian Marketplace API client for app lifecycle management, licensing, and vendor operations.

Initialization

class MarketPlace(AtlassianRestAPI):
    def __init__(self, url: str, username: str = None, password: str = None,
                 token: str = None, **kwargs):
        """
        Initialize Marketplace client.
        
        Parameters:
        - url (str): Base URL of Atlassian Marketplace API
        - username (str, optional): Username for authentication
        - password (str, optional): Password or API token
        - token (str, optional): Bearer token for authentication
        """

App Management

def get_addon_info(self, addon_key: str) -> T_resp_json:
    """
    Get addon information.
    
    Parameters:
    - addon_key: Addon key
    
    Returns:
    dict: Addon details with versions and compatibility
    """

def get_hosted_addon_info(self, addon_key: str) -> T_resp_json:
    """
    Get hosted addon information.
    
    Parameters:
    - addon_key: Hosted addon key
    
    Returns:
    dict: Hosted addon configuration and status
    """

def get_addon_properties(self, addon_key: str) -> T_resp_json:
    """
    Get addon properties.
    
    Parameters:
    - addon_key: Addon key
    
    Returns:
    dict: Addon properties and configuration
    """

def install_addon(self, addon_key: str, version: Optional[str] = None) -> T_resp_json:
    """
    Install marketplace addon.
    
    Parameters:
    - addon_key: Addon key to install
    - version: Specific version (latest if not specified)
    
    Returns:
    dict: Installation result
    """

def uninstall_addon(self, addon_key: str) -> T_resp_json:
    """
    Uninstall addon.
    
    Parameters:
    - addon_key: Addon key to uninstall
    
    Returns:
    dict: Uninstallation result
    """

Usage Examples

Crowd User Management

from atlassian import Crowd

crowd = Crowd(
    url="https://crowd.company.com",
    username="admin",
    password="admin-password"
)

# Create user
user = crowd.create_user(
    username="john.doe",
    email="john.doe@company.com",
    first_name="John",
    last_name="Doe",
    password="initial-password"
)

# Authenticate user
is_valid = crowd.authenticate_user("john.doe", "user-password")

# Search users
users = crowd.search_users("john")

# Create group and add user
group = crowd.create_group(
    name="developers",
    description="Development team members"
)

crowd.add_user_to_group("john.doe", "developers")

# Get group members
members = crowd.get_group_members("developers")

Cloud Administration

from atlassian import CloudAdminOrgs, CloudAdminUsers

# Organization management
org_admin = CloudAdminOrgs(
    url="https://admin.atlassian.com",
    username="admin@company.com",
    password="api-token"
)

orgs = org_admin.get_orgs()
org_details = org_admin.get_org(orgs[0]["id"])
org_users = org_admin.get_org_users(orgs[0]["id"])

# User administration
user_admin = CloudAdminUsers(
    url="https://admin.atlassian.com",
    username="admin@company.com", 
    password="api-token"
)

# Get user profile
profile = user_admin.get_profile("account-id-123")

# Suspend user
suspension = user_admin.suspend_user(
    "account-id-123",
    "Policy violation - unauthorized access"
)

# Get user's API tokens
tokens = user_admin.get_api_tokens("account-id-123")

Marketplace Management

from atlassian import MarketPlace

marketplace = MarketPlace(
    url="https://marketplace.atlassian.com",
    username="vendor@company.com",
    password="api-token"
)

# Get addon information
addon_info = marketplace.get_addon_info("com.company.awesome-addon")

# Install addon
installation = marketplace.install_addon(
    "com.company.awesome-addon",
    version="2.1.0"
)

# Get addon properties
properties = marketplace.get_addon_properties("com.company.awesome-addon")

Integrated Administration Workflow

def provision_new_employee(employee_data):
    """Complete employee provisioning workflow."""
    
    # Create user in Crowd
    user = crowd.create_user(
        username=employee_data["username"],
        email=employee_data["email"],
        first_name=employee_data["first_name"],
        last_name=employee_data["last_name"],
        password=generate_initial_password()
    )
    
    # Add to appropriate groups based on role
    role_groups = {
        "developer": ["jira-software-users", "confluence-users", "bitbucket-users"],
        "manager": ["jira-administrators", "confluence-administrators"],
        "support": ["jira-servicedesk-users"]
    }
    
    for group in role_groups.get(employee_data["role"], []):
        try:
            crowd.add_user_to_group(employee_data["username"], group)
        except Exception as e:
            print(f"Failed to add user to group {group}: {e}")
    
    # If cloud environment, ensure org membership
    if cloud_environment:
        org_admin.add_user_to_org(
            org_id="company-org-id",
            account_id=user["account_id"]
        )
    
    # Send welcome email with credentials
    send_welcome_email(
        employee_data["email"],
        employee_data["username"],
        initial_password
    )
    
    return user

def audit_user_access():
    """Audit user access across Atlassian products."""
    
    # Get all users from Crowd
    all_users = crowd.get_users(limit=1000)
    
    audit_report = []
    for user in all_users:
        user_info = {
            "username": user["name"],
            "email": user["email"],
            "active": user["active"],
            "groups": [],
            "last_login": user.get("lastAuthenticated")
        }
        
        # Get group memberships
        try:
            groups = crowd.get_user_groups(user["name"])
            user_info["groups"] = [g["name"] for g in groups]
        except Exception as e:
            user_info["error"] = str(e)
        
        audit_report.append(user_info)
    
    return audit_report

Error Handling

from atlassian.errors import ApiNotFoundError, ApiPermissionError, ApiConflictError

try:
    user = crowd.create_user("existing-user", "email@example.com", "John", "Doe")
except ApiConflictError:
    print("User already exists")
except ApiPermissionError:
    print("Insufficient permissions to create user")

Types

from atlassian.typehints import T_id, T_resp_json
from typing import List, Dict, Optional

# Crowd types
Username = str
GroupName = str
AuthenticationToken = str

# Cloud Admin types
OrganizationId = str
AccountId = str
PolicyType = str

# Marketplace types
AddonKey = str
AddonVersion = str

Install with Tessl CLI

npx tessl i tessl/pypi-atlassian-python-api

docs

administration.md

asset-management.md

bitbucket.md

confluence.md

development-tools.md

index.md

jira.md

service-management.md

statuspage.md

tile.json