Project

Supported by Redmine starting from version 1.0

Manager

All operations on the Project resource are provided by it’s 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 (Redmine >= 2.6.0 only).
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()
True

Read methods

get

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

Returns single Project resource from Redmine by it’s id or identifier.

Parameters:
  • resource_id (int or string) – (required). Project id or identifier.
  • include (string) – (optional). Can be used to fetch associated data in one call. Accepted values (separated by ,):
    • trackers
    • issue_categories
    • enabled_modules (Redmine >= 2.6.0 only)
Returns:

Resource object

>>> project = redmine.project.get('vacation', include='trackers,issue_categories,enabled_modules')
>>> 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
  • 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)
>>> 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 (string) – (optional). Redmine >= 2.6.0 only. Can be used to fetch associated data in one call. Accepted values (separated by ,):
    • trackers
    • issue_categories
    • enabled_modules
Returns:

ResourceSet object

>>> projects = redmine.project.all(offset=10, limit=100)
>>> 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 (Redmine >= 2.6.0 only).
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()

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

Returns:True
>>> 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()
True

Delete methods

delete

redminelib.managers.ResourceManager.delete(resource_id)

Deletes single Project resource from Redmine by it’s 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

Export

New 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='projets.atom')
'/home/jsmith/projects.atom'