{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Teams & Roles\n", "\n", "Quantinuum Nexus offers secure and flexible ways of sharing data and managing workflows. To that end we have the following concepts:\n", "\n", "- `Team`: a group of users.\n", "- `Roles`: a named role with specific permissions.\n", "\n", "A `Role` can be assigned to a `Team` or `User` to give specific permissions on a particular `Project` or resource in Nexus. \n", "\n", "These are concepts are related purely to collaboration and permissions, and are not related to metering or quotas.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import qnexus as qnx\n", "from datetime import datetime" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# List teams I am a member of\n", "qnx.teams.get_all().df()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a new Team\n", "\n", "my_team = qnx.teams.create(name=f\"My Team, created on {datetime.now()}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Assigning a Role to a Team\n", "\n", "By default when you create a Project, only you will be able to view/manage the contents of that project.\n", "\n", "Lets take the team we created and give it a `Contributor` role on a new Project." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Get possible roles in Nexus and render them in a DataFrame\n", "nexus_roles = qnx.roles.get_all()\n", "\n", "nexus_roles.df()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_new_project = qnx.projects.create(name=f\"My project with {my_team.name} team\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Assign a contributor role to the team on my new project\n", "\n", "qnx.roles.assign_team(\n", " resource_ref=my_new_project,\n", " team=my_team,\n", " role=\"Contributor\"\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# View the assigned roles on a particular project or resource\n", "\n", "qnx.roles.assignments(resource_ref=my_new_project).df()" ] } ], "metadata": { "kernelspec": { "display_name": "qnexus-Rou6F43i-py3.11", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.8" } }, "nbformat": 4, "nbformat_minor": 2 }