### Install Python-Redmine using pip Source: https://github.com/maxtepkeev/python-redmine/blob/master/README.rst Provides the command-line instruction to install the standard edition of the Python-Redmine library from the Python Package Index (PyPI) using pip, the standard package installer for Python. ```bash pip install python-redmine ``` -------------------------------- ### Import Redmine Library Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Imports the main Redmine class from the redminelib library, which is the entry point for all interactions with the Redmine API. ```python from redminelib import Redmine ``` -------------------------------- ### Get All Deal Resources with Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/deal.md Fetches all Deal resources available in Redmine using the redminelib. The `all()` method supports optional `limit` and `offset` parameters to control the number of resources returned and the starting point for the retrieval, respectively. It returns a ResourceSet object containing the Deal resources. ```python >>> deals = redmine.deal.all(limit=50) >>> deals ``` -------------------------------- ### Get All Invoice Resources (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/invoice.md This snippet demonstrates how to fetch all Invoice resources from the Invoices plugin. The redminelib.ResourceManager.all() method can optionally accept 'limit' and 'offset' parameters to control the number of resources returned and the starting point of the results, respectively. ```python >>> invoices = redmine.invoice.all(limit=50) >>> invoices ``` -------------------------------- ### Initialize Redmine Connection (Basic) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Initializes a Redmine connection object with the required Redmine server URL. Ensure the URL does not end with a forward slash. ```python redmine = Redmine('https://redmine.url') ``` -------------------------------- ### GET /products Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Retrieves a collection of Product resources from the Products plugin. ```APIDOC ## GET /products ### Description Retrieves a collection of Product resources from the Products plugin. ### Method GET ### Endpoint /products ### Parameters #### Query Parameters - **status_id** (int) - Optional - Filter products by status ID (1: active, 2: inactive). - **project_id** (int or string) - Optional - Filter products by project ID or identifier. - **category_id** (int) - Optional - Filter products by category ID. - **include** (list) - Optional - Fetches associated data in one call. Accepted values: `attachments`. ### Request Example ```python # Get all active products products = redmine.product.all(status_id=1) # Get all products for a specific project with attachments products = redmine.product.all(project_id='my-project', include=['attachments']) ``` ### Response #### Success Response (200) - **ResourceSet** (object) - A `ResourceSet` containing multiple Product resource objects. #### Response Example ```json [ { "id": 123, "name": "Example Product 1", "project_id": "products", "status_id": 1, "code": "EX-001", "price": "19.99", "currency": "USD", "category_id": 5, "description": "This is the first example product.", "tag_list": ["example", "product"], "created_on": "2023-01-01T10:00:00Z", "updated_on": "2023-01-02T11:00:00Z" }, { "id": 124, "name": "Example Product 2", "project_id": "products", "status_id": 2, "code": "EX-002", "price": "29.99", "currency": "USD", "category_id": 5, "description": "This is the second example product.", "tag_list": ["example", "product"], "created_on": "2023-01-03T12:00:00Z", "updated_on": "2023-01-03T12:00:00Z" } ] ``` ``` -------------------------------- ### Get All Product Resources (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Retrieves all Product resources from the Products plugin. Supports optional limit and offset parameters for pagination. Returns a ResourceSet object. ```python >>> products = redmine.product.all(limit=50) >>> products ``` -------------------------------- ### Copy Redmine Issues (Python) Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Provides examples of how to duplicate existing Redmine issues, with options to include subtasks, attachments, and link to the original issue. Uses the python-redmine library. ```python from redminelib import Redmine # Configure and connect to Redmine # redmine = Redmine('https://redmine.example.com', key='your_api_key') # Copy an issue with all default options (includes subtasks and attachments) # try: # copied_issue = redmine.issue.copy( # issue_id=1234, # project_id='mobile-app', # subject='Copied: Implement responsive design', # assigned_to_id=30, # link_original=True # ) # print(f"Copied issue #{copied_issue.id} from #1234") # except Exception as e: # print(f"Error copying issue #1234: {e}") # Copy without linking to original # try: # copied_issue2 = redmine.issue.copy( # issue_id=1234, # project_id='website-redesign', # subject='Similar task for different component', # link_original=False, # include=('subtasks',) # Only copy subtasks, not attachments # ) # print(f"Copied issue #{copied_issue2.id} (subtasks only)") # except Exception as e: # print(f"Error copying issue #1234 (subtasks only): {e}") # Copy without any related objects # try: # basic_copy = redmine.issue.copy( # issue_id=1234, # project_id='testing', # subject='Test copy', # link_original=False, # include=None # ) # print(f"Copied issue #{basic_copy.id} (no relations)") # except Exception as e: # print(f"Error copying issue #1234 (no relations): {e}") # Placeholder for actual execution print("Issue copy examples commented out. Uncomment and configure redmine connection to run.") ``` -------------------------------- ### Initialize Redmine Connection (with Version) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Initializes a Redmine connection, specifying the Redmine server version. This helps ensure compatibility with the library's features. The version should be in 'major.minor.patch' format. ```python redmine = Redmine('https://redmine.url', version='5.0.4') ``` -------------------------------- ### Integrate Redmine Configuration with Django Settings (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Demonstrates a best practice for managing Redmine connection details by storing them in a Django project's settings file and importing them into the application code. ```python # settings.py REDMINE_URL = 'https://redmine.url' REDMINE_KEY = 'b244397884889a29137643be79c83f1d470c1e2fac' # somewhere in the code from django.conf import settings from redminelib import Redmine redmine = Redmine(settings.REDMINE_URL, key=settings.REDMINE_KEY) ``` -------------------------------- ### Initialize Redmine Connection (Username/Password) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Initializes a Redmine connection using a username and password for authentication. This is a common method for accessing Redmine resources. ```python redmine = Redmine('https://redmine.url', username='foo', password='bar') ``` -------------------------------- ### Retrieve Projects from Redmine in Python Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Illustrates how to fetch project data from Redmine, including retrieving a single project by its identifier with included related resources like trackers and issues. Also shows how to get all projects and filter them. ```python from redminelib import Redmine redmine = Redmine('https://redmine.example.com', key='your_api_key') # Get single project by identifier with includes project = redmine.project.get('website-redesign', include=['trackers', 'issue_categories', 'enabled_modules', 'time_entry_activities', 'issue_custom_fields']) print(f"Project: {project.name}") print(f"Description: {project.description}") print(f"Created: {project.created_on}") print(f"Status: {project.status}") print(f"Trackers: {[t.name for t in project.trackers]}") # Access project's related resources for issue in project.issues[:5]: print(f"Issue #{issue.id}: {issue.subject}") # Get all projects projects = redmine.project.all() for proj in projects: print(f"{proj.identifier}: {proj.name}") # Filter projects filtered = redmine.project.filter(limit=10, offset=0) ``` -------------------------------- ### Get All Roles Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/role.md Retrieves all Role resources available in Redmine, with optional pagination. ```APIDOC ## GET /roles ### Description Retrieves all Role resources from Redmine. ### Method GET ### Endpoint /roles ### Parameters #### Query Parameters - **limit** (int) - Optional - Specifies the maximum number of resources to return. - **offset** (int) - Optional - Specifies the starting point for returning resources. ### Response #### Success Response (200) - **roles** (array) - A list of Role resource objects. #### Response Example { "roles": [ { "id": 1, "name": "Admin" }, { "id": 2, "name": "Developer" } ] } ### Request Example ```python roles = redmine.role.all() print(roles) ``` ``` -------------------------------- ### Configure Process Engine in Python-Redmine (Pro Edition) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/advanced/request_engines.md Illustrates how to utilize the ProcessEngine for asynchronous operations via Python processes. This example shows how to instantiate Redmine with the ProcessEngine and adjust the worker count. ```python from redminelib import engines, Redmine redmine = Redmine('https://redmine.url', engine=engines.ProcessEngine, workers=4) ``` -------------------------------- ### Initialize Redmine Connection (Impersonation) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Initializes a Redmine connection with user impersonation enabled. This requires administrator privileges on the Redmine server and specifies the login of the user to impersonate. ```python redmine = Redmine('https://redmine.url', impersonate='jsmith') ``` -------------------------------- ### Initialize Redmine Connection (API Key) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Initializes a Redmine connection using an API key for authentication. This method is often preferred for security as it avoids storing passwords directly in scripts. ```python redmine = Redmine('https://redmine.url', key='b244397884889a29137643be79c83f1d470c1e2fac') ``` -------------------------------- ### Initialize Redmine Connection (Custom Date/Time Formats) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Initializes a Redmine connection with custom date and datetime format strings. This is necessary if your Redmine server uses non-standard formats for these values. ```python redmine = Redmine('https://redmine.url', date_format='%d.%m.%Y', datetime_format='%d.%m.%YT%H:%M:%SZ') ``` -------------------------------- ### Get all Product Categories in Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product_category.md Fetches all ProductCategory resources available in the Products plugin. Supports optional 'limit' and 'offset' parameters for pagination. Returns a ResourceSet object containing the categories. ```python >>> categories = redmine.product_category.all(limit=50) >>> categories ``` -------------------------------- ### Control Attribute Access Exceptions in Python-Redmine Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/configuration.md Manage how Python-Redmine handles requests for non-existent attributes on resource objects. Exceptions can be disabled globally or selectively enabled for specific resource types. ```python from redminelib import Redmine # Disable attribute exception globally redmine = Redmine('https://redmine.url', raise_attr_exception=False) # Enable attribute exception for specific resources redmine = Redmine('https://redmine.url', raise_attr_exception=('Project', 'Issue', 'WikiPage')) ``` -------------------------------- ### Access On-Demand Includes for Redmine Project (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/project.md Demonstrates accessing associated Redmine data for a project resource after it has been retrieved. These 'on-demand' includes are fetched in separate requests if not specified during the initial 'get' call. ```python >>> project = redmine.project.get('vacation') >>> project.trackers ``` -------------------------------- ### Get All Expense Resources in Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/expense.md Fetches all Expense resources available in the Invoices plugin. Supports optional limit and offset parameters to control the number of resources returned and the starting point. ```python >>> expenses = redmine.expense.all(limit=50) >>> expenses ``` -------------------------------- ### Create Projects in Redmine using Python Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Shows how to create new projects in Redmine, either by providing all configuration options at once or by creating a project object and setting its attributes before saving. Includes examples of setting project name, identifier, description, trackers, custom fields, and enabled modules. ```python from redminelib import Redmine redmine = Redmine('https://redmine.example.com', key='your_api_key') # Create a complete project with all options project = redmine.project.create( name='Website Redesign', identifier='website-redesign', description='Complete overhaul of company website', homepage='https://company.com', is_public=True, parent_id=10, inherit_members=True, tracker_ids=[1, 2, 3], issue_custom_field_ids=[5, 7], custom_fields=[ {'id': 1, 'value': 'High Priority'}, {'id': 2, 'value': 'Q1 2024'} ], enabled_module_names=['issue_tracking', 'time_tracking', 'news', 'documents', 'files', 'wiki', 'repository', 'forums', 'calendar', 'gantt'] ) print(f"Created project: {project.name} (ID: {project.id})") # Alternative: Create project step by step new_project = redmine.project.new() new_project.name = 'Mobile App Development' new_project.identifier = 'mobile-app' new_project.description = 'Native mobile applications for iOS and Android' new_project.is_public = False new_project.tracker_ids = [1, 2] new_project.save() print(f"Saved project: {new_project.identifier}") ``` -------------------------------- ### Get Single Contact Tag Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/contact_tag.md Retrieves a single Contact Tag resource by its ID. This method is available starting from version 2.1.0 and requires the Pro Edition with the CRM plugin (v3.4.0+). ```APIDOC ## GET /contact_tag/{resource_id} ### Description Retrieves a single ContactTag resource from the CRM plugin by its ID. ### Method GET ### Endpoint /contact_tag/{resource_id} ### Parameters #### Path Parameters - **resource_id** (int) - Required - The unique identifier of the contact tag. #### Query Parameters None #### Request Body None ### Request Example ```python tag = redmine.contact_tag.get(1) print(tag) ``` ### Response #### Success Response (200) - **ContactTag object** - A Resource object representing the fetched contact tag. #### Response Example ```json { "id": 1, "name": "Online" } ``` ``` -------------------------------- ### Get All Redmine Queries with Pagination Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/query.md Fetches all Query resources available in Redmine. Supports pagination through `limit` and `offset` parameters to control the number of results and the starting point. Returns a ResourceSet object containing the queries. ```python >>> queries = redmine.query.all(offset=10, limit=100) >>> queries ``` -------------------------------- ### Initialize Redmine Connection and Get Project Source: https://github.com/maxtepkeev/python-redmine/blob/master/README.rst Demonstrates how to initialize a Redmine connection using the library, specifying the Redmine instance URL and user credentials. It then shows how to retrieve a specific project by its identifier and access its properties like ID, identifier, and creation date. ```python from redminelib import Redmine redmine = Redmine('http://demo.redmine.org', username='foo', password='bar') project = redmine.project.get('vacation') print(project.id) print(project.identifier) print(project.created_on) ``` -------------------------------- ### Get All Groups in Redmine Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/group.md Fetches all Group resources available in Redmine. Supports pagination using `limit` and `offset` parameters to control the number of resources returned and the starting point. Returns a ResourceSet object containing Group resources. ```python >>> groups = redmine.group.all() >>> groups ``` -------------------------------- ### Initialize Redmine Connection in Python Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Demonstrates how to establish a connection to a Redmine server using API key or username/password authentication. It also shows how to specify version, timezone, and date/datetime formats, and verifies the authentication. ```python from redminelib import Redmine # Basic connection with API key redmine = Redmine('https://redmine.example.com', key='your_api_key_here') # Connection with username and password redmine = Redmine('https://redmine.example.com', username='admin', password='secret') # Connection with version specification and timezone import datetime redmine = Redmine('https://redmine.example.com', key='your_api_key', version='5.0.4', timezone='+0000', date_format='%Y-%m-%d', datetime_format='%Y-%m-%dT%H:%M:%SZ') # Verify authentication try: current_user = redmine.auth() print(f"Authenticated as: {current_user.firstname} {current_user.lastname}") except Exception as e: print(f"Authentication failed: {e}") ``` -------------------------------- ### Manage Redmine Users with Python Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Demonstrates creating, retrieving, updating, and listing users in Redmine using the python-redmine library. It covers creating new users with detailed properties, fetching the current authenticated user and their details, retrieving specific users by ID, listing all users, and modifying existing user information. ```python from redminelib import Redmine # Assuming redmine object is already initialized # redmine = Redmine('https://redmine.example.com', key='your_api_key') # Create a new user user = redmine.user.create( login='jdoe', password='SecurePass123!', firstname='John', lastname='Doe', mail='john.doe@example.com', auth_source_id=1, mail_notification='only_assigned', must_change_passwd=True, generate_password=False, custom_fields=[ {'id': 1, 'value': 'Engineering'}, {'id': 2, 'value': 'Senior Developer'} ], admin=False ) print(f"Created user: {user.login} (ID: {user.id})") # Get current authenticated user current_user = redmine.user.get('current', include=['memberships', 'groups']) print(f"Current user: {current_user.firstname} {current_user.lastname}") print(f"Email: {current_user.mail}") print(f"Admin: {current_user.admin}") # List memberships for membership in current_user.memberships: print(f"Member of: {membership.project.name}") # Get specific user user = redmine.user.get(42, include=['memberships', 'groups']) print(f"User {user.id}: {user.login}") # Get all users users = redmine.user.all() for u in users: print(f"{u.login}: {u.firstname} {u.lastname}") # Update user user = redmine.user.get(42) user.firstname = 'Jane' user.lastname = 'Smith' user.mail = 'jane.smith@example.com' user.save() ``` -------------------------------- ### Get All Invoice Payments - Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/invoice_payment.md Fetches all InvoicePayment resources available in the Invoices plugin. Supports optional `limit` and `offset` parameters to control the number of results and the starting point. Returns a ResourceSet object containing InvoicePayment resources. ```python >>> payments = redmine.invoice_payment.all(limit=50) >>> payments ``` -------------------------------- ### Get All Order Statuses using Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/order_status.md Retrieves all OrderStatus resources available from the Products plugin. This method can optionally accept 'limit' and 'offset' parameters to control the number of resources returned and the starting point. It returns a ResourceSet object containing OrderStatus resources. ```python >>> statuses = redmine.order_status.all() >>> statuses ``` -------------------------------- ### Create Product Resource with RedmineLib Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Creates a new Product resource with specified fields and uploads associated files. Requires project_id, name, and optionally status_id, code, price, currency, category_id, description, tags, custom fields, image, and uploads. Returns a Product resource object. ```python >>> product = redmine.product.create( ... project_id='products', ... name='foobar', ... status_id=2, ... code='P-001', ... price='9.99', ... currency='USD', ... category_id=8, ... description='product description', ... tag_list=['foo', 'bar'], ... custom_fields=[{'id': 1, 'value': '11'}], ... image={'path': '/absolute/path/to/file.jpg'}, ... uploads=[{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] ... ) >>> product ``` -------------------------------- ### Create Issues in Redmine using Python Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Provides examples for creating new issues in Redmine, including setting details like subject, description, priority, status, assigned user, and file attachments. It utilizes the 'issue.create' method and demonstrates how to handle file uploads. ```python from redminelib import Redmine import datetime from io import BytesIO redmine = Redmine('https://redmine.example.com', key='your_api_key') # Example of creating an issue (actual code for creation not fully shown in input) # issue = redmine.issue.create( # project_id=1, # subject='Bug in login page', # description='User cannot log in with valid credentials.', # priority_id=1, # status_id=1, # assigned_to_id=5, # attachment=BytesIO(b'file content') # ) # print(f"Created issue: #{issue.id}") ``` -------------------------------- ### Get All Contact Tags (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/contact_tag.md Fetches all ContactTag resources available from the CRM plugin. This method supports optional 'limit' and 'offset' parameters to control the number of resources returned and the starting point of the retrieval. It returns a ResourceSet object containing ContactTag resources. ```python >>> tags = redmine.contact_tag.all() >>> tags ``` -------------------------------- ### Get All Custom Fields Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/custom_field.md Fetches all CustomField resources available in Redmine. This method can optionally accept `limit` and `offset` parameters to control the number of resources returned and the starting point of the results, respectively. It returns a ResourceSet object containing CustomField resources. ```python >>> fields = redmine.custom_field.all() >>> fields ``` -------------------------------- ### Create Redmine Resource Immediately (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/introduction.md Uses the `create()` method of a ResourceManager to instantiate a new resource, save it to Redmine, and return the created resource object. This is a straightforward method for resource creation. ```python >>> project = redmine.project.create( ... name='Vacation', ... identifier='vacation', ... description='foo', ... homepage='http://foo.bar', ... is_public=True, ... parent_id=345, ... inherit_members=True, ... custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}] ... ) >>> project ``` -------------------------------- ### Create and Save Redmine Issues (Python) Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Demonstrates two methods for creating Redmine issues: a complete creation with all options and an incremental creation followed by saving. Requires the python-redmine library and a Redmine connection. ```python from redminelib import Redmine import datetime from io import BytesIO # Assuming redmine connection is already established # redmine = Redmine('https://redmine.example.com', key='your_api_key') # Example issue data (replace with actual values or fetched data) project_id = 'website-redesign' subject = 'Homepage layout needs improvement' tracker_id = 2 description = 'The current homepage layout is not responsive on mobile devices. Need to implement a flexible grid system.' status_id = 1 priority_id = 4 assigned_to_id = 15 watcher_user_ids = [15, 23, 47] parent_issue_id = 100 start_date = datetime.date(2024, 1, 15) due_date = datetime.date(2024, 2, 15) estimated_hours = 16 done_ratio = 0 is_private = False custom_fields = [ {'id': 1, 'value': 'Frontend'}, {'id': 2, 'value': 'CSS/HTML'} ] uploads = [ {'path': '/home/user/mockup.png', 'filename': 'homepage_mockup.png', 'description': 'New design mockup'}, {'path': BytesIO(b'Detailed requirements document content'), 'filename': 'requirements.txt', 'content_type': 'text/plain'} ] # Create a complete issue with all options # issue = redmine.issue.create( # project_id=project_id, # subject=subject, # tracker_id=tracker_id, # description=description, # status_id=status_id, # priority_id=priority_id, # assigned_to_id=assigned_to_id, # watcher_user_ids=watcher_user_ids, # parent_issue_id=parent_issue_id, # start_date=start_date, # due_date=due_date, # estimated_hours=estimated_hours, # done_ratio=done_ratio, # is_private=is_private, # custom_fields=custom_fields, # uploads=uploads # ) # print(f"Created issue #{issue.id}: {issue.subject}") # Alternative: Create issue incrementally # new_issue = redmine.issue.new() # new_issue.project_id = 'mobile-app' # new_issue.subject = 'Implement push notifications' # new_issue.tracker_id = 1 # new_issue.description = 'Add Firebase Cloud Messaging for push notifications' # new_issue.priority_id = 5 # new_issue.assigned_to_id = 42 # new_issue.save() # print(f"Created new issue #{new_issue.id}: {new_issue.subject}") # Placeholder for actual execution print("Issue creation examples commented out. Uncomment and configure redmine connection to run.") ``` -------------------------------- ### Get All Roles using Python Redmine Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/role.md Fetches all available Role resources from Redmine. This method utilizes the redminelib.managers.ResourceManager.all function and supports optional 'limit' and 'offset' parameters to control the number of resources returned and the starting point of the retrieval. It returns a ResourceSet object containing the roles. ```python >>> roles = redmine.role.all() >>> roles ``` -------------------------------- ### POST /products Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Creates a new Product resource with the provided fields. This operation requires Pro Edition and the Products plugin. ```APIDOC ## POST /products ### Description Creates a new Product resource with the provided fields. This operation requires Pro Edition and the Products plugin. ### Method POST ### Endpoint /products ### Parameters #### Request Body - **name** (string) - Required - Product name. - **project_id** (int or string) - Required - Id or identifier of product’s project. - **status_id** (int) - Optional - Product status id (1: active, 2: inactive). - **code** (string) - Optional - Product code. - **price** (string) - Optional - Product price. - **currency** (string) - Optional - Product currency. - **category_id** (int) - Optional - Product category id. - **description** (string) - Optional - Product description. - **tag_list** (list) - Optional - List of tags. - **custom_fields** (list) - Optional - Custom fields as [{‘id’: 1, ‘value’: ‘foo’}]. - **image** (dict) - Optional - Image for the product. Accepted keys: `path` (required), `filename` (optional). - **uploads** (list) - Optional - Uploads as list of dicts. Accepted keys: `path` (required), `filename` (optional), `description` (optional), `content_type` (optional). ### Request Example ```python { "project_id": "products", "name": "foobar", "status_id": 2, "code": "P-001", "price": "9.99", "currency": "USD", "category_id": 8, "description": "product description", "tag_list": ["foo", "bar"], "custom_fields": [{"id": 1, "value": "11"}], "image": {"path": "/absolute/path/to/file.jpg"}, "uploads": [{"path": "/absolute/path/to/file"}, {"path": "BytesIO(b'I am content of file 2')"}] } ``` ### Response #### Success Response (200) - **Resource** (object) - The created Product resource object. #### Response Example ```json { "id": 123, "name": "foobar", "project_id": "products", "status_id": 2, "code": "P-001", "price": "9.99", "currency": "USD", "category_id": 8, "description": "product description", "tag_list": ["foo", "bar"], "created_on": "2023-01-01T10:00:00Z", "updated_on": "2023-01-01T10:00:00Z" } ``` ``` -------------------------------- ### Optimized Redmine Resource Creation with Session (Python) Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/introduction.md Shows how to use `redmine.session` context manager with `return_response=False` or `ignore_response=True` to optimize resource creation requests when the response is not needed. This can save processing time. ```python with redmine.session(return_response=False): redmine.issue.create(project_id=123, subject='Vacation') with redmine.session(return_response=False): issue = redmine.issue.new() issue.project_id = 123 issue.subject = 'Vacation' issue.save() ``` -------------------------------- ### POST /products/new Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Creates a new empty Product resource locally. The resource is saved to the Products plugin only when `save()` is called. ```APIDOC ## POST /products/new ### Description Creates a new empty Product resource locally. The resource is saved to the Products plugin only when `save()` is called. ### Method POST ### Endpoint /products/new ### Parameters #### Request Body - **name** (string) - Required - Product name. - **project_id** (int or string) - Required - Id or identifier of product’s project. - **status_id** (int) - Optional - Product status id (1: active, 2: inactive). - **code** (string) - Optional - Product code. - **price** (string) - Optional - Product price. - **currency** (string) - Optional - Product currency. - **category_id** (int) - Optional - Product category id. - **description** (string) - Optional - Product description. - **tag_list** (list) - Optional - List of tags. - **custom_fields** (list) - Optional - Custom fields as [{‘id’: 1, ‘value’: ‘foo’}]. - **image** (dict) - Optional - Image for the product. Accepted keys: `path` (required), `filename` (optional). - **uploads** (list) - Optional - Uploads as list of dicts. Accepted keys: `path` (required), `filename` (optional), `description` (optional), `content_type` (optional). ### Request Example ```python { "project_id": "products", "name": "foobar", "status_id": 2, "code": "P-001", "price": "9.99", "currency": "USD", "category_id": 8, "description": "product description", "tag_list": ["foo", "bar"], "custom_fields": [{"id": 1, "value": "11"}], "image": {"path": "/absolute/path/to/file.jpg"}, "uploads": [{"path": "/absolute/path/to/file"}, {"path": "BytesIO(b'I am content of file 2')"}] } ``` ### Response #### Success Response (200) - **Resource** (object) - The new, unsaved Product resource object. #### Response Example ```json { "id": null, "name": "foobar", "project_id": "products", "status_id": 2, "code": "P-001", "price": "9.99", "currency": "USD", "category_id": 8, "description": "product description", "tag_list": ["foo", "bar"], "created_on": null, "updated_on": null } ``` ``` -------------------------------- ### Get String Representation of Resource with repr() in Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/introduction.md Illustrates the use of the repr() function to get a string representation of a Redmine resource object, typically showing its type, ID, and name. ```python >>> repr(redmine.project.get('vacation')) '' ``` -------------------------------- ### Get a Single Resource by ID using Python-Redmine Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/introduction.md The `get()` method retrieves a single resource from a ResourceSet using its ID. It returns None if the resource is not found. This is useful for fetching specific items. ```python redmine.project.all().get(30404, None) ``` -------------------------------- ### GET /news/{resource_id} - Get News by ID Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/news.md Retrieves a single news item from Redmine using its unique identifier. Supports including related data like comments and attachments in the response. ```APIDOC ## GET /news/{resource_id} ### Description Fetches a specific news item by its ID. You can optionally include associated data like comments or attachments. ### Method GET ### Endpoint `/news/{resource_id}` ### Parameters #### Path Parameters - **resource_id** (int) - Required - The unique identifier of the news item to retrieve. #### Query Parameters - **include** (list) - Optional - A list of associated data to include. Accepted values: `comments`, `attachments`. #### Request Body None ### Request Example ``` GET /news/123?include[]=comments&include[]=attachments ``` ### Response #### Success Response (200) - **resource** (Resource) - The requested News resource object, potentially with included data. #### Response Example ```json { "id": 123, "title": "Vacation Announcement", "description": "Details about the upcoming vacation.", "created_on": "2023-10-27T10:00:00Z", "updated_on": "2023-10-27T10:00:00Z", "comments": [...], "attachments": [...] } ``` ``` -------------------------------- ### Python Redmine: Using Sessions for Temporary Configuration Source: https://context7.com/maxtepkeev/python-redmine/llms.txt Demonstrates creating temporary Redmine sessions with modified settings, such as impersonating another user, setting custom request timeouts, disabling SSL verification, or using alternative API keys for authentication. ```python from redminelib import Redmine redmine = Redmine('https://redmine.example.com', key='your_api_key') # Use session for impersonation with redmine.session(impersonate='jdoe') as session: # All operations in this block are performed as user 'jdoe' issue = session.issue.create( project_id='website-redesign', subject='Issue created via impersonation', description='This issue is created as user jdoe' ) print(f"Created issue #{issue.id} as jdoe") # Use session for custom request options with redmine.session(requests={'timeout': 60, 'verify': False}) as session: # This request has extended timeout and disabled SSL verification projects = session.project.all() for project in projects: print(project.name) # Session for different authentication with redmine.session(key='different_api_key') as session: user = session.user.get('current') print(f"Authenticated as: {user.login}") ``` -------------------------------- ### Get Issue Categories via Project Relation - python-redmine Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/issue_category.md An alternative method to retrieve Issue Categories associated with a specific project. First, get the Project resource, then access its 'issue_categories' relation. Returns a ResourceSet object. ```python >>> project = redmine.project.get('vacation') >>> project.issue_categories ``` -------------------------------- ### Get Checklists from Issue Resource - Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/checklist.md Accesses the checklist items directly associated with an existing Issue resource object. This is a convenient way to get checklists for a known issue. Returns a ResourceSet object containing the checklist items. ```python >>> issue = redmine.issue.get(1) >>> issue.checklists ``` -------------------------------- ### Create Empty Product Resource with RedmineLib and Save Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Initializes a new Product resource object with specified attributes but does not save it to Redmine until `save()` is called. This method allows for deferred saving and is useful for building complex resource objects incrementally. It also triggers pre_create and post_create hooks. ```python >>> product = redmine.product.new() >>> product.project_id = 'products' >>> product.name = 'foobar' >>> product.status_id = 2 >>> product.code = 'P-001' >>> product.price = '9.99' >>> product.currency = 'USD' >>> product.category_id = 8 >>> product.description = 'product description' >>> product.tag_list = ['foo', 'bar'] >>> product.custom_fields = [{'id': 1, 'value': '11'}] >>> product.image = {'path': '/absolute/path/to/file.jpg'} >>> product.uploads = [{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}] >>> product.save() ``` -------------------------------- ### Get Single Deal Resource by ID with Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/deal.md Retrieves a single Deal resource from Redmine by its unique ID using the redminelib. The `get()` method can optionally include associated data like 'notes' in the same request for performance optimization. If 'include' is not used, associated data can be fetched on demand via ResourceSet objects. ```python >>> deal = redmine.deal.get(123, include=['notes']) >>> deal ``` ```python >>> deal = redmine.deal.get(123) >>> deal.notes ``` -------------------------------- ### Control Data Fetching with Limit and Offset in Python Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/introduction.md Demonstrates how to retrieve specific portions of resources using slicing or keyword arguments (limit and offset) with the python-redmine library. Keyword arguments have higher priority than slicing. ```python redmine.project.all()[:135] # Returns only first 135 projects redmine.project.all(limit=135) # Returns only first 135 projects redmine.issue.filter(project_id='vacation')[10:3] # Returns only 3 issues starting from 10th redmine.issue.filter(project_id='vacation', offset=10, limit=3) # Returns only 3 issues starting from 10th ``` ```python redmine.project.all(limit=10)[:20] # Returns 10 projects and not 20 ``` -------------------------------- ### Get Issue Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/issue.md Retrieves a single issue resource from Redmine by its ID. ```APIDOC ## GET /issue/{resource_id} ### Description Returns a single Issue resource from Redmine by its ID. ### Method GET ### Endpoint /issue/{resource_id} ### Parameters #### Path Parameters - **resource_id** (int) - Required - Id of the issue. #### Query Parameters - **include** (list) - Optional - Fetches associated data in one call. Accepted values: - children - attachments - relations - changesets - journals - watchers (requires Redmine >= 2.3.0) - allowed_statuses (requires Redmine >= 5.0.0) ### Response #### Success Response (200) - **issue** (Resource) - The requested issue object. #### Response Example ```json { "issue": { "id": 34441, "subject": "Vacation", "children": [], "journals": [], "watchers": [] } } ``` ``` -------------------------------- ### GET /products/{resource_id} Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/product.md Retrieves a single Product resource from the Products plugin by its ID. ```APIDOC ## GET /products/{resource_id} ### Description Retrieves a single Product resource from the Products plugin by its ID. ### Method GET ### Endpoint /products/{resource_id} ### Parameters #### Path Parameters - **resource_id** (int) - Required - The ID of the product to retrieve. #### Query Parameters - **include** (list) - Optional - Fetches associated data in one call. Accepted values: `attachments`. ### Request Example ```python # To get a product with attachments included redmine.product.get(123, include=['attachments']) # To get a product without includes redmine.product.get(123) ``` ### Response #### Success Response (200) - **Resource** (object) - The requested Product resource object. #### Response Example ```json { "id": 123, "name": "Example Product", "project_id": "products", "status_id": 1, "code": "EX-001", "price": "19.99", "currency": "USD", "category_id": 5, "description": "This is an example product.", "tag_list": ["example", "product"], "created_on": "2023-01-01T10:00:00Z", "updated_on": "2023-01-02T11:00:00Z" } ``` #### HINT Product resource objects provide on-demand includes. These are other resource objects wrapped in a `ResourceSet` and are retrieved in a separate request if not specified in the initial `get()` call. The available on-demand includes for Product are the same as the `include` parameter in the `get()` method: `attachments`. ``` -------------------------------- ### Get Single Role Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/role.md Retrieves a single Role resource from Redmine using its unique identifier. ```APIDOC ## GET /roles/{resource_id} ### Description Retrieves a single Role resource from Redmine by its id. ### Method GET ### Endpoint /roles/{resource_id} ### Parameters #### Path Parameters - **resource_id** (int) - Required - The ID of the role to retrieve. ### Response #### Success Response (200) - **role** (object) - The retrieved Role resource object. #### Response Example { "role": { "id": 4, "name": "Waiter" } } ### Request Example ```python role = redmine.role.get(4) print(role) ``` ``` -------------------------------- ### Create Redmine Version Resource Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/version.md Creates a new Version resource in Redmine with specified fields. Requires project ID and name, with optional status, sharing, due date, description, and wiki page title. Returns a Resource object. ```python >>> version = redmine.version.create( ... project_id='vacation', ... name='Vacation', ... status='open', ... sharing='none', ... due_date=datetime.date(2014, 1, 30), ... description='my vacation', ... wiki_page_title='Vacation' ... ) >>> version ``` -------------------------------- ### GET /query Source: https://github.com/maxtepkeev/python-redmine/blob/master/docs/resources/query.md Retrieves all Query resources from Redmine, with support for pagination. Requires Redmine version 1.3 or later. ```APIDOC ## GET /query ### Description Retrieves all Query resources from Redmine, with support for pagination. ### Method GET ### Endpoint /query ### Parameters #### Query Parameters - **limit** (int) - Optional - The maximum number of resources to return. - **offset** (int) - Optional - The starting offset for retrieving resources. ### Request Example ```python # Assuming 'redmine' is a configured Redmine API client object queries = redmine.query.all(offset=10, limit=100) print(queries) ``` ### Response #### Success Response (200) - **ResourceSet** (object) - A ResourceSet object containing Query resources. #### Response Example ```json ``` ```