Crowd module

API reference

class atlassian.crowd.Crowd(url, username, password, timeout=60, api_root='rest', api_version='latest')

Crowd API wrapper. Important to note that you will have to use an application credentials, not user credentials, in order to access Crowd APIs

check_plugin_manager_status()
delete_plugin(plugin_key)

Delete plugin :param plugin_key: :return:

get_plugin_info(plugin_key)

Provide plugin info :return a json of installed plugins

get_plugin_license_info(plugin_key)

Provide plugin license info :return a json specific License query

get_plugins_info()

Provide plugins info :return a json of installed plugins

group(groupname)

Return a group by name.

group_add_user(username, groupname)

Add user to group :return:

group_attributes(groupname)

Return all attributes for a group.

group_create(groupname, description=None, active=True)

Create new group method :param groupname: string: The name of new group :param description: string: The description of new group, default is None :param active: bool: Weather the group is active, default is True :return: Create result

group_delete(groupname)

Delete a group by name.

group_members(group, kind='direct', max_results=99999)

Get group’s all direct members :param group: str - group name :param kind: str - group type :param max_results: int - maximum number of results :return: The specify group’s direct members info

group_remove_attribute(groupname, attribute_name)

Delete one group attribute.

group_remove_user(username, groupname)

Remove a direct user-to-group membership.

group_store_attributes(groupname, attributes)

Store group attributes using Crowd’s attribute request body.

group_update(groupname, data)

Update a group with a Crowd group representation.

health_check()

Get health status https://confluence.atlassian.com/jirakb/how-to-retrieve-health-check-results-using-rest-api-867195158.html :return:

is_user_in_group(username, group, kind='direct')

Check if the user is a member of the group :param username: str - username :param group: str - group name :param kind: str - group type :return: bool - Return True or False

property memberships

Retrieves full details of all group memberships, with users and nested groups. See: https://docs.atlassian.com/atlassian-crowd/5.3.1/REST/#usermanagement/1/group-getAllMemberships :return: All membership mapping dict

nested_group_members(groupname, max_results=99999)

Return users who are direct or nested members of a group.

nested_user_groups(username)

Return direct and nested groups for a user.

update_plugin_license(plugin_key, raw_license)

Update license for plugin :param plugin_key: :param raw_license: :return:

upload_plugin(plugin_path)

Provide plugin path for upload into Jira e.g. useful for auto deploy :param plugin_path: :return:

user(username)

Get user information :param username: :return:

user_activate(username)

Activate user :param username: str - username

user_attributes(username)

Return all attributes for a user.

user_create(username, active, first_name, last_name, display_name, email, password)

Create new user method :param active: bool: :param username: string: username :param active: bool: :param first_name: string: :param last_name: string: :param display_name: string: :param email: string: :param password: string: :return:

user_deactivate(username)

Deactivate user

Returns:

user_delete(username)

Delete user :param username: str - username :return:

user_groups(username, kind='direct')

Get user’s all group info :param username: str - username :param kind: str - group type :return: The specify user’s group info

user_remove_attribute(username, attribute_name)

Delete one user attribute.

user_store_attributes(username, attributes)

Store user attributes using Crowd’s attribute request body.

user_update(username, data)

Update a user with a Crowd user representation.

user_update_password(username, password)

Update a user’s password.

Manage users

# Activate user
crowd.user_activate(username)

# Add user
crowd.user_create(username, active, first_name, last_name, display_name, email, password)

# Deactivate user
crowd.user_deactivate(username)

# Delete user
crowd.user_delete(username)

# Get user
crowd.user(username)

# Get user's all group info
crowd.user_groups(username, kind='direct')

# Check whether the user is a member of the group
crowd.is_user_in_group(username, group, kind='direct')

crowd.user_update(username, {"name": username, "email": "ada@example.com", "active": True})
crowd.user_update_password(username, "new-password")
crowd.user_store_attributes(username, {"attributes": []})
crowd.nested_user_groups(username)
crowd.group_remove_user(username, groupname)

Manage groups

# Add user to group
crowd.group_add_user(username, groupname)

# Get group's members
crowd.group_members(group, kind='direct', max_results=99999)

# Create new group method
crowd.group_create(groupname, description, active=True)

crowd.group(groupname)
crowd.group_update(groupname, {"name": groupname, "active": True})
crowd.group_store_attributes(groupname, {"attributes": []})
crowd.nested_group_members(groupname)
crowd.group_delete(groupname)

Get memberships

# Retrieves full details of all group memberships.
# Return data structure:
# {
#     GroupName1<str>: [ Member1<str>, Member2<str>, ... ],
#     GroupName2<str>: [ MemberA<str>, MemberB<str>, ... ],
#     ...
# }
crowd.memberships

Healthcheck

# Check if the Crowd server is reachable
crowd.health_check()

# Provide plugins info
crowd.get_plugins_info()

# Provide plugin info
crowd.get_plugin_info(plugin_key)

# Provide plugin license info
crowd.get_plugin_license_info(plugin_key)

# Provide plugin path for upload into Jira e.g. useful for auto deploy
crowd.upload_plugin(plugin_path)

# Delete plugin
crowd.delete_plugin(plugin_key)

# Check plugin manager status
crowd.check_plugin_manager_status()

# Update plugin license
crowd.update_plugin_license(plugin_key, license_key)