From 55518e18eb457da23a33d478d342664d09cfe8a3 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Fri, 26 Apr 2024 18:03:47 +0200 Subject: [PATCH 1/4] fix: workspace name not a parameter --- Naas API/Naas_API_Create_Workspace.ipynb | 29 ++++++++++++------------ 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Naas API/Naas_API_Create_Workspace.ipynb b/Naas API/Naas_API_Create_Workspace.ipynb index 7ffb5747da..153c84e293 100644 --- a/Naas API/Naas_API_Create_Workspace.ipynb +++ b/Naas API/Naas_API_Create_Workspace.ipynb @@ -141,21 +141,21 @@ "outputs": [], "source": [ "api_key = naas.secret.get('NAAS_API_TOKEN')\n", - "user_id = \"2b9ac8af-4026-4173-8796-xxxxxx\"\n", + "user_id = \"2b9ac8af-4026-4173-8796-xxxxxxx\"\n", "data = {\n", " \"user_id\": user_id,\n", " \"workspace\": {\n", - " 'name': 'Test',\n", - " 'fav_icon': '',\n", - " 'large_logo': '',\n", - " 'small_logo': '',\n", - " 'primary_color': '#0080FF', #highlight green\n", - " 'secondary_color': '#0A165D', #background black left pannel \n", - " 'tertiary_color': '#fff', #background grey main chat\n", - " 'text_primary_color': '#fff',\n", - " 'text_secondary_color': '#747677',\n", - " 'is_personal': False,\n", - " } \n", + " 'name': 'Naas',\n", + " 'fav_icon': '',\n", + " 'large_logo': '/assets/nass-logo-big-Bgh_HbfS.png',\n", + " 'small_logo': 'https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/Naas%20API.png',\n", + " 'primary_color': '#48DD82',\n", + " 'secondary_color': '#181a1c',\n", + " 'tertiary_color': '#3c3f40',\n", + " 'text_primary_color': '#fff',\n", + " 'text_secondary_color': '#747677',\n", + " 'is_personal': False,\n", + " } \n", "}" ] }, @@ -193,7 +193,6 @@ "source": [ "def create_workspace(\n", " api_key,\n", - " name,\n", " data,\n", "):\n", " url = \"https://api.naas.ai/workspace\"\n", @@ -204,7 +203,7 @@ " response = requests.post(url, headers=headers, json=data)\n", " return response.json()\n", "\n", - "result = create_workspace(api_key, name, data)\n", + "result = create_workspace(api_key, data)\n", "print(result)" ] }, @@ -293,4 +292,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} From 1eb1eeb7ab6fdb41616036a96d26b87508789276 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Fri, 26 Apr 2024 18:10:10 +0200 Subject: [PATCH 2/4] feat: list workspace plugin --- .../Naas_API_List_Workspace_Plugins.ipynb | 274 ++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 Naas API/Naas_API_List_Workspace_Plugins.ipynb diff --git a/Naas API/Naas_API_List_Workspace_Plugins.ipynb b/Naas API/Naas_API_List_Workspace_Plugins.ipynb new file mode 100644 index 0000000000..f989fe6a49 --- /dev/null +++ b/Naas API/Naas_API_List_Workspace_Plugins.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6a04f99a-e16e-4087-98d1-07631df5be0a", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "040f57d7-baa8-4f5c-8f00-2911825d7a42", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Naas API - List Workspace Plugins\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9afb388c-60b4-43ec-88a5-46c69cd1aef3", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #naas #api #workspace #list #plugin #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "5e796b36-0f21-49fa-83e2-637df65868dd", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "7c29836b-87f1-47f4-8f31-dc7b844b8bfa", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-03-28 (Created: 2024-03-28)" + ] + }, + { + "cell_type": "markdown", + "id": "beccc4e5-d064-4b06-94bc-23786b1a0385", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook demonstrates how to list workspace plugins using the Naas API." + ] + }, + { + "cell_type": "markdown", + "id": "a3b9a052-36ce-45b8-a776-a090f34a3c04", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [Naas API Documentation](https://api.naas.ai/redoc#tag/Workspace-API/operation/list_workspace_plugins_workspace__workspace_id__plugin_get)\n", + "- [Naas Official Website](https://naas.ai/)" + ] + }, + { + "cell_type": "markdown", + "id": "a2107faa-0d01-45ad-a74d-a7b6937bb296", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "f7957d06-6d17-40d1-b5ec-b4cac0be6831", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c6184bb-dae6-4cb0-9cbe-26753bbb2f69", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import naas\n", + "import json" + ] + }, + { + "cell_type": "markdown", + "id": "0beb4f2a-8564-48ae-a6c1-f9411ab60150", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Naas API key.\n", + "- `workspace_id`: Workspace ID." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1e100cb-681b-4723-bc4b-864890b082f0", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = naas.secret.get('NAAS_API_TOKEN')\n", + "workspace_id = \"01b19929-d904-4e59-bc6d-4ec728534cb8\"" + ] + }, + { + "cell_type": "markdown", + "id": "d88be66d-4656-48dd-9403-4ed1d2723095", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "b9fa7620-5ae2-4f1e-8345-89e5f8141944", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### List Workspace plugins" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72edcd3b-ab9c-4e39-9d53-f4698404d578", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "def list_workspace_plugins(\n", + " api_key,\n", + " workspace_id,\n", + "):\n", + " url = f\"https://api.naas.ai/workspace/{workspace_id}/plugin\"\n", + " headers = {\n", + " \"Content-Type\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_key}\"\n", + " }\n", + " response = requests.get(url, headers=headers)\n", + " return response.json()\n", + "\n", + "results = list_workspace_plugins(api_key, workspace_id)\n", + "print(\"Results:\", len(results.get('workspace_plugins')))" + ] + }, + { + "cell_type": "markdown", + "id": "ea210872-cf05-404e-9594-74c0321d2a61", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0eac2556-b0f0-446c-947d-86931508243b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7268aac3-8000-4ab8-a1fc-694e2081b08c", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "for result in results.get('workspace_plugins'):\n", + " uid = result.get(\"id\")\n", + " workspace_id = result.get(\"workspace_id\")\n", + " payload = json.loads(result.get(\"payload\"))\n", + " name = payload.get(\"name\")\n", + " print(f\"- {name} - {uid} (workspace id: {workspace_id})\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.9.6" + }, + "naas": { + "notebook_id": "17018fb5c65fbd665ae64d41f5950100a4f95e5f1759728f084901da02cb8ae4", + "notebook_path": "Naas API/Naas_API_List_Workspace_Users.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.5.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 24d0b5d378e0bcc6d8a2cb759c583f29d5cb667b Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Fri, 26 Apr 2024 18:21:59 +0200 Subject: [PATCH 3/4] feat: delete workspace plugin --- .../Naas_API_Delete_Workspace_Plugin.ipynb | 272 ++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 Naas API/Naas_API_Delete_Workspace_Plugin.ipynb diff --git a/Naas API/Naas_API_Delete_Workspace_Plugin.ipynb b/Naas API/Naas_API_Delete_Workspace_Plugin.ipynb new file mode 100644 index 0000000000..789f2283e2 --- /dev/null +++ b/Naas API/Naas_API_Delete_Workspace_Plugin.ipynb @@ -0,0 +1,272 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6a04f99a-e16e-4087-98d1-07631df5be0a", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "040f57d7-baa8-4f5c-8f00-2911825d7a42", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Naas API - Delete Workspace Plugin\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9afb388c-60b4-43ec-88a5-46c69cd1aef3", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #naas #api #workspace #plugin #delete #python #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "5e796b36-0f21-49fa-83e2-637df65868dd", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "7c29836b-87f1-47f4-8f31-dc7b844b8bfa", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-04-04 (Created: 2024-04-04)" + ] + }, + { + "cell_type": "markdown", + "id": "beccc4e5-d064-4b06-94bc-23786b1a0385", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook demonstrates how to delete a workspace's plugin using the Naas API." + ] + }, + { + "cell_type": "markdown", + "id": "a3b9a052-36ce-45b8-a776-a090f34a3c04", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [Naas API Documentation](https://api.naas.ai/redoc#tag/Workspace-API/operation/delete_workspace_plugin_workspace__workspace_id__plugin__plugin_id__delete)\n", + "- [Naas Official Website](https://naas.ai/)" + ] + }, + { + "cell_type": "markdown", + "id": "a2107faa-0d01-45ad-a74d-a7b6937bb296", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "f7957d06-6d17-40d1-b5ec-b4cac0be6831", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c6184bb-dae6-4cb0-9cbe-26753bbb2f69", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import naas\n", + "import json" + ] + }, + { + "cell_type": "markdown", + "id": "0beb4f2a-8564-48ae-a6c1-f9411ab60150", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Naas API key.\n", + "- `workspace_id`: Workspace ID.\n", + "- `plugin_id`: Plugin ID." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1e100cb-681b-4723-bc4b-864890b082f0", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = naas.secret.get('NAAS_API_TOKEN')\n", + "workspace_id = \"01b19929-d904-4e59-bc6d-4ec728534cb8\"\n", + "plugin_id = \"e5bad22c-a29f-40ff-81a6-badb22cdb342\"" + ] + }, + { + "cell_type": "markdown", + "id": "d88be66d-4656-48dd-9403-4ed1d2723095", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "b9fa7620-5ae2-4f1e-8345-89e5f8141944", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Delete Workspace plugin" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72edcd3b-ab9c-4e39-9d53-f4698404d578", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "def delete_workspace_plugin(\n", + " api_key,\n", + " workspace_id,\n", + " plugin_id,\n", + "):\n", + " url = f\"https://api.naas.ai/workspace/{workspace_id}/plugin/{plugin_id}\"\n", + " headers = {\n", + " \"Content-Type\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_key}\"\n", + " }\n", + " response = requests.delete(url, headers=headers)\n", + " return response.json()\n", + "\n", + "result = delete_workspace_plugin(api_key, workspace_id, plugin_id)\n", + "print(result)" + ] + }, + { + "cell_type": "markdown", + "id": "ea210872-cf05-404e-9594-74c0321d2a61", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0eac2556-b0f0-446c-947d-86931508243b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7268aac3-8000-4ab8-a1fc-694e2081b08c", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "result" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.9.6" + }, + "naas": { + "notebook_id": "17018fb5c65fbd665ae64d41f5950100a4f95e5f1759728f084901da02cb8ae4", + "notebook_path": "Naas API/Naas_API_List_Workspace_Users.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.5.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From b8d612ccd06fab3ed6df98fb1720eda1ed75d06b Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Fri, 26 Apr 2024 18:27:14 +0200 Subject: [PATCH 4/4] feat: create workspace plugin --- .../Naas_API_Create_Workspace_Plugin.ipynb | 340 ++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 Naas API/Naas_API_Create_Workspace_Plugin.ipynb diff --git a/Naas API/Naas_API_Create_Workspace_Plugin.ipynb b/Naas API/Naas_API_Create_Workspace_Plugin.ipynb new file mode 100644 index 0000000000..2ffa4bac70 --- /dev/null +++ b/Naas API/Naas_API_Create_Workspace_Plugin.ipynb @@ -0,0 +1,340 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6a04f99a-e16e-4087-98d1-07631df5be0a", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "040f57d7-baa8-4f5c-8f00-2911825d7a42", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Naas API - Create Workspace Plugin\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9afb388c-60b4-43ec-88a5-46c69cd1aef3", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #naas #api #workspace #create #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "5e796b36-0f21-49fa-83e2-637df65868dd", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "7c29836b-87f1-47f4-8f31-dc7b844b8bfa", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-04-25 (Created: 2024-03-28)" + ] + }, + { + "cell_type": "markdown", + "id": "beccc4e5-d064-4b06-94bc-23786b1a0385", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook demonstrates how to create a workspace plugin using the Naas API." + ] + }, + { + "cell_type": "markdown", + "id": "a3b9a052-36ce-45b8-a776-a090f34a3c04", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [Naas API Documentation](https://api.naas.ai/redoc#tag/Workspace-API/operation/create_workspace_plugin_workspace__workspace_id__plugin_post)\n", + "- [Naas Official Website](https://naas.ai/)" + ] + }, + { + "cell_type": "markdown", + "id": "a2107faa-0d01-45ad-a74d-a7b6937bb296", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "f7957d06-6d17-40d1-b5ec-b4cac0be6831", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c6184bb-dae6-4cb0-9cbe-26753bbb2f69", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import naas\n", + "import json" + ] + }, + { + "cell_type": "markdown", + "id": "0beb4f2a-8564-48ae-a6c1-f9411ab60150", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Naas API key.\n", + "- `workspace_id`: Workspace ID.\n", + "- `personal_workspace`: Boolean to send plugin to Personal workspace.\n", + "- `plugin`: Plugin JSON." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1e100cb-681b-4723-bc4b-864890b082f0", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = naas.secret.get('NAAS_API_TOKEN')\n", + "workspace_id = None\n", + "personal_workspace = True\n", + "plugin = {\n", + " 'name': 'Content Assistant',\n", + " 'model': 'gpt-4-1106-preview',\n", + " 'temperature': 0.5,\n", + " 'max_tokens': 128000,\n", + " 'prompt': \"Act as a Content Assistant who has access to valuable data and insights about the content strategy.\",\n", + " 'commands': [],\n", + " 'description': \"Streamline the generation and distribution of content that aligns with the user's or business's brand voice and audience engagement goals.\",\n", + " 'avatar': 'https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/content_creation.png',\n", + " 'prompt_type': 'system',\n", + " 'slug': 'content-assistant/test',\n", + " 'id': 'content-assistant',\n", + " 'url': ''\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "d88be66d-4656-48dd-9403-4ed1d2723095", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "e952a778-1800-443f-9053-43dd356e38b9", + "metadata": {}, + "source": [ + "### Get workspace ID" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "810e02eb-5578-4c50-bb53-4ce9d5dec2ee", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def list_workspaces(\n", + " api_key,\n", + "):\n", + " url = \"https://api.naas.ai/workspace/\"\n", + " headers = {\n", + " \"Content-Type\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_key}\"\n", + " }\n", + " response = requests.get(url, headers=headers)\n", + " return response.json()\n", + "\n", + "# If not workspace ID, we get the personal workspace ID\n", + "if workspace_id is None and personal_workspace:\n", + " result = list_workspaces(api_key)\n", + " if len(result) > 0:\n", + " for workspace in result.get(\"workspaces\"):\n", + " is_personal = workspace.get(\"is_personal\")\n", + " workspace_id = workspace.get(\"id\")\n", + " if is_personal:\n", + " break\n", + " \n", + "print(f\"Workspace ID: {workspace_id}\")" + ] + }, + { + "cell_type": "markdown", + "id": "b9fa7620-5ae2-4f1e-8345-89e5f8141944", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Create Workspace Plugin" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72edcd3b-ab9c-4e39-9d53-f4698404d578", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "def create_workspace_plugin(\n", + " api_key,\n", + " workspace_id,\n", + " plugin,\n", + "):\n", + " url = f\"https://api.naas.ai/workspace/{workspace_id}/plugin\"\n", + " headers = {\n", + " \"Content-Type\": \"application/json\",\n", + " \"Authorization\": f\"Bearer {api_key}\"\n", + " }\n", + " data = {\n", + " \"workspace_id\": workspace_id,\n", + " \"payload\": json.dumps(plugin),\n", + " }\n", + " response = requests.post(url, headers=headers, json=data)\n", + " return response.json()\n", + "\n", + "result = create_workspace_plugin(api_key, workspace_id, plugin)\n", + "print(result.get('workspace_plugin'))" + ] + }, + { + "cell_type": "markdown", + "id": "ea210872-cf05-404e-9594-74c0321d2a61", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0eac2556-b0f0-446c-947d-86931508243b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7268aac3-8000-4ab8-a1fc-694e2081b08c", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5019b530-3337-4b05-b426-5587b4c2d5f6", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.9.6" + }, + "naas": { + "notebook_id": "17018fb5c65fbd665ae64d41f5950100a4f95e5f1759728f084901da02cb8ae4", + "notebook_path": "Naas API/Naas_API_List_Workspace_Users.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.5.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}