From e828dc671c3365ab44cf3a660f6aad3a463230c9 Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Tue, 2 Jul 2024 08:58:47 +0200 Subject: [PATCH] fix: split storage notebooks --- Naas API/Naas_API_Create_Storage.ipynb | 231 +++++++++++++++++ Naas API/Naas_API_Create_Storage_Object.ipynb | 242 +++++++++++++++++ Naas API/Naas_API_Delete_Storage.ipynb | 225 ++++++++++++++++ Naas API/Naas_API_Delete_Storage_Object.ipynb | 238 +++++++++++++++++ Naas API/Naas_API_Get_Storage_Object.ipynb | 242 +++++++++++++++++ Naas API/Naas_API_List_Storage.ipynb | 233 +++++++++++++++++ Naas API/Naas_API_List_Storage_Object.ipynb | 244 ++++++++++++++++++ 7 files changed, 1655 insertions(+) create mode 100644 Naas API/Naas_API_Create_Storage.ipynb create mode 100644 Naas API/Naas_API_Create_Storage_Object.ipynb create mode 100644 Naas API/Naas_API_Delete_Storage.ipynb create mode 100644 Naas API/Naas_API_Delete_Storage_Object.ipynb create mode 100644 Naas API/Naas_API_Get_Storage_Object.ipynb create mode 100644 Naas API/Naas_API_List_Storage.ipynb create mode 100644 Naas API/Naas_API_List_Storage_Object.ipynb diff --git a/Naas API/Naas_API_Create_Storage.ipynb b/Naas API/Naas_API_Create_Storage.ipynb new file mode 100644 index 0000000000..ce6e985fd3 --- /dev/null +++ b/Naas API/Naas_API_Create_Storage.ipynb @@ -0,0 +1,231 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - Create Storage\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #create" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-01 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** This notebook demonstrates how to create a Workspace Storage. A Workspace storage is the root of your data directory to set access permission." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID\n", + "* `storage_name` : User Storage name to create" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "storage_name = \"test\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### Create storage" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "storage = naas_python.storage.create_workspace_storage(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + " )\n", + "storage" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "### CLI command\n", + "```sh\n", + "naas-python storage create --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage create -w 81507a26-3644-496c-a379-4c7021434aa0 -s test\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "74502426", + "metadata": {}, + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_Create_Storage_Object.ipynb b/Naas API/Naas_API_Create_Storage_Object.ipynb new file mode 100644 index 0000000000..732cb12efe --- /dev/null +++ b/Naas API/Naas_API_Create_Storage_Object.ipynb @@ -0,0 +1,242 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - Create Storage Object\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #create #object" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-02 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** This notebook demonstrates how to use send your local file into a Workspace Storage." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID\n", + "* `storage_name` : User Storage\n", + "* `src_file`: Local file to upload\n", + "* `dst_file`: Destination and name in the storage. If the directory doesn't exist it will be created." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "storage_name = \"test\"\n", + "src_file=\"Naas_API_Storage.ipynb\"\n", + "dst_file=\"directory-1/Naas_API_Storage.ipynb\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### Create Storage Object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "object = naas_python.storage.post_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + " src_file=src_file,\n", + " dst_file=dst_file\n", + ")\n", + "object" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "5162486b", + "metadata": {}, + "source": [ + "### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "```sh\n", + "naas-python storage put-object --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage put-object \\\n", + "-w 81507a26-3644-496c-a379-4c7021434aa0 \\\n", + "-s test-storage \\\n", + "-src test.txt.zip \\\n", + "-dst my-test-dir/my-object.txt.zip\n", + "```" + ] + } + ], + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_Delete_Storage.ipynb b/Naas API/Naas_API_Delete_Storage.ipynb new file mode 100644 index 0000000000..390bd90aa6 --- /dev/null +++ b/Naas API/Naas_API_Delete_Storage.ipynb @@ -0,0 +1,225 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - Delete Storage\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #delete" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-01 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** This notebook demonstrates how to delete a Workspace Storage. *Be careful* a Workspace Storage is the root of your data directory." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID\n", + "* `storage_name` : User Storage name to create" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "storage_name = \"test\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### Delete storage" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "deleted_storage = naas_python.storage.delete_workspace_storage(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + ")\n", + "deleted_storage" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "### CLI command\n", + "```sh\n", + "naas-python storage delete --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage delete -w 81507a26-3644-496c-a379-4c7021434aa0 -s test-storage\n", + "```" + ] + } + ], + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_Delete_Storage_Object.ipynb b/Naas API/Naas_API_Delete_Storage_Object.ipynb new file mode 100644 index 0000000000..61157f2e37 --- /dev/null +++ b/Naas API/Naas_API_Delete_Storage_Object.ipynb @@ -0,0 +1,238 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - Delete Storage Object\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #delete #object" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-02 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** Delete an object from your Naas Storage." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID\n", + "* `storage_name`: User Workspace Storage\n", + "* `object_name` : Path and name of the object in the Storage to delete." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "storage_name = \"test-storage\"\n", + "object_name=\"directory-1/Naas_API_Storage.ipynb\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### Delete storage object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "delete_object = naas_python.storage.delete_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + " object_name=object_name\n", + ")\n", + "delete_object" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "d2d5f77e", + "metadata": {}, + "source": [ + "### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "```sh\n", + "naas-python storage delete-object --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage delete-object \\\n", + "--workspace 81507a26-3644-496c-a379-4c7021434aa0 \\\n", + "--storage test-storage \\\n", + "--object \"my-test-dir/my-object.txt.zip\"\n", + "```" + ] + } + ], + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_Get_Storage_Object.ipynb b/Naas API/Naas_API_Get_Storage_Object.ipynb new file mode 100644 index 0000000000..c96bd45e57 --- /dev/null +++ b/Naas API/Naas_API_Get_Storage_Object.ipynb @@ -0,0 +1,242 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - Get Storage Object\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #get #object" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-02 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** Download an object from your Naas Storage." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID\n", + "* `storage_name` : User Storage\n", + "* `src_file`: File path to into the Workspace Storage to download\n", + "* `dst_file`: Download destination directory and filename on your computer" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "storage_name=\"test-storage\",\n", + "src_file=\"directory-1/Naas_API_Storage.ipynb\",\n", + "dst_file=\"local_Naas_API_Storage.ipynb\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### Get Storage Object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "get_object = naas_python.storage.get_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + " src_file=src_file,\n", + " dst_file=dst_file\n", + ")\n", + "get_object" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "bdf35940", + "metadata": {}, + "source": [ + "### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "```sh\n", + "naas-python storage get-object --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage get-object \\\n", + "--workspace 81507a26-3644-496c-a379-4c7021434aa0 \\\n", + "--storage test-storage \\\n", + "--source \"my-test-dir/my-object.txt.zip\" \\\n", + "--destination \"test.local.txt.zip\"\n", + "```" + ] + } + ], + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_List_Storage.ipynb b/Naas API/Naas_API_List_Storage.ipynb new file mode 100644 index 0000000000..a1fa9d7df2 --- /dev/null +++ b/Naas API/Naas_API_List_Storage.ipynb @@ -0,0 +1,233 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - List Storage\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #list" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-01 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** This notebook demonstrates how to list all your Workspace Storages. A Workspace Storage is the root of your data directory." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### Delete storage" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "storage_list = naas_python.storage.list_workspace_storage(\n", + " workspace_id=workspace_id\n", + ")\n", + "storage_list" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result" + ] + }, + { + "cell_type": "markdown", + "id": "e4761017", + "metadata": {}, + "source": [ + "```json\n", + "{'storage': [{'name': 'test-storage'},\n", + " {'name': 'test-storage2'},\n", + " {'name': 'test'},\n", + " {'name': 'testlib'}],\n", + " 'error': {'error': 0, 'message': 'Sucess'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "#### CLI command\n", + "```sh\n", + "naas-python storage list --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage list -w 81507a26-3644-496c-a379-4c7021434aa0\n", + "```" + ] + } + ], + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_List_Storage_Object.ipynb b/Naas API/Naas_API_List_Storage_Object.ipynb new file mode 100644 index 0000000000..d2c317af77 --- /dev/null +++ b/Naas API/Naas_API_List_Storage_Object.ipynb @@ -0,0 +1,244 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", + "metadata": {}, + "source": [ + "\"Naas" + ] + }, + { + "cell_type": "markdown", + "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", + "metadata": {}, + "source": [ + "# Naas API - List Storage Object\n", + "Give Feedback | Bug report" + ] + }, + { + "cell_type": "markdown", + "id": "9c897c82-4a8f-4f8c-8b00-dd66e496273b", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:19.410802Z", + "iopub.status.busy": "2024-06-03T14:17:19.410576Z", + "iopub.status.idle": "2024-06-03T14:17:19.420684Z", + "shell.execute_reply": "2024-06-03T14:17:19.419788Z", + "shell.execute_reply.started": "2024-06-03T14:17:19.410779Z" + } + }, + "source": [ + "**Tags:** #naas #api #storage #list #object" + ] + }, + { + "cell_type": "markdown", + "id": "20e4f13f-d7c4-4acf-9c53-880545f0ce76", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:17:27.697224Z", + "iopub.status.busy": "2024-06-03T14:17:27.696997Z", + "iopub.status.idle": "2024-06-03T14:17:27.705749Z", + "shell.execute_reply": "2024-06-03T14:17:27.704763Z", + "shell.execute_reply.started": "2024-06-03T14:17:27.697200Z" + } + }, + "source": [ + "**Author:** [Loic Laville](https://www.linkedin.com/in/loic-laville/)" + ] + }, + { + "cell_type": "markdown", + "id": "210c53e9", + "metadata": {}, + "source": [ + "**Last update:** 2024-07-02 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "id": "b3ed8dac", + "metadata": {}, + "source": [ + "**Description:** This notebook demonstrates how to list your file inside your Workspace Storage." + ] + }, + { + "cell_type": "markdown", + "id": "0de8d719", + "metadata": {}, + "source": [ + "# Input" + ] + }, + { + "cell_type": "markdown", + "id": "f9ae1bdf-49b2-4f53-9ae9-b396c4608e9d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:23:07.494752Z", + "iopub.status.busy": "2024-06-03T14:23:07.494526Z", + "iopub.status.idle": "2024-06-03T14:23:07.500018Z", + "shell.execute_reply": "2024-06-03T14:23:07.497930Z", + "shell.execute_reply.started": "2024-06-03T14:23:07.494728Z" + } + }, + "source": [ + "### Import library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32fa0149", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " import naas_python\n", + "except:\n", + " %pip install naas-python --user\n", + " import naas_python" + ] + }, + { + "cell_type": "markdown", + "id": "245593c8", + "metadata": {}, + "source": [ + "### Setup variables" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "Required :\n", + "* `workspace_id` : User Workspace ID\n", + "* `storage_name` : User Storage\n", + "* `storage_prefix`: The directory to list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "storage_name = \"test\"\n", + "storage_prefix=\"directory-1\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### List Storage Object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4856c7a5", + "metadata": {}, + "outputs": [], + "source": [ + "object_list = naas_python.storage.list_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + " storage_prefix=storage_prefix,\n", + ")\n", + "object_list" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display Result\n", + "```json\n", + "{'object': [{\n", + " 'name': 'my-object.txt.zip', \n", + " 'type': 'file', \n", + " 'prefix': '/my-test-dir/', \n", + " 'size': '0.00', \n", + " 'lastmodified': '2024-06-10T12:46:38+00:00'}], \n", + " 'error': {'error': 0, 'message': 'Sucess'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "1f97ea33", + "metadata": {}, + "source": [ + "### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "41e2fbf0", + "metadata": {}, + "source": [ + "```sh\n", + "naas-python storage list-object --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage list-object \\\n", + "-w 81507a26-3644-496c-a379-4c7021434aa0 \\\n", + "-s test-storage \\\n", + "-p my-test-dir\n", + "```" + ] + } + ], + "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.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}