Skip to content

Commit 443132c

Browse files
authored
Merge pull request #672 from MerginMaps/add_create_invitation_method
Add create invitation method
1 parent 3044fa0 commit 443132c

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

scripts/wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,4 @@ yaml
304304
pre
305305
env
306306
IDP
307+
enum

src/dev/integration/index.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ You can create new users and manage their roles using the following methods.
5353
The following methods are available for Python API Client versions `0.10.0` or higher, using server versions `2025.2.0` or higher.
5454
:::
5555

56+
Some of the following methods require a `workspace_role` argument. This must be provided as a member of the `WorkspaceRole` enum.
57+
To use the enum, import it from the `common.py` module:
58+
59+
```python
60+
from mergin.common import WorkspaceRole
61+
```
62+
5663
### Create a user
5764

5865
```python
@@ -69,15 +76,17 @@ Arguments:
6976

7077
`workspace_id` (int) <span title="Ignored on Community edition servers">:information_source:</span> : The workspace ID where the user will be added.
7178

72-
`workspace_role` (string) <span title="Ignored on Community edition servers">:information_source:</span> : The user’s role in the workspace. [See the roles options](../../manage/permissions/index.md#workspace-member-roles-overview).
79+
`workspace_role` (`WorkspaceRole` enum) <span title="Ignored on Community edition servers">:information_source:</span> : The user’s role in the workspace. [See the roles options](../../manage/permissions/index.md#workspace-member-roles-overview).
7380

7481
`username` (string, optional): If not provided, it will be automatically generated from the email address.
7582

7683
`notify_user` (Boolean, optional): If true, confirmation email and other email communication will be sent to the email address (invitations, access requests etc.). Default is `False`.
7784

7885
Example:
7986
```python
80-
client.create_user("jill@example.com", "T0p_secret", 1, "editor", notify_user=True)
87+
from mergin.common import WorkspaceRole
88+
89+
client.create_user("jill@example.com", "T0p_secret", 1, WorkspaceRole.EDITOR, notify_user=True)
8190
```
8291

8392
> :information_source: `workspace_id` and `workspace_role` arguments are ignored on Community edition servers.
@@ -125,7 +134,7 @@ Arguments:
125134

126135
`user_id` (int): ID of the user.
127136

128-
`workspace_role` (string): New role. [See the roles options](../../manage/permissions/index.md#workspace-member-roles-overview).
137+
`workspace_role` (`WorkspaceRole` enum): New role. [See the roles options](../../manage/permissions/index.md#workspace-member-roles-overview).
129138

130139
`reset_projects_roles` (Boolean, optional): If true, overridden project roles (explicitly shared projects access) will be reset. Default is `False`.
131140

@@ -142,6 +151,24 @@ Arguments:
142151

143152
> The user account is not removed. This method only removes their access to the workspace.
144153
154+
#### Invite user to workspace
155+
156+
::: warning API availability
157+
The following method is available for Python API Client versions `0.10.3` or higher, using server versions `2025.6.1` or higher.
158+
:::
159+
160+
```python
161+
client.create_invitation(<workspace_id>, <email>, <workspace_role>)
162+
```
163+
164+
Arguments:
165+
166+
`workspace_id` (int): The workspace ID where the user will be invited.
167+
168+
`email` (string): The email of an existing user.
169+
170+
`workspace_role` (`WorkspaceRole` enum): The user’s role in the workspace. [See the roles options](../../manage/permissions/index.md#workspace-member-roles-overview).
171+
145172
---
146173

147174
### Project collaborators methods
@@ -156,6 +183,13 @@ The caller of the following methods must be a workspace admin, owner, project ow
156183

157184
The following methods accept project ids (of type `uuid`). You can find project id via <GitHubRepo id="MerginMaps/python-api-client/blob/634237890afd9f28f03953e5a01376b56f5abf5c/mergin/client.py#L572" desc="projects_list" /> and <GitHubRepo id="MerginMaps/python-api-client/blob/634237890afd9f28f03953e5a01376b56f5abf5c/mergin/client.py#L641" desc="project_info" /> methods.
158185

186+
Some of the following methods require a `project_role` argument. This must be provided as a member of the `ProjectRole` enum.
187+
To use the enum, import it from the `common.py` module:
188+
189+
```python
190+
from mergin.common import ProjectRole
191+
```
192+
159193
#### List project collaborators
160194

161195
```python
@@ -179,7 +213,7 @@ Arguments:
179213

180214
`user` (string): Email or username of the user to be added to the project.
181215

182-
`project_role`: (string): Role of the user in the project. [See the roles options](../../manage/permissions/index.md#project-permissions-overview)
216+
`project_role`: (`ProjectRole` enum): Role of the user in the project. [See the roles options](../../manage/permissions/index.md#project-permissions-overview)
183217

184218
#### Update project collaborator role
185219

@@ -192,7 +226,7 @@ Arguments:
192226

193227
`user_id` (int): ID of the user.
194228

195-
`project_role`: (string): New role. [See the roles options](../../manage/permissions/index.md#project-permissions-overview)
229+
`project_role`: (`ProjectRole` enum): New role. [See the roles options](../../manage/permissions/index.md#project-permissions-overview)
196230

197231
> The user must be first added to the project (via [Add project collaborator](./index.md#add-project-collaborator)) before calling this method, even if he/she is already a workspace member or guest.
198232
@@ -207,7 +241,7 @@ Arguments:
207241

208242
`user_id` (int): ID of the user.
209243

210-
> The user account is not removed, only the project access.
244+
> The user account is not removed, only the project access.
211245
212246
## Further details
213247

0 commit comments

Comments
 (0)