Project Membership

Supported by Redmine starting from version 1.4

Manager

All operations on the ProjectMembership resource are provided by its manager. To get access to it you have to call redmine.project_membership 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 ProjectMembership resource with given fields and saves it to the Redmine.

Parameters:
  • project_id (int or string) – (required). Id or identifier of the project.

  • user_id (int) – (required). Id of the user or group to add to the project.

  • role_ids (list) – (required). Role ids to add to the user in this project.

Returns:

Resource object

>>> membership = redmine.project_membership.create(project_id='vacation', user_id=1, role_ids=[1, 2])
>>> membership
<redminelib.resources.ProjectMembership #123>

new

redminelib.managers.ResourceManager.new()

Creates new empty ProjectMembership 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

>>> membership = redmine.project_membership.new()
>>> membership.project_id = 'vacation'
>>> membership.user_id = 1
>>> membership.role_ids = [1, 2]
>>> membership.save()
<redminelib.resources.ProjectMembership #123>

Read methods

get

redminelib.managers.ResourceManager.get(resource_id)

Returns single ProjectMembership resource from Redmine by its id.

Parameters:

resource_id (int) – (required). Project membership id.

Returns:

Resource object

>>> membership = redmine.project_membership.get(521)
>>> membership
<redminelib.resources.ProjectMembership #521>

all

Not supported by Redmine

filter

redminelib.managers.ResourceManager.filter(**filters)

Returns ProjectMembership resources that match the given lookup parameters.

Parameters:
  • project_id (int or string) – (required). Id or identifier of the project.

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

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

Returns:

ResourceSet object

>>> memberships = redmine.project_membership.filter(project_id='vacation')
>>> memberships
<redminelib.resultsets.ResourceSet object with ProjectMembership resources>

Hint

You can also get project memberships from a Project resource object directly using memberships relation:

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

Update methods

update

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

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

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

  • role_ids (list) – (required). Role ids to add to the user in this project.

Returns:

True

>>> redmine.project_membership.update(1, role_ids=[1, 2])
True

save

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

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

Returns:

Resource object

>>> membership = redmine.project_membership.get(1)
>>> membership.role_ids = [1, 2]
>>> membership.save()
<redminelib.resources.ProjectMembership #1>

Added in version 2.1.0: Alternative syntax was introduced.

>>> membership = redmine.project_membership.get(1).save(role_ids=[1, 2])
>>> membership
<redminelib.resources.ProjectMembership #1>

Delete methods

delete

redminelib.managers.ResourceManager.delete(resource_id)

Deletes single ProjectMembership resource from Redmine by its id.

Parameters:

resource_id (int) – (required). Project membership id.

Returns:

True

>>> redmine.project_membership.delete(1)
True
redminelib.resources.ProjectMembership.delete()

Deletes current ProjectMembership resource object from Redmine.

Returns:

True

>>> membership = redmine.project_membership.get(1)
>>> membership.delete()
True

Export

Not supported by Redmine