Python-Redmine

repository·master·Indexed 20 days ago

https://github.com/maxtepkeev/python-redmine

A Python library for communicating with Redmine project management applications via its REST API. It provides an ORM-style interface for managing projects, issues, and other resources. The library supports custom resource definition, external authentication, and multiple request engines (Sync, Thread, and Process). It is available in a free Standard Edition and a paid Pro Edition that includes asynchronous request support and API endpoints for RedmineUP plugins.

Tokens
56.6K
Snippets
241
Records
258
Agent score
69%

What's inside python-redmine

  1. Overview of Python-Redmine features

    master

    Python-Redmine is a library designed to communicate with the Redmine project management application via its REST API.

    Key capabilities include:

    • Full API Support: Supports 100% of the Redmine API, including external Redmine plugins.
    • ORM-style API: Provides a Pythonic interface inspired by the Django ORM for interacting with resources.
    • Extensibility: Can be extended using custom resources and custom request engines.
    • Compatibility: Supports Python 3.7 - 3.12 and PyPy3.
    • Flexible Networking: Supports different request engines for handling HTTP communication.
  2. Explore RedmineUP plugin resources

    master

    The library includes support for various RedmineUP plugins. Depending on your installed plugins, you can access resources for:

    • CRM: contact, contact_tag, note, deal, deal_status, deal_category, crm_query
    • Helpdesk: ticket
    • Checklists: checklist
    • Invoices: invoice, invoice_payment, expense
    • Products: product, product_category, order, order_status
  3. Explore Redmine core API resources

    master

    The python-redmine library provides comprehensive support for core Redmine entities. You can interact with the following resources via the API:

    • Issues & Workflow: issue, issue_relation, issue_status, tracker, issue_category
    • Project Management: project, project_membership, version, wiki_page
    • Users & Access: user, role, group
    • Time & Files: time_entry, file, attachment
    • Content & Organization: news, query, enumeration, custom_field
  4. Compare Standard and Pro Editions of Python-Redmine

    master

    Python-Redmine is available in two editions: Standard and Pro.

    Standard Edition

    • Cost: Free
    • Distribution: PyPI
    • Features: Supports all vanilla Redmine features.
    • License: Apache 2.0

    Pro Edition

    • Cost: 25 USDT (purchased via TON)
    • Features: Includes everything in Standard, plus:
      • Engines: Thread and Process engines (in addition to Sync).
      • Support: Email support with a 24-hour response time.
      • Plugin Support: API endpoints for various RedmineUP plugins (CRM, Helpdesk, Checklists, Invoices, and Products).
      • Async: Support for async requests to Redmine.
    • License: Python-Redmine Pro Edition License Version 1.0. The license is valid for the current major version (e.g., a license for 2.x.x covers all 2.x.x releases).
  5. How ResourceManager works for CRUD operations

    master

    In Python-Redmine, a ResourceManager is an object that provides CRUD (Create, Read, Update, Delete) operations for a specific Redmine resource (e.g., Project, Issue, User). These managers are accessed as attributes of your configured redmine object.

    Best Practice: It is recommended to access the ResourceManager directly from the redmine object for each operation rather than storing the manager in a variable, to ensure you are always working with the most current state.

    # Recommended: Accessing the manager on the fly
    p1 = redmine.project.get(1)
    p2 = redmine.project.get(2)
    
    # Not recommended: Storing the manager object
    project_manager = redmine.project
    p1 = project_manager.get(1)
    p2 = project_manager.get(2)
    >>> redmine.project
    <redminelib.managers.ResourceManager object for Project resource>
    >>> redmine.issue
    <redminelib.managers.ResourceManager object for Issue resource>
    >>> redmine.user
    <redminelib.managers.ResourceManager object for User resource>
  6. Access Custom Field management via the CustomField manager

    master

    All operations for the CustomField resource are handled through a manager. You can access this manager by calling redmine.custom_field on a configured Redmine object. Note that Custom Fields are supported by Redmine starting from version 2.4.

    # Assuming 'redmine' is already configured
    manager = redmine.custom_field
  7. Manage Issue Journals (History)

    master

    Issue history is represented by IssueJournal resources.

    Accessing Journals: It is recommended to include journals when fetching the issue to avoid extra requests:

    issue = redmine.issue.get(1, include=['journals'])
    for journal in issue.journals:
        print(journal.id, journal.notes)

    Operations:

    • Create: Add a new journal entry by updating the issue with notes: redmine.issue.update(1, notes='new note').
    • Update: Update the notes of an existing journal: journal.save(notes='new value') or redmine.issue_journal.update(journal_id, notes='new value').
    • Delete: To delete a journal, set its notes attribute to an empty string: journal.save(notes='') or redmine.issue_journal.update(journal_id, notes=''). Note: You cannot delete a journal that has associated details.
    # Accessing journals
    issue = redmine.issue.get(1, include=['journals'])
    for journal in issue.journals:
        print(journal.id, journal.notes)
    
    # Updating a journal note
    issue.journals[0].save(notes='setting notes to a new value')
    
    # Deleting a journal (setting notes to empty)
    issue.journals[0].save(notes='')
  8. How on-demand includes and relations work

    master

    Project resource objects provide two ways to access associated data:

    1. On-demand includes: Accessing attributes like project.trackers triggers a separate API request to fetch the associated ResourceSet. This is convenient but slower than using include in the get() method.
    2. Relations: These are ResourceSet objects representing related resources. Common relations include:
      • wiki_pages
      • memberships
      • issue_categories
      • versions
      • news
      • files
      • issues
      • time_entries
      • Plugin-specific relations: deals, contacts, deal_categories (CRM plugin), invoices, expenses (Invoices plugin), products, orders (Products plugin).

    Example of accessing a relation:

    project = redmine.project.get('vacation')
    issues = project.issues  # Returns a ResourceSet of Issue resources
    project = redmine.project.get('vacation')
    >>> project.issues
    <redminelib.resultsets.ResourceSet object with Issue resources>