Project

Supported by Redmine starting from version 1.0

Manager

All operations on the Project resource are provided by its manager. To get access to it you have to call redmine.project where redmine is a configured redmine object. See the Configuration about how to configure redmine object.

Create methods

create

redminelib.managers.ResourceManager.create(**fields)

Creates new Project resource with given fields and saves it to the Redmine.

Parameters:
  • name (string) – (required). Project name.

  • identifier (string) – (required). Project identifier.

  • description (string) – (optional). Project description.

  • homepage (string) – (optional). Project homepage url.

  • is_public (bool) – (optional). Whether project is public.

  • parent_id (int) – (optional). Project’s parent project id.

  • inherit_members (bool) – (optional). Whether to inherit parent project’s members.

  • tracker_ids (list) – (optional). The ids of trackers for this project.

  • issue_custom_field_ids (list) – (optional). The ids of issue custom fields for this project.

  • custom_fields (list) – (optional). Custom fields as [{‘id’: 1, ‘value’: ‘foo’}].

  • enabled_module_names (list) – (optional). The names of enabled modules for this project (requires Redmine >= 2.6.0).

Returns:

Resource object

>>> project = redmine.project.create(
...     name='Vacation',
...     identifier='vacation',
...     description='foo',
...     homepage='http://foo.bar',
...     is_public=True,
...     parent_id=345,
...     inherit_members=True,
...     tracker_ids=[1, 2],
...     issue_custom_field_ids=[1, 2],
...     custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}],
...     enabled_module_names=['calendar', 'documents', 'files', 'gantt']
... )
>>> project
<redminelib.resources.Project #123 "Vacation">

new

redminelib.managers.ResourceManager.new()

Creates new empty Project resource but saves it to the Redmine only when save() is called, also calls pre_create() and post_create() methods of the Resource object. Valid attributes are the same as for create() method above.

Returns:

Resource object

>>> project = redmine.project.new()
>>> project.name = 'Vacation'
>>> project.identifier = 'vacation'
>>> project.description = 'foo'
>>> project.homepage = 'http://foo.bar'
>>> project.is_public = True
>>> project.parent_id = 345
>>> project.inherit_members = True
>>> project.tracker_ids = [1, 2]
>>> project.issue_custom_field_ids = [1, 2]
>>> project.custom_fields = [{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}]
>>> project.enabled_module_names = ['calendar', 'documents', 'files', 'gantt']
>>> project.save()
<redminelib.resources.Project #123 "Vacation">

Read methods

get

redminelib.managers.ResourceManager.get(resource_id, **params)

Returns single Project resource from Redmine by its id or identifier.

Parameters:
  • resource_id (int or string) – (required). Project id or identifier.

  • include (list) – (optional). Fetches associated data in one call. Accepted values:

    • trackers

    • issue_categories

    • enabled_modules (requires Redmine >= 2.6.0)

    • time_entry_activities (requires Redmine >= 3.4.0)

    • issue_custom_fields (requires Redmine >= 4.2.0)

Returns:

Resource object

>>> project = redmine.project.get('vacation', include=['trackers', 'issue_categories', 'enabled_modules', 'time_entry_activities', 'issue_custom_fields'])
>>> project
<redminelib.resources.Project #123 "Vacation">

Hint

Project resource object provides you with on demand includes. On demand includes are the other resource objects wrapped in a ResourceSet which are associated with a Project resource object. Keep in mind that on demand includes are retrieved in a separate request, that means that if the speed is important it is recommended to use get() method with include keyword argument. On demand includes provided by the Project resource object are the same as in the get() method above:

>>> project = redmine.project.get('vacation')
>>> project.trackers
<redminelib.resultsets.ResourceSet object with Tracker resources>

Hint

Project resource object provides you with some relations. Relations are the other resource objects wrapped in a ResourceSet which are somehow related to a Project resource object. The relations provided by the Project resource object are:

  • wiki_pages

  • memberships

  • issue_categories

  • versions

  • news

  • files

  • issues

  • time_entries

  • deals (requires Pro Edition and CRM plugin)

  • contacts (requires Pro Edition and CRM plugin)

  • deal_categories (requires Pro Edition and CRM plugin >= 3.3.0)

  • invoices (requires Pro Edition and Invoices plugin >= 4.1.3)

  • expenses (requires Pro Edition and Invoices plugin >= 4.1.3)

  • products (requires Pro Edition and Products plugin >= 2.1.5)

  • orders (requires Pro Edition and Products plugin >= 2.1.5)

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

all

redminelib.managers.ResourceManager.all(**params)

Returns all Project resources from Redmine.

Parameters:
  • limit (int) – (optional). How much resources to return.

  • offset (int) – (optional). Starting from what resource to return the other resources.

  • include (list) – (optional). Redmine >= 2.6.0 only. Fetches associated data in one call. Accepted values:

    • trackers

    • issue_categories

    • enabled_modules

    • time_entry_activities

Returns:

ResourceSet object

>>> projects = redmine.project.all(offset=10, limit=100, include=['trackers', 'issue_categories', 'enabled_modules', 'time_entry_activities'])
>>> projects
<redminelib.resultsets.ResourceSet object with Project resources>

filter

