diff --git a/Naas Credits/Naas_Credits_Export_current_transactions_to_Excel.ipynb b/Naas Credits/Naas_Credits_Export_current_transactions_to_Excel.ipynb
new file mode 100644
index 0000000000..9242a90dce
--- /dev/null
+++ b/Naas Credits/Naas_Credits_Export_current_transactions_to_Excel.ipynb
@@ -0,0 +1,282 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "168abe1a-0f00-446c-bd08-74b5cb43c4a4",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d42f1fdd-8fd8-4213-8e15-78f6281e6344",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "# Naas Credits - Export current transactions to Excel"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "09160566-d6dd-4912-8aa4-df8f40036d72",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "**Tags:** #naascredits #export #transaction #current #excel #naas"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "026cfb17-7b38-4ebb-ae40-8147b11a6ab6",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cfe15482-7cfe-4de2-a83f-e91aeffa3e3c",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "**Last update:** 2023-12-21 (Created: 2023-12-21)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "fce74c2a-914f-47d8-acef-dadce3d4da59",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "**Description:** This notebook will export your current transactions (transactions done this month) from Naas Credits API and save it to an Excel file."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2c60ac49-a891-462d-86ae-5890bb801ab8",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "**References:**\n",
+ "- [Naas Credits driver](https://github.com/jupyter-naas/drivers/blob/main/naas_drivers/tools/naas_credits.py)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1de76aea-f175-4f80-b0de-f827518a47b6",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "## Input"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0eab4379-7117-468a-86e9-5ec4701d1a00",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "### Import libraries"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "7f994733-0621-4cce-8fda-f1a3cc2ee3d2",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "from naas_drivers import naascredits\n",
+ "from datetime import datetime\n",
+ "import pandas as pd"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "35b0528a-1021-4cfc-8363-03ecbb0dd08a",
+ "metadata": {},
+ "source": [
+ "### Setup variables\n",
+ "- `file_path`: Excel file path to be saved in your local env."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d0ac086d-1dba-4bbf-a692-f7bf0832f24e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "file_path = f\"{datetime.now().isoformat()}_currents_transactions.xlsx\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3af3ebc4-3b52-4cc4-8974-3d222a1cb0b1",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "## Model"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9445fab9-f0ac-4af5-b3d3-d4990137f9d4",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "### Get current transaction"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "06a55817-cb91-4f9f-ae7e-25595be18237",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "data = naascredits.connect().transactions.get_currents()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "30a1a7a6-5121-4c76-859e-00e0ea6cb364",
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2023-12-21T08:53:33.705308Z",
+ "iopub.status.busy": "2023-12-21T08:53:33.705055Z",
+ "iopub.status.idle": "2023-12-21T08:53:33.708305Z",
+ "shell.execute_reply": "2023-12-21T08:53:33.707644Z",
+ "shell.execute_reply.started": "2023-12-21T08:53:33.705284Z"
+ },
+ "tags": []
+ },
+ "source": [
+ "### Convert data to DataFrame"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "eb2a040e-dd00-4afa-933b-9ea2497d83dc",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "df = pd.DataFrame(data)\n",
+ "print(\"Current balance:\", df.CREDIT.sum())"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "775fe31b-d335-4b03-92e5-ed11f25f953e",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "## Output"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9e8ea457-99a5-40ff-ac9b-28f195511068",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "source": [
+ "### Save data to Excel file"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "bc039287-6129-4f0b-8966-80bb8985b989",
+ "metadata": {
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "df.to_excel(\n",
+ " file_path,\n",
+ " sheet_name=\"Export\",\n",
+ " index=False,\n",
+ ")\n",
+ "print(f\"Excel file successfully saved: {file_path}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e71dce99-777c-476f-98c6-81ac62025df2",
+ "metadata": {
+ "papermill": {},
+ "tags": []
+ },
+ "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"
+ },
+ "widgets": {
+ "application/vnd.jupyter.widget-state+json": {
+ "state": {},
+ "version_major": 2,
+ "version_minor": 0
+ }
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/Naas/Naas_Credits_Get_Balance.ipynb b/Naas Credits/Naas_Credits_Get_Balance.ipynb
similarity index 95%
rename from Naas/Naas_Credits_Get_Balance.ipynb
rename to Naas Credits/Naas_Credits_Get_Balance.ipynb
index cebf8386e9..81fa0bd531 100644
--- a/Naas/Naas_Credits_Get_Balance.ipynb
+++ b/Naas Credits/Naas_Credits_Get_Balance.ipynb
@@ -26,7 +26,7 @@
"tags": []
},
"source": [
- "# Naas - Credits Get Balance\n",
+ "# Naas Credits - Get Balance\n",
"
Give Feedback | Bug report"
]
},
@@ -60,7 +60,7 @@
"tags": []
},
"source": [
- "**Last update:** 2023-04-12 (Created: 2021-11-17)"
+ "**Last update:** 2023-12-21 (Created: 2021-11-17)"
]
},
{
@@ -130,7 +130,7 @@
"tags": []
},
"source": [
- "### Function"
+ "### Get balance"
]
},
{
@@ -143,7 +143,8 @@
},
"outputs": [],
"source": [
- "balance = naascredits.connect().get_balance()"
+ "balance = naascredits.connect().get_balance()\n",
+ "print(balance)"
]
},
{
@@ -205,7 +206,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.8"
+ "version": "3.9.6"
},
"naas": {
"notebook_id": "b8e8498be8e2a6e4ed47256dd6b987fc934f372db1ce9b0ba198bd19514296ca",
@@ -227,4 +228,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
-}
\ No newline at end of file
+}
diff --git a/Naas/Naas_Get_Transactions.ipynb b/Naas Credits/Naas_Credits_Get_current_transactions.ipynb
similarity index 88%
rename from Naas/Naas_Get_Transactions.ipynb
rename to Naas Credits/Naas_Credits_Get_current_transactions.ipynb
index c8186865bd..824a48f547 100644
--- a/Naas/Naas_Get_Transactions.ipynb
+++ b/Naas Credits/Naas_Credits_Get_current_transactions.ipynb
@@ -26,7 +26,7 @@
"tags": []
},
"source": [
- "# Naas - Get Transactions\n",
+ "# Naas Credits - Get Transactions\n",
"
Give Feedback | Bug report"
]
},
@@ -60,7 +60,7 @@
"tags": []
},
"source": [
- "**Last update:** 2023-04-12 (Created: 2021-11-17)"
+ "**Last update:** 2023-12-21 (Created: 2021-11-17)"
]
},
{
@@ -112,30 +112,6 @@
"import pandas as pd"
]
},
- {
- "cell_type": "markdown",
- "id": "306bd842-b936-4eed-a173-f49dfdd09687",
- "metadata": {
- "papermill": {},
- "tags": []
- },
- "source": [
- "### Variables"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "782b2a2b-ca0b-45e1-823f-c3abf3ac43cf",
- "metadata": {
- "papermill": {},
- "tags": []
- },
- "outputs": [],
- "source": [
- "page_size = \"100000\""
- ]
- },
{
"cell_type": "markdown",
"id": "registered-showcase",
@@ -155,7 +131,7 @@
"tags": []
},
"source": [
- "### Function"
+ "### Get transactions"
]
},
{
@@ -168,8 +144,9 @@
},
"outputs": [],
"source": [
- "df = pd.DataFrame(naascredits.connect().transactions.get(page_size=page_size))\n",
- "df"
+ "df = pd.DataFrame(naascredits.connect().transactions.get_currents())\n",
+ "print(len(df))\n",
+ "print(\"Current balance:\", df.CREDIT.sum())"
]
},
{
@@ -211,7 +188,7 @@
},
"outputs": [],
"source": [
- "df.to_csv(\"billing.csv\")"
+ "df"
]
}
],
@@ -231,7 +208,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.8"
+ "version": "3.9.6"
},
"naas": {
"notebook_id": "5df9412ae66fd7ab475df0c83cd5f8a2f36ca695bb4292dd5433aded3dc2e890",
@@ -253,4 +230,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
-}
\ No newline at end of file
+}