diff --git a/Trello/Trello_Create_Card.ipynb b/Trello/Trello_Create_Card.ipynb index 0e56a7f7f4..0d1f31f2cb 100644 --- a/Trello/Trello_Create_Card.ipynb +++ b/Trello/Trello_Create_Card.ipynb @@ -53,7 +53,7 @@ "tags": [] }, "source": [ - "**Last update:** 2023-07-14 (Created: 2023-07-14)" + "**Last update:** 2023-10-16 (Created: 2023-07-14)" ] }, { @@ -103,9 +103,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "e313ed44-19d7-4ea2-97f4-decbc0809508", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:33:06.764389Z", + "iopub.status.busy": "2023-10-16T07:33:06.764161Z", + "iopub.status.idle": "2023-10-16T07:33:06.768954Z", + "shell.execute_reply": "2023-10-16T07:33:06.768366Z", + "shell.execute_reply.started": "2023-10-16T07:33:06.764366Z" + }, "papermill": {}, "tags": [] }, @@ -126,16 +133,23 @@ "### Setup Variables\n", "- `api_key`: Your Trello API key. [Get your API key here](https://github.com/Benjifilly/My_notebooks/wiki/How-to-obtain-an-API-key-for-Trello)\n", "- `force_update`: Parameters to enforce the token update\n", - "- `board_id`: The ID of the board you want to create the card in.\n", - "- `list_id`: The ID of the list you want to create the card in, Use this template to find the ID:

\"Trello - Retrieve list id\"

\n", + "- `board_id`: The ID of the board where you want to create the card. Use this template to find the ID: \"Trello/Trello_List_Boards.ipynb\"\n", + "- `list_id`: The ID of the list where you want to create the card. Use this template to find the ID: \"Trello/Trello_Get_Lists_on_a_Board.ipynb\"\n", "- `card_details`: is a list that contains dictionaries representing the name and description of cards to be created on the Trello board." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "ef678151-5b31-4645-8d92-e8f624472ca6", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:33:07.559742Z", + "iopub.status.busy": "2023-10-16T07:33:07.559511Z", + "iopub.status.idle": "2023-10-16T07:33:07.696857Z", + "shell.execute_reply": "2023-10-16T07:33:07.696153Z", + "shell.execute_reply.started": "2023-10-16T07:33:07.559717Z" + }, "papermill": {}, "tags": [] }, @@ -143,8 +157,8 @@ "source": [ "api_key = naas.secret.get(\"TRELLO_API_KEY\") or \"YOUR_TRELLO_API_KEY\"\n", "force_update = False\n", - "board_id = \"ogBhOe9a\" #Example: \"https://trello.com/b/ogBhOe9a/ultimate-to-do-list\"\n", - "list_id = \"649d8b3c9f796ee9d57a765d\" #Example: \"649d8b3c9f796ee9d57a765d\"\n", + "board_id = \"64a19089d2740e7042011f55\"\n", + "list_id = \"64a1908a014235fd7b94aafe\"\n", "\n", "#Example with several cards\n", "card_details = [\n", @@ -179,9 +193,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "98147739-b010-4936-8205-552412504d39", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:33:08.788184Z", + "iopub.status.busy": "2023-10-16T07:33:08.787946Z", + "iopub.status.idle": "2023-10-16T07:33:08.929960Z", + "shell.execute_reply": "2023-10-16T07:33:08.929304Z", + "shell.execute_reply.started": "2023-10-16T07:33:08.788159Z" + }, "papermill": {}, "tags": [] }, @@ -225,9 +246,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "56d84ea9-48e7-4642-96d2-9999eaf33f02", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:33:09.780469Z", + "iopub.status.busy": "2023-10-16T07:33:09.780162Z", + "iopub.status.idle": "2023-10-16T07:33:09.789629Z", + "shell.execute_reply": "2023-10-16T07:33:09.788965Z", + "shell.execute_reply.started": "2023-10-16T07:33:09.780434Z" + }, "papermill": {}, "tags": [] }, @@ -274,13 +302,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "79ca43a4-b149-4b21-b73e-384f383e0955", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:33:12.398606Z", + "iopub.status.busy": "2023-10-16T07:33:12.398353Z", + "iopub.status.idle": "2023-10-16T07:33:13.484942Z", + "shell.execute_reply": "2023-10-16T07:33:13.484203Z", + "shell.execute_reply.started": "2023-10-16T07:33:12.398569Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Card Created:\n", + "πŸ†” ID: 652ce73895823f12c4c8d699\n", + "- Name: Call at 9:00 PM this Monday\n", + "- Description: Don't forget to do this call, it's very important\n", + "--------------------\n", + "βœ… Card Created:\n", + "πŸ†” ID: 652ce738cfae8bbb75818cf2\n", + "- Name: Meeting with the team\n", + "- Description: Discuss project updates and action items\n", + "--------------------\n", + "βœ… Card Created:\n", + "πŸ†” ID: 652ce7398a9cf85a98e68af5\n", + "- Name: Send report to the client\n", + "- Description: Include sales figures and recommendations\n", + "--------------------\n" + ] + } + ], "source": [ "for card_info in card_details:\n", " card = create_card(api_key, token, board_id, list_id, card_info[\"name\"], card_info[\"desc\"])\n", @@ -294,6 +351,14 @@ " print(\"❌ Failed to create card.\")\n", " print(\"--------------------\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0b026e17-0465-4f97-a078-80227582b604", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -334,4 +399,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/Trello/Trello_Get_Lists_on_a_Board.ipynb b/Trello/Trello_Get_Lists_on_a_Board.ipynb index 79e7dfbaeb..9bc69bb018 100644 --- a/Trello/Trello_Get_Lists_on_a_Board.ipynb +++ b/Trello/Trello_Get_Lists_on_a_Board.ipynb @@ -55,7 +55,7 @@ "tags": [] }, "source": [ - "**Last update:** 2023-07-14 (Created: 2023-07-14)" + "**Last update:** 2023-10-16 (Created: 2023-07-14)" ] }, { @@ -107,9 +107,16 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 6, "id": "supreme-westminster", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:32:16.931492Z", + "iopub.status.busy": "2023-10-16T07:32:16.931253Z", + "iopub.status.idle": "2023-10-16T07:32:16.934355Z", + "shell.execute_reply": "2023-10-16T07:32:16.933711Z", + "shell.execute_reply.started": "2023-10-16T07:32:16.931466Z" + }, "papermill": {}, "tags": [] }, @@ -140,14 +147,21 @@ "source": [ "- `api_key`: Your Trello API key. [Get your API key here](https://github.com/Benjifilly/My_notebooks/wiki/How-to-obtain-an-API-key-for-Trello)\n", "- `force_update`: Parameters to enforce the token update\n", - "- `board_id`: The unique identifier of the Trello board you want to work with." + "- `board_id`: The unique identifier of the Trello board you want to work with. Use this template to find the ID: \"Trello/Trello_List_Boards.ipynb\"" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 7, "id": "tender-albany", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:32:17.840428Z", + "iopub.status.busy": "2023-10-16T07:32:17.840203Z", + "iopub.status.idle": "2023-10-16T07:32:17.962957Z", + "shell.execute_reply": "2023-10-16T07:32:17.962240Z", + "shell.execute_reply.started": "2023-10-16T07:32:17.840404Z" + }, "papermill": {}, "tags": [] }, @@ -155,7 +169,7 @@ "source": [ "api_key = naas.secret.get(\"TRELLO_API_KEY\") or \"YOUR_TRELLO_API_KEY\"\n", "force_update = False\n", - "board_id = \"ogBhOe9a\" #example: \"https://trello.com/b/ogBhOe9a/ultimate-to-do-list\" " + "board_id = \"64a19089d2740e7042011f55\"" ] }, { @@ -183,9 +197,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 8, "id": "96e73242-c286-4413-8d69-825ad7391584", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:32:19.197135Z", + "iopub.status.busy": "2023-10-16T07:32:19.196728Z", + "iopub.status.idle": "2023-10-16T07:32:19.321838Z", + "shell.execute_reply": "2023-10-16T07:32:19.320934Z", + "shell.execute_reply.started": "2023-10-16T07:32:19.197097Z" + }, "papermill": {}, "tags": [] }, @@ -219,9 +240,16 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 9, "id": "6ad17a5c-689b-4c43-9630-3765e3d0e239", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:32:20.300182Z", + "iopub.status.busy": "2023-10-16T07:32:20.299955Z", + "iopub.status.idle": "2023-10-16T07:32:20.520727Z", + "shell.execute_reply": "2023-10-16T07:32:20.520139Z", + "shell.execute_reply.started": "2023-10-16T07:32:20.300158Z" + }, "papermill": {}, "tags": [] }, @@ -255,13 +283,36 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 10, "id": "73bd6ede-4b47-465f-8c71-3d3caa3e7dce", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:32:21.894538Z", + "iopub.status.busy": "2023-10-16T07:32:21.894203Z", + "iopub.status.idle": "2023-10-16T07:32:21.913306Z", + "shell.execute_reply": "2023-10-16T07:32:21.910751Z", + "shell.execute_reply.started": "2023-10-16T07:32:21.894494Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“‹ \u001b[1mList Title:\u001b[0m Γ€ faire\n", + "πŸ†” \u001b[1mList ID:\u001b[0m 64a1908a014235fd7b94aafe\n", + "------------------------\n", + "πŸ“‹ \u001b[1mList Title:\u001b[0m En cours\n", + "πŸ†” \u001b[1mList ID:\u001b[0m 64a1908ab6205111b631b83d\n", + "------------------------\n", + "πŸ“‹ \u001b[1mList Title:\u001b[0m TerminΓ©\n", + "πŸ†” \u001b[1mList ID:\u001b[0m 64a1908a227da437458e2e99\n", + "------------------------\n" + ] + } + ], "source": [ "if response.status_code == 200:\n", " lists = response.json()\n", @@ -272,6 +323,14 @@ "else:\n", " print(\"❌ Failed to fetch lists.\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "74f65e9e-46b8-4887-89b2-2d1283fc51b1", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -305,4 +364,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/Trello/Trello_List_Boards.ipynb b/Trello/Trello_List_Boards.ipynb index 8e2f161b92..383e8a937c 100644 --- a/Trello/Trello_List_Boards.ipynb +++ b/Trello/Trello_List_Boards.ipynb @@ -53,7 +53,7 @@ "tags": [] }, "source": [ - "**Last update:** 2023-07-11 (Created: 2023-07-11)" + "**Last update:** 2023-10-16 (Created: 2023-07-11)" ] }, { @@ -247,13 +247,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "b5e17a25-dcf7-4e5f-93c9-359ee24c174a", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-16T07:30:22.622220Z", + "iopub.status.busy": "2023-10-16T07:30:22.621911Z", + "iopub.status.idle": "2023-10-16T07:30:22.629653Z", + "shell.execute_reply": "2023-10-16T07:30:22.629012Z", + "shell.execute_reply.started": "2023-10-16T07:30:22.622190Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“š You have 1 board(s) in Trello:\n", + "---------------------------------\n", + "πŸ“Œ Naas Onboarding (ID: 64a19089d2740e7042011f55)\n" + ] + } + ], "source": [ "# Check if the request was successful\n", "if response.status_code == 200:\n", @@ -268,7 +285,8 @@ " # Iterate over the boards and print their names\n", " for board in boards:\n", " board_name = board['name']\n", - " print(f\"πŸ“Œ {board_name}\")\n", + " board_id = board['id']\n", + " print(f\"πŸ“Œ {board_name} (ID: {board_id})\")\n", "else:\n", " print(f\"⚠️ Error: {response.status_code} - {response.text}\")" ] @@ -323,4 +341,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/Trello/Trello_Update_Cards.ipynb b/Trello/Trello_Update_Cards.ipynb new file mode 100644 index 0000000000..2f226236a0 --- /dev/null +++ b/Trello/Trello_Update_Cards.ipynb @@ -0,0 +1,315 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e3f41c66-54b7-4f06-9881-9a9991bf43d1", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "dbc4cf57-1769-4639-bc72-0377bb682bf5", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Trello - Update Cards\n", + "

Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "68643b1f-e196-4735-9600-3add8344d37b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #trello #api #rest #cards #board #get" + ] + }, + { + "cell_type": "markdown", + "id": "7b82329c-d291-44d0-82c0-0bebabe140d4", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Benjamin Filly](https://www.linkedin.com/in/benjamin-filly-05427727a/)" + ] + }, + { + "cell_type": "markdown", + "id": "40e48172-1cbf-438e-bac7-e47d21927f6b", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-10-16 (Created: 2023-10-12)" + ] + }, + { + "cell_type": "markdown", + "id": "fe2e4742-dfa5-4b0f-9377-de233c19eff9", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook show you how to update the title, description, due, position of a card in Trello using API" + ] + }, + { + "cell_type": "markdown", + "id": "52215a73-6d34-40cd-910a-4dc489a8ff2e", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n", + "- [Trello API Documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-cards-get)\n", + "- [Trello API Authentication](https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/#authentication)" + ] + }, + { + "cell_type": "markdown", + "id": "19b038d9-985e-4c4f-873b-77a79b201d8d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "150e31ef-a043-4e0f-8544-6f6f74c13a89", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d88d11ca-f19a-4808-a420-553bfed562f6", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import naas" + ] + }, + { + "cell_type": "markdown", + "id": "de74bd41-9051-4865-b9b2-2de71c4ce874", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup Variables\n", + "- `api_key`: Your Trello API key. [Get your API key here](https://github.com/Benjifilly/My_notebooks/wiki/How-to-obtain-an-API-key-for-Trello)\n", + "- `force_update`: Parameters to enforce the token update\n", + "- `board_id`: The ID of the board you want to get the cards from. Use this template to find the ID: \"Trello/Trello_List_Boards.ipynb\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "676d453f-1689-4017-a9e2-ac206aa351fa", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = naas.secret.get(\"TRELLO_API_KEY\") or \"YOUR_TRELLO_API_KEY\"\n", + "force_update = False\n", + "board_id = \"64a19089d2740e7042011f55\"\n", + "card_id = \"652ce73895823f12c4c8d699\" \n", + "update_data = {\n", + " \"name\": \"New Card Name\",\n", + " \"desc\": \"New Card Description\",\n", + " \"due\": \"2024-08-30T10:00:00.000Z\", # Due date (use ISO 8601 format)\n", + " \"pos\": \"bottom\", # Position (top, bottom)\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "9ce89c21-dfc0-4ba2-b2eb-44fbac519ad7", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "2afd2bc7-5f4f-4522-8167-989ebeabb3f2", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Get your token\n", + "Your Trello token will be stored on naas secret name: \"TRELLO_TOKEN\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e6af4a71-dce1-4a88-82e8-dad9a0effefd", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "def get_token(api_key, force_update):\n", + " token = naas.secret.get(\"TRELLO_TOKEN\")\n", + " if not token or force_update:\n", + " url = f\"https://trello.com/1/authorize?expiration=never&scope=read,write,account&response_type=token&key={api_key}\"\n", + " print(f\"πŸ”— Click on the URL to get your token: {url}\")\n", + " print(\"βœ… On the authorization page, click on 'Authorize' button at the bottom of the page to proceed.\")\n", + " print(\"πŸ’Ύ Copy/Paste the token in red in the input case below\")\n", + " token = input(\"-> Enter your token here:\")\n", + " naas.secret.add(\"TRELLO_TOKEN\", token)\n", + " return token\n", + " \n", + "token = get_token(api_key, force_update)" + ] + }, + { + "cell_type": "markdown", + "id": "6d1bc995-19c6-43ce-8405-d8a3ee68681c", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Get Cards on a Board" + ] + }, + { + "cell_type": "markdown", + "id": "9300ff09-fafb-478a-aee3-4ad54dccdfbb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "This function will get all of the open Cards on a Board." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "005bd319-f1ba-45bf-9733-d10d31776b55", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "update_url = f\"https://api.trello.com/1/cards/{card_id}?key={api_key}&token={token}\"\n", + "response = requests.put(update_url, data=update_data)" + ] + }, + { + "cell_type": "markdown", + "id": "18efd886-0c30-4444-8d45-348f41886e1d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "38d40391-d1f4-4acd-b272-1d1a1dcb46d1", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "73be94a3-b8b8-4bc6-a898-00d16ddaedd9", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "if response.status_code == 200:\n", + " print(\"Card successfully updated βœ…\")\n", + "else:\n", + " print(\"❌ Failed to update the card. Status code:\", response.status_code)" + ] + } + ], + "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": "171b2e70749cf7235cefd7b019c057afa2196c1cdfdb0127320915d7609c3fc6", + "notebook_path": "Trello/Trello_Get_Cards_on_a_Board.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.4.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}