Not supported by Redmine

Update methods

update

redminelib.managers.ResourceManager.update(resource_id, **fields)

Updates values of given fields of a Project resource and saves them to the Redmine.

Parameters:
  • resource_id (int) – (required). Project id.

  • name (string) – (optional). Project name.

  • description (string) – (optional). Project description.

  • homepage (string) – (optional). Project homepage url.

  • is_public (bool) – (optional). Whether project is public.

  • parent_id (int) – (optional). Project’s parent project id.

  • inherit_members (bool) – (optional). Whether to inherit parent project’s members.

  • tracker_ids (list) – (optional). The ids of trackers for this project.

  • issue_custom_field_ids (list) – (optional). The ids of issue custom fields for this project.

  • custom_fields (list) – (optional). Custom fields as [{‘id’: 1, ‘value’: ‘foo’}].

  • enabled_module_names (list) – (optional). The names of enabled modules for this project (requires Redmine >= 2.6.0).

Returns:

True

>>> redmine.project.update(
...     1,
...     name='Vacation',
...     description='foo',
...     homepage='http://foo.bar',
...     is_public=True,
...     parent_id=345,
...     inherit_members=True,
...     tracker_ids=[1, 2],
...     issue_custom_field_ids=[1, 2],
...     custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}],
...     enabled_module_names=['calendar', 'documents', 'files', 'gantt']
... )
True

save

redminelib.resources.Project.save(**attrs)

Saves the current state of a Project resource to the Redmine. Attrs that can be changed are the same as for update() method above.

Returns:

Resource object

>>> project = redmine.project.get(1)
>>> project.name = 'Vacation'
>>> project.description = 'foo'
>>> project.homepage = 'http://foo.bar'
>>> project.is_public = True
>>> project.parent_id = 345
>>> project.inherit_members = True
>>> project.tracker_ids = [1, 2]
>>> project.issue_custom_field_ids = [1, 2]
>>> project.custom_fields = [{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}]
>>> project.enabled_module_names = ['calendar', 'documents', 'files', 'gantt']
>>> project.save()
<redminelib.resources.Project #1 "Vacation">

Added in version 2.1.0: Alternative syntax was introduced.

>>> project = redmine.project.get(1).save(
...     name='Vacation',
...     description='foo',
...     homepage='http://foo.bar',
...     is_public=True,
...     parent_id=345,
...     inherit_members=True,
...     tracker_ids=[1, 2],
...     issue_custom_field_ids=[1, 2],
...     custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}],
...     enabled_module_names=['calendar', 'documents', 'files', 'gantt']
... )
>>> project
<redminelib.resources.Project #1 "Vacation">

Delete methods

delete

redminelib.managers.ResourceManager.delete(resource_id)

Deletes single Project resource from Redmine by its id or identifier.

Parameters:

resource_id (int or string) – (required). Project id or identifier.

Returns:

True

>>> redmine.project.delete(1)
True
redminelib.resources.Project.delete()

Deletes current Project resource object from Redmine.

Returns:

True

>>> project = redmine.project.get(1)
>>> project.delete()
True

Additional methods

Added in version 2.4.0.

close

redminelib.managers.ProjectManager.close(resource_id)

Closes single Project Redmine resource by its id or identifier.

Parameters:

resource_id (int or string) – (required). Project id or identifier.

Returns:

True

>>> redmine.project.close(1)
True
redminelib.resources.Project.close()

Closes current Project Redmine resource object.

Returns:

True

>>> project = redmine.project.get(1)
>>> project.close()
True

reopen

redminelib.managers.ProjectManager.reopen(resource_id)

Reopens previously closed single Project Redmine resource by its id or identifier.

Parameters:

resource_id (int or string) – (required). Project id or identifier.

Returns:

True

>>> redmine.project.reopen(1)
True
redminelib.resources.Project.reopen()

Reopens previously closed current Project Redmine resource object.

Returns:

True

>>> project = redmine.project.get(1)
>>> project.reopen()
True

archive

redminelib.managers.ProjectManager.archive(resource_id)

Archives single Project Redmine resource by its id or identifier.

Parameters:

resource_id (int or string) – (required). Project id or identifier.

Returns:

True

>>> redmine.project.archive(1)
True
redminelib.resources.Project.archive()

Archives current Project Redmine resource object.

Returns:

True

>>> project = redmine.project.get(1)
>>> project.archive()
True

unarchive

redminelib.managers.ProjectManager.unarchive(resource_id)

Unarchives single Project Redmine resource by its id or identifier.

Parameters:

resource_id (int or string) – (required). Project id or identifier.

Returns:

True

>>> redmine.project.unarchive(1)
True

Export

Added in version 2.0.0.

redminelib.resultsets.ResourceSet.export(fmt, savepath=None, filename=None)

Exports a resource set of Project resources in one of the following formats: atom

Parameters:
  • fmt (string) – (required). Format to use for export.

  • savepath (string) – (optional). Path where to save the file.

  • filename (string) – (optional). Name that will be used for the file.

Returns:

String or Object

>>> projects = redmine.project.all()
>>> projects.export('atom', savepath='/home/jsmith', filename='projects.atom')
'/home/jsmith/projects.atom'