You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"source": "Login to Mergin Maps using your workspace user with `Owner` permission.",
65
+
"metadata": {
66
+
"id": "u05lxbRQm2VF"
67
+
}
68
+
},
69
+
{
70
+
"cell_type": "code",
71
+
"source": "# Use here your login username and password\nLOGIN=\"\"\nPASSW=\"\"\n\nimport mergin\n\nclient = mergin.MerginClient(login=LOGIN, password=PASSW)",
"source": "Let's create a dummy workspace and project as base for our users management example.\n\nChange the variable `WORKSPACE`with your desired workspace name and `PROJECT` with project name.",
96
+
"metadata": {
97
+
"id": "gFN3jXIjntwf"
98
+
}
99
+
},
100
+
{
101
+
"cell_type": "code",
102
+
"source": "# Add here your existing workspace name and the new project name\nWORKSPACE=\"\"\nPROJECT=\"\"\n\n# Create new workspace\n#INFO: Only uncomment if you are able to create a new workspace. Mergin Maps free tier only allows for 1 workspace per user. In this case use your existing workspace.\n#client.create_workspace(WORKSPACE) \n\n# Create new dummy project (public accessible)\nclient.create_project(project_name=PROJECT, namespace=WORKSPACE, is_public=True)",
103
+
"metadata": {
104
+
"id": "27rA4VfgoJjy",
105
+
"executionInfo": {
106
+
"status": "ok",
107
+
"timestamp": 1748364795430,
108
+
"user_tz": -60,
109
+
"elapsed": 745,
110
+
"user": {
111
+
"displayName": "Fernando Ribeiro",
112
+
"userId": "15488710231554262191"
113
+
}
114
+
}
115
+
},
116
+
"outputs": [],
117
+
"execution_count": 3
118
+
},
119
+
{
120
+
"cell_type": "markdown",
121
+
"source": "Create some users on your Mergin Maps example workspace from the provided example file in `01_users_assets/users.csv` with random permissions.",
122
+
"metadata": {
123
+
"id": "SXimIDIDqb9J"
124
+
}
125
+
},
126
+
{
127
+
"cell_type": "code",
128
+
"source": "import csv\nimport string\nimport random\n\nfrom mergin.common import WorkspaceRole\n\npermissions = [WorkspaceRole.EDITOR,\n WorkspaceRole.READER,\n WorkspaceRole.WRITER]\n\n\ntry:\n with open('01_users_assets/users.csv', mode='r', newline='', encoding='utf-8') as csvfile:\n reader = csv.reader(csvfile)\n header = next(reader) # Skip header\n first_data_row = next(reader) # Get first data row\n if len(first_data_row) >= 2: # Check if there are at least two columns\n username = first_data_row[0]\n email = first_data_row[1]\n # add new mergin maps user\n client.create_user(username=username, password=random.choices(string.ascii_uppercase + string.digits, k=12), email=email, workspace_id=WORKSPACE, workspace_role=random.choice(permissions))\n print(f\"User '{username}' created successfully.\")\n else:\n print(\"First data row does not have enough columns.\")\nexcept FileNotFoundError:\n print(f\"File '{filename}' not found for processing example.\")\nexcept StopIteration:\n print(f\"File '{filename}' does not contain enough data rows for processing example.\")\nexcept Exception as e:\n print(f\"An error occurred during processing example: {e}\")\n",
129
+
"metadata": {
130
+
"id": "Lp351dFYquVs"
131
+
},
132
+
"outputs": [],
133
+
"execution_count": null
134
+
},
135
+
{
136
+
"cell_type": "markdown",
137
+
"source": "Let's change permission level for a specific user to `READER`.",
0 commit comments