From 55f2a26dfdf403791f103490c77afeb101ec2c6f Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Tue, 11 Jun 2024 10:09:52 +0200 Subject: [PATCH 1/7] feat: Naas Storage API notebook --- Naas API/Naas_API_Storage.ipynb | 946 ++++++++++++++++++++++++++++++++ 1 file changed, 946 insertions(+) create mode 100644 Naas API/Naas_API_Storage.ipynb diff --git a/Naas API/Naas_API_Storage.ipynb b/Naas API/Naas_API_Storage.ipynb new file mode 100644 index 0000000000..4b216ff589 --- /dev/null +++ b/Naas API/Naas_API_Storage.ipynb @@ -0,0 +1,946 @@ +{ + "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 - Storage" + ] + }, + { + "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" + ] + }, + { + "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": "3e784016-04fb-4544-af08-d55e21a30d86", + "metadata": {}, + "source": [ + "**Naas API Storage is a service to host your data.**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Last update:** 2024-06-10 (Created: 2024-06-10)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Description:** This notebook demonstrates how to use Naas API Storage." + ] + }, + { + "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": [ + "import naas_python" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c1519102-4298-46e4-a30c-f7a4fd8e9981", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-05T09:12:07.223484Z", + "iopub.status.busy": "2024-06-05T09:12:07.223252Z", + "iopub.status.idle": "2024-06-05T09:12:07.226394Z", + "shell.execute_reply": "2024-06-05T09:12:07.225699Z", + "shell.execute_reply.started": "2024-06-05T09:12:07.223458Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "workspace_id='81507a26-3644-496c-a379-4c7021434aa0'" + ] + }, + { + "cell_type": "markdown", + "id": "780bd325-280f-4e68-8ca4-4f7eb00c7ed4", + "metadata": {}, + "source": [ + "### Command list" + ] + }, + { + "cell_type": "markdown", + "id": "f18b5055-49a6-4cee-8793-ba2f5d002815", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T16:21:57.186360Z", + "iopub.status.busy": "2024-06-03T16:21:57.186133Z", + "iopub.status.idle": "2024-06-03T16:21:57.195495Z", + "shell.execute_reply": "2024-06-03T16:21:57.194575Z", + "shell.execute_reply.started": "2024-06-03T16:21:57.186336Z" + } + }, + "source": [ + "Workspace Storage :\n", + "* [Create A Workspace Storage](#createstorage)\n", + "* [List Workspace Storages](#liststorage)\n", + "* [Delete a Workspace Storage](#deletestorage)" + ] + }, + { + "cell_type": "markdown", + "id": "26e7cbfb", + "metadata": {}, + "source": [ + "Workspace Object\n", + "* [Post a Workspace Storage Object](#postobject)\n", + "* [List Workspace Storage Objects](#listobjects)\n", + "* [Get a Workspace Storage Object](#getobject)\n", + "* [Delete a Workspace Storage Object](#deleteobject)" + ] + }, + { + "cell_type": "markdown", + "id": "55296efb-41bc-4922-b668-98e93cd09c8e", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "d5074443-6174-4f7e-a4ba-ca1ed5b1b1fb", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:26:27.969902Z", + "iopub.status.busy": "2024-06-03T14:26:27.969608Z", + "iopub.status.idle": "2024-06-03T14:26:27.972888Z", + "shell.execute_reply": "2024-06-03T14:26:27.972264Z", + "shell.execute_reply.started": "2024-06-03T14:26:27.969871Z" + } + }, + "source": [ + "

Create a Workspace Storage

" + ] + }, + { + "cell_type": "markdown", + "id": "561fe35b-8c67-4ded-807e-4c346f903001", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T16:24:36.125226Z", + "iopub.status.busy": "2024-06-03T16:24:36.124913Z", + "iopub.status.idle": "2024-06-03T16:24:36.138351Z", + "shell.execute_reply": "2024-06-03T16:24:36.137411Z", + "shell.execute_reply.started": "2024-06-03T16:24:36.125190Z" + } + }, + "source": [ + "**A Workspace storage is the root of your data directory to set access permission.**" + ] + }, + { + "cell_type": "markdown", + "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", + "metadata": {}, + "source": [ + "**required arguments:**\n", + "* **workspace_id** : workspace id\n", + "* **storage_name** : name of the new storage" + ] + }, + { + "cell_type": "markdown", + "id": "ab6a9231-d9fe-4afa-ad9d-37d106edb80d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T14:27:15.754780Z", + "iopub.status.busy": "2024-06-03T14:27:15.754540Z", + "iopub.status.idle": "2024-06-03T14:27:15.765551Z", + "shell.execute_reply": "2024-06-03T14:27:15.764655Z", + "shell.execute_reply.started": "2024-06-03T14:27:15.754751Z" + } + }, + "source": [ + "### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Get the list of user storages\n", + "storage_list = naas_python.storage.list_workspace_storage(workspace_id)\n", + "\n", + "# If the storage does not exist, create it\n", + "if not any(storage['name'] == 'test-storage' for storage in storage_list['storage']):\n", + " storage = naas_python.storage.create_workspace_storage(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + " )" + ] + }, + { + "cell_type": "markdown", + "id": "35c1d93a-e584-4098-825f-48e581144b49", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T15:57:16.339770Z", + "iopub.status.busy": "2024-06-03T15:57:16.339540Z", + "iopub.status.idle": "2024-06-03T15:57:16.342484Z", + "shell.execute_reply": "2024-06-03T15:57:16.341807Z", + "shell.execute_reply.started": "2024-06-03T15:57:16.339744Z" + } + }, + "source": [ + "#### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "ef0ecd66-c59e-43d3-babf-6e921da29d29", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T15:58:10.611202Z", + "iopub.status.busy": "2024-06-03T15:58:10.610977Z", + "iopub.status.idle": "2024-06-03T15:58:10.626998Z", + "shell.execute_reply": "2024-06-03T15:58:10.626067Z", + "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" + } + }, + "source": [ + "```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", + "```\n", + "\n", + "output : _creating storage..._\n", + "_Storage test created._" + ] + }, + { + "cell_type": "markdown", + "id": "b6d02372-0f87-4307-b726-8ea8e815618c", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "0a90ef5d-8c19-491a-8f50-68dcec43960f", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T16:31:54.376884Z", + "iopub.status.busy": "2024-06-03T16:31:54.376657Z", + "iopub.status.idle": "2024-06-03T16:31:54.385361Z", + "shell.execute_reply": "2024-06-03T16:31:54.384497Z", + "shell.execute_reply.started": "2024-06-03T16:31:54.376860Z" + } + }, + "source": [ + "

List Workspace Storages

" + ] + }, + { + "cell_type": "markdown", + "id": "f8814c11-6b6c-4cdf-9190-b39185c02a46", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T16:34:11.837595Z", + "iopub.status.busy": "2024-06-03T16:34:11.837365Z", + "iopub.status.idle": "2024-06-03T16:34:11.853684Z", + "shell.execute_reply": "2024-06-03T16:34:11.852804Z", + "shell.execute_reply.started": "2024-06-03T16:34:11.837570Z" + } + }, + "source": [ + "**List the storages of a specified workspace.**" + ] + }, + { + "cell_type": "markdown", + "id": "f1b9f608-c3c7-4e6e-9664-e1fd15b19277", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T16:36:10.912242Z", + "iopub.status.busy": "2024-06-03T16:36:10.912014Z", + "iopub.status.idle": "2024-06-03T16:36:10.920610Z", + "shell.execute_reply": "2024-06-03T16:36:10.919786Z", + "shell.execute_reply.started": "2024-06-03T16:36:10.912217Z" + } + }, + "source": [ + "required arguments:\n", + "* **workspace_id** : workspace id" + ] + }, + { + "cell_type": "markdown", + "id": "30a9ceb9", + "metadata": {}, + "source": [ + "### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "89825d68-fcca-4b1d-b7be-51b2cdc32202", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "storage_list = naas_python.storage.list_workspace_storage(workspace_id)" + ] + }, + { + "cell_type": "markdown", + "id": "47ef0523-2067-47a4-8aa7-344f9e686a1a", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T16:51:14.843204Z", + "iopub.status.busy": "2024-06-03T16:51:14.842976Z", + "iopub.status.idle": "2024-06-03T16:51:14.858356Z", + "shell.execute_reply": "2024-06-03T16:51:14.857496Z", + "shell.execute_reply.started": "2024-06-03T16:51:14.843179Z" + }, + "tags": [] + }, + "source": [ + "output :\n", + "```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": "4fcb91c7-22a4-4adc-863f-5a50023644b7", + "metadata": {}, + "source": [ + "#### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "7d015740-66af-436d-b662-9a3d2365759a", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T15:58:10.611202Z", + "iopub.status.busy": "2024-06-03T15:58:10.610977Z", + "iopub.status.idle": "2024-06-03T15:58:10.626998Z", + "shell.execute_reply": "2024-06-03T15:58:10.626067Z", + "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" + } + }, + "source": [ + "```sh\n", + "naas-python storage list --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage list -w 81507a26-3644-496c-a379-4c7021434aa0\n", + "```\n", + "\n", + "output : _{'storage': [{'name': 'test-storage'}, {'name': 'test-storage2'}, {'name': 'test'}, {'name': 'testlib'}], 'error': {'error': 0, 'message': 'Sucess'}}_" + ] + }, + { + "cell_type": "markdown", + "id": "6c107009-99ca-4b64-88a2-e9f5731ccfb8", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "d02eb9f4-8880-47bc-bd0a-d026fb763d25", + "metadata": {}, + "source": [ + "

Delete a Workspace Storage

" + ] + }, + { + "cell_type": "markdown", + "id": "5b84fe9c-44af-4dfb-92a2-7b8b32da646a", + "metadata": {}, + "source": [ + "**Delete the storage of a specified workspace.**" + ] + }, + { + "cell_type": "markdown", + "id": "8b2600ef-715d-49a0-9ace-a509b47e3701", + "metadata": {}, + "source": [ + "**required arguments:**\n", + "* **workspace_id** : workspace id\n", + "* **storage_name** : name of the storage" + ] + }, + { + "cell_type": "markdown", + "id": "60d75127", + "metadata": {}, + "source": [ + "### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5730580-24f9-432d-bde0-3c9bd467fff2", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-05T09:12:23.906037Z", + "iopub.status.busy": "2024-06-05T09:12:23.905455Z", + "iopub.status.idle": "2024-06-05T09:12:23.915033Z", + "shell.execute_reply": "2024-06-05T09:12:23.914324Z", + "shell.execute_reply.started": "2024-06-05T09:12:23.905998Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "delete_storage = naas_python.storage.delete_workspace_storage(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "79f999ae", + "metadata": {}, + "source": [ + "output :\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "5f3e9393", + "metadata": {}, + "source": [ + "#### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "6c749cf0", + "metadata": {}, + "source": [ + "```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", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "866ecb97-cfcc-474b-919c-ce0970c17498", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "a678b443-edb6-4826-a170-3791fa6f8320", + "metadata": {}, + "source": [ + "

Post a Workspace Storage Object

" + ] + }, + { + "cell_type": "markdown", + "id": "bb1c90a5-c537-46ff-93f4-39e424681ea5", + "metadata": {}, + "source": [ + "**Upload a local file to your remote Naas Storage.**" + ] + }, + { + "cell_type": "markdown", + "id": "d6afb80c-4294-4c93-bea0-9ba21adbbcf1", + "metadata": {}, + "source": [ + "arguments :\n", + "* **workspace_id** : ID of the workspace\n", + "* **storage_name** : Name of the storage\n", + "* **src_file** : File to upload in the storage\n", + "* **dst_file** : Destination file path in the storage " + ] + }, + { + "cell_type": "markdown", + "id": "8164b56f", + "metadata": {}, + "source": [ + "### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "16699cbb-f8e0-44c1-ac7c-9041b0182bc0", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-05T09:14:26.764369Z", + "iopub.status.busy": "2024-06-05T09:14:26.764098Z", + "iopub.status.idle": "2024-06-05T09:14:28.878038Z", + "shell.execute_reply": "2024-06-05T09:14:28.877342Z", + "shell.execute_reply.started": "2024-06-05T09:14:26.764341Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import os\n", + "post_object = naas_python.storage.post_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + " src_file=\"test.txt.zip\",\n", + " dst_file=\"my-test-dir/my-object.txt.zip\"\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "6151c642-5592-4836-811f-d75161644f12", + "metadata": {}, + "source": [ + "#### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "96bb6897-b3e5-441c-826b-411e9625bcd1", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T15:58:10.611202Z", + "iopub.status.busy": "2024-06-03T15:58:10.610977Z", + "iopub.status.idle": "2024-06-03T15:58:10.626998Z", + "shell.execute_reply": "2024-06-03T15:58:10.626067Z", + "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" + } + }, + "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", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "02198ade-5413-4ec5-a37e-e9fb38091d41", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-04T12:32:50.552808Z", + "iopub.status.busy": "2024-06-04T12:32:50.552324Z", + "iopub.status.idle": "2024-06-04T12:32:50.555880Z", + "shell.execute_reply": "2024-06-04T12:32:50.555269Z", + "shell.execute_reply.started": "2024-06-04T12:32:50.552772Z" + }, + "tags": [] + }, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "137089e4-df3a-4214-86a3-11c850942c62", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-04T13:20:15.105892Z", + "iopub.status.busy": "2024-06-04T13:20:15.105621Z", + "iopub.status.idle": "2024-06-04T13:20:15.110041Z", + "shell.execute_reply": "2024-06-04T13:20:15.109383Z", + "shell.execute_reply.started": "2024-06-04T13:20:15.105831Z" + } + }, + "source": [ + "

List Workspace Storage Objects

" + ] + }, + { + "cell_type": "markdown", + "id": "2f66b617-1f51-4bf6-be60-ab70df7bd425", + "metadata": {}, + "source": [ + "**List objects of a remote Naas Storage directory**" + ] + }, + { + "cell_type": "markdown", + "id": "914df591", + "metadata": {}, + "source": [ + "arguments :\n", + "* **workspace_id** : ID of the workspace\n", + "* **storage_name** : Name of the storage\n", + "* **storage_prefix** : Path prefix in the storage" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6a6ef7dc-173d-41c3-a92d-ce8a47bd68c9", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-05T09:15:15.435530Z", + "iopub.status.busy": "2024-06-05T09:15:15.435302Z", + "iopub.status.idle": "2024-06-05T09:15:16.139686Z", + "shell.execute_reply": "2024-06-05T09:15:16.139087Z", + "shell.execute_reply.started": "2024-06-05T09:15:15.435506Z" + } + }, + "outputs": [], + "source": [ + "naas_python.storage.list_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + " storage_prefix=\"my-test-dir/\"\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "90a0be4b", + "metadata": {}, + "source": [ + "output :\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": "64b7b785-155a-4575-abea-ec6a9ddf6a3c", + "metadata": {}, + "source": [ + "#### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "70d6b2c5-9584-4bcb-9474-e882abc1fa4d", + "metadata": { + "execution": { + "iopub.execute_input": "2024-06-03T15:58:10.611202Z", + "iopub.status.busy": "2024-06-03T15:58:10.610977Z", + "iopub.status.idle": "2024-06-03T15:58:10.626998Z", + "shell.execute_reply": "2024-06-03T15:58:10.626067Z", + "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" + } + }, + "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", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "04fea996", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "29d7b43e", + "metadata": {}, + "source": [ + "

Get a Workspace Storage Object

" + ] + }, + { + "cell_type": "markdown", + "id": "d2ab81de", + "metadata": {}, + "source": [ + "**Download an object from your Naas Storage.**" + ] + }, + { + "cell_type": "markdown", + "id": "5b01539b", + "metadata": {}, + "source": [ + "arguments :\n", + "* **workspace_id** : ID of the workspace\n", + "* **storage_name** : Name of the storage\n", + "* **src_file** : File to upload in the storage\n", + "* **dst_file** : Destination file path in the storage " + ] + }, + { + "cell_type": "markdown", + "id": "41f83480", + "metadata": {}, + "source": [ + "#### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d3ada36d", + "metadata": {}, + "outputs": [], + "source": [ + "get_object = naas_python.storage.get_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + " src_file=\"my-test-dir/my-object.txt.zip\",\n", + " dst_file=\"test.txt.zip\"\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "c0281586", + "metadata": {}, + "source": [ + "#### CLI" + ] + }, + { + "cell_type": "markdown", + "id": "b57e5b8f", + "metadata": {}, + "source": [ + "```sh\n", + "naas-python storage get-object --help\n", + "```\n", + "\n", + "```sh\n", + "naas-python storage put-object \\\n", + "--workspace 81507a26-3644-496c-a379-4c7021434aa0 \\\n", + "--storage test-storage \\\n", + "--source \"my-test-dir/my-object.txt.zip\" \\\n", + "--destination \"test.txt.zip\"\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "d239fa1e", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "id": "3b87caa2", + "metadata": {}, + "source": [ + "

Delete a Workspace Storage Object

" + ] + }, + { + "cell_type": "markdown", + "id": "ae490881", + "metadata": {}, + "source": [ + "**Delet an object from your Naas Storage**" + ] + }, + { + "cell_type": "markdown", + "id": "c9d64043", + "metadata": {}, + "source": [ + "arguments :\n", + "* **workspace_id** : ID of the workspace\n", + "* **object_name** : Path and name of the object" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d3e29150", + "metadata": {}, + "outputs": [], + "source": [ + "delete_object = naas_python.storage.delete_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + " object_name=\"my-test-dir/my-object.txt.zip\"\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "c36cf34d", + "metadata": {}, + "source": [ + "result :\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Sucess'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "e1059713", + "metadata": {}, + "source": [ + "#### CLI" + ] + }, + { + "cell_type": "markdown", + "id": "7fe8b345", + "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 +} From 32363d822d4f15b9830e66ea54bf7cf2dbb8dde0 Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Mon, 24 Jun 2024 15:13:54 +0200 Subject: [PATCH 2/7] fix: typo change --- Naas API/Naas_API_Storage.ipynb | 239 +++++++++++++++++--------------- 1 file changed, 128 insertions(+), 111 deletions(-) diff --git a/Naas API/Naas_API_Storage.ipynb b/Naas API/Naas_API_Storage.ipynb index 4b216ff589..1abe6d3e78 100644 --- a/Naas API/Naas_API_Storage.ipynb +++ b/Naas API/Naas_API_Storage.ipynb @@ -60,7 +60,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Last update:** 2024-06-10 (Created: 2024-06-10)" + "**Last update:** 2024-06-24 (Created: 2024-06-10)" ] }, { @@ -96,6 +96,20 @@ "import naas_python" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "6be3b1ae", + "metadata": { + "vscode": { + "languageId": "shellscript" + } + }, + "outputs": [], + "source": [ + "pip show naas-python" + ] + }, { "cell_type": "code", "execution_count": null, @@ -162,6 +176,100 @@ "---" ] }, + { + "cell_type": "markdown", + "id": "12528e9d", + "metadata": {}, + "source": [ + "

Delete a Workspace Storage

" + ] + }, + { + "cell_type": "markdown", + "id": "5b70e30c", + "metadata": {}, + "source": [ + "**Delete the storage of a specified workspace.**" + ] + }, + { + "cell_type": "markdown", + "id": "a42db27a", + "metadata": {}, + "source": [ + "**required arguments:**\n", + "* **workspace_id** : workspace id\n", + "* **storage_name** : name of the storage" + ] + }, + { + "cell_type": "markdown", + "id": "f8028c11", + "metadata": {}, + "source": [ + "### Python Example" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1141fa97", + "metadata": {}, + "outputs": [], + "source": [ + "# Get the list of user storages\n", + "storage_list = naas_python.storage.list_workspace_storage(workspace_id)\n", + "\n", + "# If the storage does not exist, create it\n", + "if any(storage['name'] == 'test-storage' for storage in storage_list['storage']):\n", + " delete_storage = naas_python.storage.delete_workspace_storage(\n", + " workspace_id=workspace_id,\n", + " storage_name=\"test-storage\",\n", + ")\n", + "delete_storage" + ] + }, + { + "cell_type": "markdown", + "id": "cd5c8a81", + "metadata": {}, + "source": [ + "output :\n", + "```json\n", + "{'error': {'error': 0, 'message': 'Success'}}\n", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "dd4d0128", + "metadata": {}, + "source": [ + "#### CLI command" + ] + }, + { + "cell_type": "markdown", + "id": "a9d3233e", + "metadata": {}, + "source": [ + "```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", + "```" + ] + }, + { + "cell_type": "markdown", + "id": "2281159e", + "metadata": {}, + "source": [ + "---" + ] + }, { "cell_type": "markdown", "id": "d5074443-6174-4f7e-a4ba-ca1ed5b1b1fb", @@ -237,7 +345,8 @@ " storage = naas_python.storage.create_workspace_storage(\n", " workspace_id=workspace_id,\n", " storage_name=\"test-storage\",\n", - " )" + " )\n", + "storage_list" ] }, { @@ -355,7 +464,8 @@ }, "outputs": [], "source": [ - "storage_list = naas_python.storage.list_workspace_storage(workspace_id)" + "storage_list = naas_python.storage.list_workspace_storage(workspace_id)\n", + "storage_list" ] }, { @@ -414,103 +524,6 @@ "output : _{'storage': [{'name': 'test-storage'}, {'name': 'test-storage2'}, {'name': 'test'}, {'name': 'testlib'}], 'error': {'error': 0, 'message': 'Sucess'}}_" ] }, - { - "cell_type": "markdown", - "id": "6c107009-99ca-4b64-88a2-e9f5731ccfb8", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "d02eb9f4-8880-47bc-bd0a-d026fb763d25", - "metadata": {}, - "source": [ - "

Delete a Workspace Storage

" - ] - }, - { - "cell_type": "markdown", - "id": "5b84fe9c-44af-4dfb-92a2-7b8b32da646a", - "metadata": {}, - "source": [ - "**Delete the storage of a specified workspace.**" - ] - }, - { - "cell_type": "markdown", - "id": "8b2600ef-715d-49a0-9ace-a509b47e3701", - "metadata": {}, - "source": [ - "**required arguments:**\n", - "* **workspace_id** : workspace id\n", - "* **storage_name** : name of the storage" - ] - }, - { - "cell_type": "markdown", - "id": "60d75127", - "metadata": {}, - "source": [ - "### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e5730580-24f9-432d-bde0-3c9bd467fff2", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-05T09:12:23.906037Z", - "iopub.status.busy": "2024-06-05T09:12:23.905455Z", - "iopub.status.idle": "2024-06-05T09:12:23.915033Z", - "shell.execute_reply": "2024-06-05T09:12:23.914324Z", - "shell.execute_reply.started": "2024-06-05T09:12:23.905998Z" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "delete_storage = naas_python.storage.delete_workspace_storage(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - ")" - ] - }, - { - "cell_type": "markdown", - "id": "79f999ae", - "metadata": {}, - "source": [ - "output :\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "5f3e9393", - "metadata": {}, - "source": [ - "#### CLI command" - ] - }, - { - "cell_type": "markdown", - "id": "6c749cf0", - "metadata": {}, - "source": [ - "```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", - "```" - ] - }, { "cell_type": "markdown", "id": "866ecb97-cfcc-474b-919c-ce0970c17498", @@ -575,9 +588,10 @@ "post_object = naas_python.storage.post_workspace_storage_object(\n", " workspace_id=workspace_id,\n", " storage_name=\"test-storage\",\n", - " src_file=\"test.txt.zip\",\n", - " dst_file=\"my-test-dir/my-object.txt.zip\"\n", - ")" + " src_file=\"Naas_API_Storage.ipynb\",\n", + " dst_file=\"directory-1/Naas_API_Storage.ipynb\"\n", + ")\n", + "post_object" ] }, { @@ -688,11 +702,12 @@ }, "outputs": [], "source": [ - "naas_python.storage.list_workspace_storage_object(\n", + "storage_list = naas_python.storage.list_workspace_storage_object(\n", " workspace_id=workspace_id,\n", " storage_name=\"test-storage\",\n", - " storage_prefix=\"my-test-dir/\"\n", - ")" + " storage_prefix=\"directory-1\"\n", + ")\n", + "storage_list" ] }, { @@ -799,9 +814,10 @@ "get_object = naas_python.storage.get_workspace_storage_object(\n", " workspace_id=workspace_id,\n", " storage_name=\"test-storage\",\n", - " src_file=\"my-test-dir/my-object.txt.zip\",\n", - " dst_file=\"test.txt.zip\"\n", - ")" + " src_file=\"directory-1/Naas_API_Storage.ipynb\",\n", + " dst_file=\"Naas_API_Storage-2.ipynb\"\n", + ")\n", + "get_object" ] }, { @@ -881,8 +897,9 @@ "delete_object = naas_python.storage.delete_workspace_storage_object(\n", " workspace_id=workspace_id,\n", " storage_name=\"test-storage\",\n", - " object_name=\"my-test-dir/my-object.txt.zip\"\n", - ")" + " object_name=\"directory-1/Naas_API_Storage.ipynb\"\n", + ")\n", + "delete_object" ] }, { From daa87a351d3aa5e2fbaf03430fdda1ac85da5d29 Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Thu, 27 Jun 2024 16:59:05 +0200 Subject: [PATCH 3/7] fix: remove test workspace_id --- Naas API/Naas_API_Storage.ipynb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Naas API/Naas_API_Storage.ipynb b/Naas API/Naas_API_Storage.ipynb index 1abe6d3e78..780d3c7daa 100644 --- a/Naas API/Naas_API_Storage.ipynb +++ b/Naas API/Naas_API_Storage.ipynb @@ -262,14 +262,6 @@ "```" ] }, - { - "cell_type": "markdown", - "id": "2281159e", - "metadata": {}, - "source": [ - "---" - ] - }, { "cell_type": "markdown", "id": "d5074443-6174-4f7e-a4ba-ca1ed5b1b1fb", From e828dc671c3365ab44cf3a660f6aad3a463230c9 Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Tue, 2 Jul 2024 08:58:47 +0200 Subject: [PATCH 4/7] 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 +} From 663c7bac042fee930e49d96fa21c62a53c6513bc Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Tue, 2 Jul 2024 11:56:35 +0200 Subject: [PATCH 5/7] fix: deleted previous notebook and test cicd --- Naas API/Naas_API_Create_Storage.ipynb | 2 +- Naas API/Naas_API_Storage.ipynb | 955 ------------------------- 2 files changed, 1 insertion(+), 956 deletions(-) delete mode 100644 Naas API/Naas_API_Storage.ipynb diff --git a/Naas API/Naas_API_Create_Storage.ipynb b/Naas API/Naas_API_Create_Storage.ipynb index ce6e985fd3..6abc1e1c58 100644 --- a/Naas API/Naas_API_Create_Storage.ipynb +++ b/Naas API/Naas_API_Create_Storage.ipynb @@ -13,7 +13,7 @@ "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", "metadata": {}, "source": [ - "# Naas API - Create Storage\n", + "## Naas API - Create Storage\n", "Give Feedback | Bug report" ] }, diff --git a/Naas API/Naas_API_Storage.ipynb b/Naas API/Naas_API_Storage.ipynb deleted file mode 100644 index 780d3c7daa..0000000000 --- a/Naas API/Naas_API_Storage.ipynb +++ /dev/null @@ -1,955 +0,0 @@ -{ - "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 - Storage" - ] - }, - { - "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" - ] - }, - { - "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": "3e784016-04fb-4544-af08-d55e21a30d86", - "metadata": {}, - "source": [ - "**Naas API Storage is a service to host your data.**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Last update:** 2024-06-24 (Created: 2024-06-10)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Description:** This notebook demonstrates how to use Naas API Storage." - ] - }, - { - "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": [ - "import naas_python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6be3b1ae", - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "pip show naas-python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c1519102-4298-46e4-a30c-f7a4fd8e9981", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-05T09:12:07.223484Z", - "iopub.status.busy": "2024-06-05T09:12:07.223252Z", - "iopub.status.idle": "2024-06-05T09:12:07.226394Z", - "shell.execute_reply": "2024-06-05T09:12:07.225699Z", - "shell.execute_reply.started": "2024-06-05T09:12:07.223458Z" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "workspace_id='81507a26-3644-496c-a379-4c7021434aa0'" - ] - }, - { - "cell_type": "markdown", - "id": "780bd325-280f-4e68-8ca4-4f7eb00c7ed4", - "metadata": {}, - "source": [ - "### Command list" - ] - }, - { - "cell_type": "markdown", - "id": "f18b5055-49a6-4cee-8793-ba2f5d002815", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T16:21:57.186360Z", - "iopub.status.busy": "2024-06-03T16:21:57.186133Z", - "iopub.status.idle": "2024-06-03T16:21:57.195495Z", - "shell.execute_reply": "2024-06-03T16:21:57.194575Z", - "shell.execute_reply.started": "2024-06-03T16:21:57.186336Z" - } - }, - "source": [ - "Workspace Storage :\n", - "* [Create A Workspace Storage](#createstorage)\n", - "* [List Workspace Storages](#liststorage)\n", - "* [Delete a Workspace Storage](#deletestorage)" - ] - }, - { - "cell_type": "markdown", - "id": "26e7cbfb", - "metadata": {}, - "source": [ - "Workspace Object\n", - "* [Post a Workspace Storage Object](#postobject)\n", - "* [List Workspace Storage Objects](#listobjects)\n", - "* [Get a Workspace Storage Object](#getobject)\n", - "* [Delete a Workspace Storage Object](#deleteobject)" - ] - }, - { - "cell_type": "markdown", - "id": "55296efb-41bc-4922-b668-98e93cd09c8e", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "12528e9d", - "metadata": {}, - "source": [ - "

Delete a Workspace Storage

" - ] - }, - { - "cell_type": "markdown", - "id": "5b70e30c", - "metadata": {}, - "source": [ - "**Delete the storage of a specified workspace.**" - ] - }, - { - "cell_type": "markdown", - "id": "a42db27a", - "metadata": {}, - "source": [ - "**required arguments:**\n", - "* **workspace_id** : workspace id\n", - "* **storage_name** : name of the storage" - ] - }, - { - "cell_type": "markdown", - "id": "f8028c11", - "metadata": {}, - "source": [ - "### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1141fa97", - "metadata": {}, - "outputs": [], - "source": [ - "# Get the list of user storages\n", - "storage_list = naas_python.storage.list_workspace_storage(workspace_id)\n", - "\n", - "# If the storage does not exist, create it\n", - "if any(storage['name'] == 'test-storage' for storage in storage_list['storage']):\n", - " delete_storage = naas_python.storage.delete_workspace_storage(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - ")\n", - "delete_storage" - ] - }, - { - "cell_type": "markdown", - "id": "cd5c8a81", - "metadata": {}, - "source": [ - "output :\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "dd4d0128", - "metadata": {}, - "source": [ - "#### CLI command" - ] - }, - { - "cell_type": "markdown", - "id": "a9d3233e", - "metadata": {}, - "source": [ - "```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", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "d5074443-6174-4f7e-a4ba-ca1ed5b1b1fb", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T14:26:27.969902Z", - "iopub.status.busy": "2024-06-03T14:26:27.969608Z", - "iopub.status.idle": "2024-06-03T14:26:27.972888Z", - "shell.execute_reply": "2024-06-03T14:26:27.972264Z", - "shell.execute_reply.started": "2024-06-03T14:26:27.969871Z" - } - }, - "source": [ - "

Create a Workspace Storage

" - ] - }, - { - "cell_type": "markdown", - "id": "561fe35b-8c67-4ded-807e-4c346f903001", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T16:24:36.125226Z", - "iopub.status.busy": "2024-06-03T16:24:36.124913Z", - "iopub.status.idle": "2024-06-03T16:24:36.138351Z", - "shell.execute_reply": "2024-06-03T16:24:36.137411Z", - "shell.execute_reply.started": "2024-06-03T16:24:36.125190Z" - } - }, - "source": [ - "**A Workspace storage is the root of your data directory to set access permission.**" - ] - }, - { - "cell_type": "markdown", - "id": "a0c5268d-a14d-42c5-bf93-722f6302cc0a", - "metadata": {}, - "source": [ - "**required arguments:**\n", - "* **workspace_id** : workspace id\n", - "* **storage_name** : name of the new storage" - ] - }, - { - "cell_type": "markdown", - "id": "ab6a9231-d9fe-4afa-ad9d-37d106edb80d", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T14:27:15.754780Z", - "iopub.status.busy": "2024-06-03T14:27:15.754540Z", - "iopub.status.idle": "2024-06-03T14:27:15.765551Z", - "shell.execute_reply": "2024-06-03T14:27:15.764655Z", - "shell.execute_reply.started": "2024-06-03T14:27:15.754751Z" - } - }, - "source": [ - "### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# Get the list of user storages\n", - "storage_list = naas_python.storage.list_workspace_storage(workspace_id)\n", - "\n", - "# If the storage does not exist, create it\n", - "if not any(storage['name'] == 'test-storage' for storage in storage_list['storage']):\n", - " storage = naas_python.storage.create_workspace_storage(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - " )\n", - "storage_list" - ] - }, - { - "cell_type": "markdown", - "id": "35c1d93a-e584-4098-825f-48e581144b49", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T15:57:16.339770Z", - "iopub.status.busy": "2024-06-03T15:57:16.339540Z", - "iopub.status.idle": "2024-06-03T15:57:16.342484Z", - "shell.execute_reply": "2024-06-03T15:57:16.341807Z", - "shell.execute_reply.started": "2024-06-03T15:57:16.339744Z" - } - }, - "source": [ - "#### CLI command" - ] - }, - { - "cell_type": "markdown", - "id": "ef0ecd66-c59e-43d3-babf-6e921da29d29", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T15:58:10.611202Z", - "iopub.status.busy": "2024-06-03T15:58:10.610977Z", - "iopub.status.idle": "2024-06-03T15:58:10.626998Z", - "shell.execute_reply": "2024-06-03T15:58:10.626067Z", - "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" - } - }, - "source": [ - "```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", - "```\n", - "\n", - "output : _creating storage..._\n", - "_Storage test created._" - ] - }, - { - "cell_type": "markdown", - "id": "b6d02372-0f87-4307-b726-8ea8e815618c", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "0a90ef5d-8c19-491a-8f50-68dcec43960f", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T16:31:54.376884Z", - "iopub.status.busy": "2024-06-03T16:31:54.376657Z", - "iopub.status.idle": "2024-06-03T16:31:54.385361Z", - "shell.execute_reply": "2024-06-03T16:31:54.384497Z", - "shell.execute_reply.started": "2024-06-03T16:31:54.376860Z" - } - }, - "source": [ - "

List Workspace Storages

" - ] - }, - { - "cell_type": "markdown", - "id": "f8814c11-6b6c-4cdf-9190-b39185c02a46", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T16:34:11.837595Z", - "iopub.status.busy": "2024-06-03T16:34:11.837365Z", - "iopub.status.idle": "2024-06-03T16:34:11.853684Z", - "shell.execute_reply": "2024-06-03T16:34:11.852804Z", - "shell.execute_reply.started": "2024-06-03T16:34:11.837570Z" - } - }, - "source": [ - "**List the storages of a specified workspace.**" - ] - }, - { - "cell_type": "markdown", - "id": "f1b9f608-c3c7-4e6e-9664-e1fd15b19277", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T16:36:10.912242Z", - "iopub.status.busy": "2024-06-03T16:36:10.912014Z", - "iopub.status.idle": "2024-06-03T16:36:10.920610Z", - "shell.execute_reply": "2024-06-03T16:36:10.919786Z", - "shell.execute_reply.started": "2024-06-03T16:36:10.912217Z" - } - }, - "source": [ - "required arguments:\n", - "* **workspace_id** : workspace id" - ] - }, - { - "cell_type": "markdown", - "id": "30a9ceb9", - "metadata": {}, - "source": [ - "### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "89825d68-fcca-4b1d-b7be-51b2cdc32202", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "storage_list = naas_python.storage.list_workspace_storage(workspace_id)\n", - "storage_list" - ] - }, - { - "cell_type": "markdown", - "id": "47ef0523-2067-47a4-8aa7-344f9e686a1a", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T16:51:14.843204Z", - "iopub.status.busy": "2024-06-03T16:51:14.842976Z", - "iopub.status.idle": "2024-06-03T16:51:14.858356Z", - "shell.execute_reply": "2024-06-03T16:51:14.857496Z", - "shell.execute_reply.started": "2024-06-03T16:51:14.843179Z" - }, - "tags": [] - }, - "source": [ - "output :\n", - "```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": "4fcb91c7-22a4-4adc-863f-5a50023644b7", - "metadata": {}, - "source": [ - "#### CLI command" - ] - }, - { - "cell_type": "markdown", - "id": "7d015740-66af-436d-b662-9a3d2365759a", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T15:58:10.611202Z", - "iopub.status.busy": "2024-06-03T15:58:10.610977Z", - "iopub.status.idle": "2024-06-03T15:58:10.626998Z", - "shell.execute_reply": "2024-06-03T15:58:10.626067Z", - "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" - } - }, - "source": [ - "```sh\n", - "naas-python storage list --help\n", - "```\n", - "\n", - "```sh\n", - "naas-python storage list -w 81507a26-3644-496c-a379-4c7021434aa0\n", - "```\n", - "\n", - "output : _{'storage': [{'name': 'test-storage'}, {'name': 'test-storage2'}, {'name': 'test'}, {'name': 'testlib'}], 'error': {'error': 0, 'message': 'Sucess'}}_" - ] - }, - { - "cell_type": "markdown", - "id": "866ecb97-cfcc-474b-919c-ce0970c17498", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "a678b443-edb6-4826-a170-3791fa6f8320", - "metadata": {}, - "source": [ - "

Post a Workspace Storage Object

" - ] - }, - { - "cell_type": "markdown", - "id": "bb1c90a5-c537-46ff-93f4-39e424681ea5", - "metadata": {}, - "source": [ - "**Upload a local file to your remote Naas Storage.**" - ] - }, - { - "cell_type": "markdown", - "id": "d6afb80c-4294-4c93-bea0-9ba21adbbcf1", - "metadata": {}, - "source": [ - "arguments :\n", - "* **workspace_id** : ID of the workspace\n", - "* **storage_name** : Name of the storage\n", - "* **src_file** : File to upload in the storage\n", - "* **dst_file** : Destination file path in the storage " - ] - }, - { - "cell_type": "markdown", - "id": "8164b56f", - "metadata": {}, - "source": [ - "### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "16699cbb-f8e0-44c1-ac7c-9041b0182bc0", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-05T09:14:26.764369Z", - "iopub.status.busy": "2024-06-05T09:14:26.764098Z", - "iopub.status.idle": "2024-06-05T09:14:28.878038Z", - "shell.execute_reply": "2024-06-05T09:14:28.877342Z", - "shell.execute_reply.started": "2024-06-05T09:14:26.764341Z" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "import os\n", - "post_object = naas_python.storage.post_workspace_storage_object(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - " src_file=\"Naas_API_Storage.ipynb\",\n", - " dst_file=\"directory-1/Naas_API_Storage.ipynb\"\n", - ")\n", - "post_object" - ] - }, - { - "cell_type": "markdown", - "id": "6151c642-5592-4836-811f-d75161644f12", - "metadata": {}, - "source": [ - "#### CLI command" - ] - }, - { - "cell_type": "markdown", - "id": "96bb6897-b3e5-441c-826b-411e9625bcd1", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T15:58:10.611202Z", - "iopub.status.busy": "2024-06-03T15:58:10.610977Z", - "iopub.status.idle": "2024-06-03T15:58:10.626998Z", - "shell.execute_reply": "2024-06-03T15:58:10.626067Z", - "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" - } - }, - "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", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "02198ade-5413-4ec5-a37e-e9fb38091d41", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-04T12:32:50.552808Z", - "iopub.status.busy": "2024-06-04T12:32:50.552324Z", - "iopub.status.idle": "2024-06-04T12:32:50.555880Z", - "shell.execute_reply": "2024-06-04T12:32:50.555269Z", - "shell.execute_reply.started": "2024-06-04T12:32:50.552772Z" - }, - "tags": [] - }, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "137089e4-df3a-4214-86a3-11c850942c62", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-04T13:20:15.105892Z", - "iopub.status.busy": "2024-06-04T13:20:15.105621Z", - "iopub.status.idle": "2024-06-04T13:20:15.110041Z", - "shell.execute_reply": "2024-06-04T13:20:15.109383Z", - "shell.execute_reply.started": "2024-06-04T13:20:15.105831Z" - } - }, - "source": [ - "

List Workspace Storage Objects

" - ] - }, - { - "cell_type": "markdown", - "id": "2f66b617-1f51-4bf6-be60-ab70df7bd425", - "metadata": {}, - "source": [ - "**List objects of a remote Naas Storage directory**" - ] - }, - { - "cell_type": "markdown", - "id": "914df591", - "metadata": {}, - "source": [ - "arguments :\n", - "* **workspace_id** : ID of the workspace\n", - "* **storage_name** : Name of the storage\n", - "* **storage_prefix** : Path prefix in the storage" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6a6ef7dc-173d-41c3-a92d-ce8a47bd68c9", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-05T09:15:15.435530Z", - "iopub.status.busy": "2024-06-05T09:15:15.435302Z", - "iopub.status.idle": "2024-06-05T09:15:16.139686Z", - "shell.execute_reply": "2024-06-05T09:15:16.139087Z", - "shell.execute_reply.started": "2024-06-05T09:15:15.435506Z" - } - }, - "outputs": [], - "source": [ - "storage_list = naas_python.storage.list_workspace_storage_object(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - " storage_prefix=\"directory-1\"\n", - ")\n", - "storage_list" - ] - }, - { - "cell_type": "markdown", - "id": "90a0be4b", - "metadata": {}, - "source": [ - "output :\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": "64b7b785-155a-4575-abea-ec6a9ddf6a3c", - "metadata": {}, - "source": [ - "#### CLI command" - ] - }, - { - "cell_type": "markdown", - "id": "70d6b2c5-9584-4bcb-9474-e882abc1fa4d", - "metadata": { - "execution": { - "iopub.execute_input": "2024-06-03T15:58:10.611202Z", - "iopub.status.busy": "2024-06-03T15:58:10.610977Z", - "iopub.status.idle": "2024-06-03T15:58:10.626998Z", - "shell.execute_reply": "2024-06-03T15:58:10.626067Z", - "shell.execute_reply.started": "2024-06-03T15:58:10.611178Z" - } - }, - "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", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "04fea996", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "29d7b43e", - "metadata": {}, - "source": [ - "

Get a Workspace Storage Object

" - ] - }, - { - "cell_type": "markdown", - "id": "d2ab81de", - "metadata": {}, - "source": [ - "**Download an object from your Naas Storage.**" - ] - }, - { - "cell_type": "markdown", - "id": "5b01539b", - "metadata": {}, - "source": [ - "arguments :\n", - "* **workspace_id** : ID of the workspace\n", - "* **storage_name** : Name of the storage\n", - "* **src_file** : File to upload in the storage\n", - "* **dst_file** : Destination file path in the storage " - ] - }, - { - "cell_type": "markdown", - "id": "41f83480", - "metadata": {}, - "source": [ - "#### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d3ada36d", - "metadata": {}, - "outputs": [], - "source": [ - "get_object = naas_python.storage.get_workspace_storage_object(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - " src_file=\"directory-1/Naas_API_Storage.ipynb\",\n", - " dst_file=\"Naas_API_Storage-2.ipynb\"\n", - ")\n", - "get_object" - ] - }, - { - "cell_type": "markdown", - "id": "c0281586", - "metadata": {}, - "source": [ - "#### CLI" - ] - }, - { - "cell_type": "markdown", - "id": "b57e5b8f", - "metadata": {}, - "source": [ - "```sh\n", - "naas-python storage get-object --help\n", - "```\n", - "\n", - "```sh\n", - "naas-python storage put-object \\\n", - "--workspace 81507a26-3644-496c-a379-4c7021434aa0 \\\n", - "--storage test-storage \\\n", - "--source \"my-test-dir/my-object.txt.zip\" \\\n", - "--destination \"test.txt.zip\"\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "d239fa1e", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "id": "3b87caa2", - "metadata": {}, - "source": [ - "

Delete a Workspace Storage Object

" - ] - }, - { - "cell_type": "markdown", - "id": "ae490881", - "metadata": {}, - "source": [ - "**Delet an object from your Naas Storage**" - ] - }, - { - "cell_type": "markdown", - "id": "c9d64043", - "metadata": {}, - "source": [ - "arguments :\n", - "* **workspace_id** : ID of the workspace\n", - "* **object_name** : Path and name of the object" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d3e29150", - "metadata": {}, - "outputs": [], - "source": [ - "delete_object = naas_python.storage.delete_workspace_storage_object(\n", - " workspace_id=workspace_id,\n", - " storage_name=\"test-storage\",\n", - " object_name=\"directory-1/Naas_API_Storage.ipynb\"\n", - ")\n", - "delete_object" - ] - }, - { - "cell_type": "markdown", - "id": "c36cf34d", - "metadata": {}, - "source": [ - "result :\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Sucess'}}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "e1059713", - "metadata": {}, - "source": [ - "#### CLI" - ] - }, - { - "cell_type": "markdown", - "id": "7fe8b345", - "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 -} From e88d86846adda68ea00123c2b9ef2defd4467bcb Mon Sep 17 00:00:00 2001 From: "Loic L." Date: Tue, 2 Jul 2024 12:02:54 +0200 Subject: [PATCH 6/7] fix: cicd 2 --- Naas API/Naas_API_Create_Storage.ipynb | 2 +- Naas API/Naas_API_Create_Storage_Object.ipynb | 4 ++-- Naas API/Naas_API_Delete_Storage.ipynb | 2 +- Naas API/Naas_API_Delete_Storage_Object.ipynb | 2 +- Naas API/Naas_API_Get_Storage_Object.ipynb | 2 +- Naas API/Naas_API_List_Storage.ipynb | 2 +- Naas API/Naas_API_List_Storage_Object.ipynb | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Naas API/Naas_API_Create_Storage.ipynb b/Naas API/Naas_API_Create_Storage.ipynb index 6abc1e1c58..db7da9f346 100644 --- a/Naas API/Naas_API_Create_Storage.ipynb +++ b/Naas API/Naas_API_Create_Storage.ipynb @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { diff --git a/Naas API/Naas_API_Create_Storage_Object.ipynb b/Naas API/Naas_API_Create_Storage_Object.ipynb index 732cb12efe..17e5f9f3b4 100644 --- a/Naas API/Naas_API_Create_Storage_Object.ipynb +++ b/Naas API/Naas_API_Create_Storage_Object.ipynb @@ -13,7 +13,7 @@ "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", "metadata": {}, "source": [ - "# Naas API - Create Storage Object\n", + "## Naas API - Delete Storage Object\n", "Give Feedback | Bug report" ] }, @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { diff --git a/Naas API/Naas_API_Delete_Storage.ipynb b/Naas API/Naas_API_Delete_Storage.ipynb index 390bd90aa6..c2f5593129 100644 --- a/Naas API/Naas_API_Delete_Storage.ipynb +++ b/Naas API/Naas_API_Delete_Storage.ipynb @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { diff --git a/Naas API/Naas_API_Delete_Storage_Object.ipynb b/Naas API/Naas_API_Delete_Storage_Object.ipynb index 61157f2e37..b7d859b5c4 100644 --- a/Naas API/Naas_API_Delete_Storage_Object.ipynb +++ b/Naas API/Naas_API_Delete_Storage_Object.ipynb @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { diff --git a/Naas API/Naas_API_Get_Storage_Object.ipynb b/Naas API/Naas_API_Get_Storage_Object.ipynb index c96bd45e57..8c0fe9aa0a 100644 --- a/Naas API/Naas_API_Get_Storage_Object.ipynb +++ b/Naas API/Naas_API_Get_Storage_Object.ipynb @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { diff --git a/Naas API/Naas_API_List_Storage.ipynb b/Naas API/Naas_API_List_Storage.ipynb index a1fa9d7df2..24dee57058 100644 --- a/Naas API/Naas_API_List_Storage.ipynb +++ b/Naas API/Naas_API_List_Storage.ipynb @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { diff --git a/Naas API/Naas_API_List_Storage_Object.ipynb b/Naas API/Naas_API_List_Storage_Object.ipynb index d2c317af77..42620abeee 100644 --- a/Naas API/Naas_API_List_Storage_Object.ipynb +++ b/Naas API/Naas_API_List_Storage_Object.ipynb @@ -70,7 +70,7 @@ "id": "0de8d719", "metadata": {}, "source": [ - "# Input" + "## Input" ] }, { From eee6a8f45ef98c927fdae26f232af49d0ebea47c Mon Sep 17 00:00:00 2001 From: FlorentLvr Date: Tue, 2 Jul 2024 15:13:41 +0200 Subject: [PATCH 7/7] refactor: test notebook and change md --- Naas API/Naas_API_Create_Storage.ipynb | 29 +- Naas API/Naas_API_Create_Storage_Object.ipynb | 90 +++++- Naas API/Naas_API_Delete_Storage.ipynb | 63 ++++- Naas API/Naas_API_Delete_Storage_Object.ipynb | 22 +- Naas API/Naas_API_Get_Storage_Object.ipynb | 80 ++++-- Naas API/Naas_API_List_Storage_Object.ipynb | 244 ---------------- Naas API/Naas_API_List_Storage_Objects.ipynb | 267 ++++++++++++++++++ ...age.ipynb => Naas_API_List_Storages.ipynb} | 31 +- 8 files changed, 497 insertions(+), 329 deletions(-) delete mode 100644 Naas API/Naas_API_List_Storage_Object.ipynb create mode 100644 Naas API/Naas_API_List_Storage_Objects.ipynb rename Naas API/{Naas_API_List_Storage.ipynb => Naas_API_List_Storages.ipynb} (90%) diff --git a/Naas API/Naas_API_Create_Storage.ipynb b/Naas API/Naas_API_Create_Storage.ipynb index db7da9f346..810091386c 100644 --- a/Naas API/Naas_API_Create_Storage.ipynb +++ b/Naas API/Naas_API_Create_Storage.ipynb @@ -62,7 +62,7 @@ "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." + "**Description:** This notebook demonstrates how to create a workspace storage. A Workspace storage is the root of your data directory to set access permission." ] }, { @@ -86,7 +86,7 @@ } }, "source": [ - "### Import library" + "### Import libraries" ] }, { @@ -132,7 +132,7 @@ "source": [ "# Required\n", "\n", - "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "workspace_id = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"\n", "storage_name = \"test\"" ] }, @@ -179,10 +179,17 @@ "id": "0de0bf16", "metadata": {}, "source": [ - "### Display Result\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a114a720", + "metadata": {}, + "outputs": [], + "source": [ + "storage.get(\"storage\")" ] }, { @@ -199,12 +206,6 @@ "naas-python storage create -w 81507a26-3644-496c-a379-4c7021434aa0 -s test\n", "```" ] - }, - { - "cell_type": "markdown", - "id": "74502426", - "metadata": {}, - "source": [] } ], "metadata": { @@ -223,7 +224,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/Naas API/Naas_API_Create_Storage_Object.ipynb b/Naas API/Naas_API_Create_Storage_Object.ipynb index 17e5f9f3b4..6a5fcfb08e 100644 --- a/Naas API/Naas_API_Create_Storage_Object.ipynb +++ b/Naas API/Naas_API_Create_Storage_Object.ipynb @@ -13,7 +13,7 @@ "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", "metadata": {}, "source": [ - "## Naas API - Delete Storage Object\n", + "## Naas API - Create Storage Object\n", "Give Feedback | Bug report" ] }, @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "32fa0149", "metadata": {}, "outputs": [], @@ -125,7 +125,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", "metadata": { "tags": [] @@ -133,11 +133,10 @@ "outputs": [], "source": [ "# Required\n", - "\n", - "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "workspace_id = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"\n", "storage_name = \"test\"\n", - "src_file=\"Naas_API_Storage.ipynb\"\n", - "dst_file=\"directory-1/Naas_API_Storage.ipynb\"" + "src_file = \"Naas_API_Create_Storage.ipynb\"\n", + "dst_file = \"Naas_API_Create_Storage.ipynb\"" ] }, { @@ -158,10 +157,66 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "4856c7a5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
[07/02/24 15:05:36] ERROR    Parameter validation failed:                           S3StorageProviderAdaptor.py:279\n",
+       "                             Invalid type for parameter ContentType, value: None,                                  \n",
+       "                             type: <class 'NoneType'>, valid types: <class 'str'>                                  \n",
+       "
\n" + ], + "text/plain": [ + "\u001b[2;36m[07/02/24 15:05:36]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Parameter validation failed: \u001b]8;id=474969;file://C:\\Users\\flore\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py\u001b\\\u001b[2mS3StorageProviderAdaptor.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=752932;file://C:\\Users\\flore\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py#279\u001b\\\u001b[2m279\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m \u001b[0m Invalid type for parameter ContentType, value: \u001b[3;35mNone\u001b[0m, \u001b[2m \u001b[0m\n", + "\u001b[2;36m \u001b[0m type: \u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'NoneType'\u001b[0m\u001b[39m>, valid types: \u001b[0m \u001b[2m \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "ERROR:naas_python.domains.storage.adaptors.secondary.providers.S3StorageProviderAdaptor:Parameter validation failed:\n", + "Invalid type for parameter ContentType, value: None, type: , valid types: \n" + ] + }, + { + "ename": "Exception", + "evalue": "Parameter validation failed:\nInvalid type for parameter ContentType, value: None, type: , valid types: ", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mParamValidationError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py:68\u001b[0m, in \u001b[0;36mS3StorageProviderAdaptor.post_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 67\u001b[0m s3 \u001b[38;5;241m=\u001b[39m boto3\u001b[38;5;241m.\u001b[39mclient(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms3\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m---> 68\u001b[0m response \u001b[38;5;241m=\u001b[39m s3\u001b[38;5;241m.\u001b[39mupload_file(Filename\u001b[38;5;241m=\u001b[39msrc_file, Bucket\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnaas_bucket, Key\u001b[38;5;241m=\u001b[39mkey, ExtraArgs\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mContentType\u001b[39m\u001b[38;5;124m'\u001b[39m: content_type})\n\u001b[0;32m 69\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\boto3\\s3\\inject.py:145\u001b[0m, in \u001b[0;36mupload_file\u001b[1;34m(self, Filename, Bucket, Key, ExtraArgs, Callback, Config)\u001b[0m\n\u001b[0;32m 144\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m S3Transfer(\u001b[38;5;28mself\u001b[39m, Config) \u001b[38;5;28;01mas\u001b[39;00m transfer:\n\u001b[1;32m--> 145\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m transfer\u001b[38;5;241m.\u001b[39mupload_file(\n\u001b[0;32m 146\u001b[0m filename\u001b[38;5;241m=\u001b[39mFilename,\n\u001b[0;32m 147\u001b[0m bucket\u001b[38;5;241m=\u001b[39mBucket,\n\u001b[0;32m 148\u001b[0m key\u001b[38;5;241m=\u001b[39mKey,\n\u001b[0;32m 149\u001b[0m extra_args\u001b[38;5;241m=\u001b[39mExtraArgs,\n\u001b[0;32m 150\u001b[0m callback\u001b[38;5;241m=\u001b[39mCallback,\n\u001b[0;32m 151\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\boto3\\s3\\transfer.py:372\u001b[0m, in \u001b[0;36mS3Transfer.upload_file\u001b[1;34m(self, filename, bucket, key, callback, extra_args)\u001b[0m\n\u001b[0;32m 371\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 372\u001b[0m future\u001b[38;5;241m.\u001b[39mresult()\n\u001b[0;32m 373\u001b[0m \u001b[38;5;66;03m# If a client error was raised, add the backwards compatibility layer\u001b[39;00m\n\u001b[0;32m 374\u001b[0m \u001b[38;5;66;03m# that raises a S3UploadFailedError. These specific errors were only\u001b[39;00m\n\u001b[0;32m 375\u001b[0m \u001b[38;5;66;03m# ever thrown for upload_parts but now can be thrown for any related\u001b[39;00m\n\u001b[0;32m 376\u001b[0m \u001b[38;5;66;03m# client error.\u001b[39;00m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\futures.py:103\u001b[0m, in \u001b[0;36mTransferFuture.result\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 99\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 100\u001b[0m \u001b[38;5;66;03m# Usually the result() method blocks until the transfer is done,\u001b[39;00m\n\u001b[0;32m 101\u001b[0m \u001b[38;5;66;03m# however if a KeyboardInterrupt is raised we want want to exit\u001b[39;00m\n\u001b[0;32m 102\u001b[0m \u001b[38;5;66;03m# out of this and propagate the exception.\u001b[39;00m\n\u001b[1;32m--> 103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_coordinator\u001b[38;5;241m.\u001b[39mresult()\n\u001b[0;32m 104\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\futures.py:266\u001b[0m, in \u001b[0;36mTransferCoordinator.result\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 265\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_exception:\n\u001b[1;32m--> 266\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_exception\n\u001b[0;32m 267\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_result\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\tasks.py:139\u001b[0m, in \u001b[0;36mTask.__call__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 138\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_transfer_coordinator\u001b[38;5;241m.\u001b[39mdone():\n\u001b[1;32m--> 139\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_execute_main(kwargs)\n\u001b[0;32m 140\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\tasks.py:162\u001b[0m, in \u001b[0;36mTask._execute_main\u001b[1;34m(self, kwargs)\u001b[0m\n\u001b[0;32m 160\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExecuting task \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m with kwargs \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mkwargs_to_display\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m--> 162\u001b[0m return_value \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_main(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 163\u001b[0m \u001b[38;5;66;03m# If the task is the final task, then set the TransferFuture's\u001b[39;00m\n\u001b[0;32m 164\u001b[0m \u001b[38;5;66;03m# value to the return value from main().\u001b[39;00m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\upload.py:764\u001b[0m, in \u001b[0;36mPutObjectTask._main\u001b[1;34m(self, client, fileobj, bucket, key, extra_args)\u001b[0m\n\u001b[0;32m 763\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m fileobj \u001b[38;5;28;01mas\u001b[39;00m body:\n\u001b[1;32m--> 764\u001b[0m client\u001b[38;5;241m.\u001b[39mput_object(Bucket\u001b[38;5;241m=\u001b[39mbucket, Key\u001b[38;5;241m=\u001b[39mkey, Body\u001b[38;5;241m=\u001b[39mbody, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mextra_args)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\botocore\\client.py:565\u001b[0m, in \u001b[0;36mClientCreator._create_api_method.._api_call\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 564\u001b[0m \u001b[38;5;66;03m# The \"self\" in this scope is referring to the BaseClient.\u001b[39;00m\n\u001b[1;32m--> 565\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_make_api_call(operation_name, kwargs)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\botocore\\client.py:974\u001b[0m, in \u001b[0;36mBaseClient._make_api_call\u001b[1;34m(self, operation_name, api_params)\u001b[0m\n\u001b[0;32m 973\u001b[0m request_context[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mendpoint_properties\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m properties\n\u001b[1;32m--> 974\u001b[0m request_dict \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_convert_to_request_dict(\n\u001b[0;32m 975\u001b[0m api_params\u001b[38;5;241m=\u001b[39mapi_params,\n\u001b[0;32m 976\u001b[0m operation_model\u001b[38;5;241m=\u001b[39moperation_model,\n\u001b[0;32m 977\u001b[0m endpoint_url\u001b[38;5;241m=\u001b[39mendpoint_url,\n\u001b[0;32m 978\u001b[0m context\u001b[38;5;241m=\u001b[39mrequest_context,\n\u001b[0;32m 979\u001b[0m headers\u001b[38;5;241m=\u001b[39madditional_headers,\n\u001b[0;32m 980\u001b[0m )\n\u001b[0;32m 981\u001b[0m resolve_checksum_context(request_dict, operation_model, api_params)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\botocore\\client.py:1048\u001b[0m, in \u001b[0;36mBaseClient._convert_to_request_dict\u001b[1;34m(self, api_params, operation_model, endpoint_url, context, headers, set_user_agent_header)\u001b[0m\n\u001b[0;32m 1039\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_convert_to_request_dict\u001b[39m(\n\u001b[0;32m 1040\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 1041\u001b[0m api_params,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1046\u001b[0m set_user_agent_header\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[0;32m 1047\u001b[0m ):\n\u001b[1;32m-> 1048\u001b[0m request_dict \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_serializer\u001b[38;5;241m.\u001b[39mserialize_to_request(\n\u001b[0;32m 1049\u001b[0m api_params, operation_model\n\u001b[0;32m 1050\u001b[0m )\n\u001b[0;32m 1051\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_client_config\u001b[38;5;241m.\u001b[39minject_host_prefix:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\botocore\\validate.py:381\u001b[0m, in \u001b[0;36mParamValidationDecorator.serialize_to_request\u001b[1;34m(self, parameters, operation_model)\u001b[0m\n\u001b[0;32m 380\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m report\u001b[38;5;241m.\u001b[39mhas_errors():\n\u001b[1;32m--> 381\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ParamValidationError(report\u001b[38;5;241m=\u001b[39mreport\u001b[38;5;241m.\u001b[39mgenerate_report())\n\u001b[0;32m 382\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_serializer\u001b[38;5;241m.\u001b[39mserialize_to_request(\n\u001b[0;32m 383\u001b[0m parameters, operation_model\n\u001b[0;32m 384\u001b[0m )\n", + "\u001b[1;31mParamValidationError\u001b[0m: Parameter validation failed:\nInvalid type for parameter ContentType, value: None, type: , valid types: ", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mException\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[12], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mobject\u001b[39m \u001b[38;5;241m=\u001b[39m naas_python\u001b[38;5;241m.\u001b[39mstorage\u001b[38;5;241m.\u001b[39mpost_workspace_storage_object(\n\u001b[0;32m 2\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 3\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 4\u001b[0m src_file\u001b[38;5;241m=\u001b[39msrc_file,\n\u001b[0;32m 5\u001b[0m dst_file\u001b[38;5;241m=\u001b[39mdst_file\n\u001b[0;32m 6\u001b[0m )\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28mobject\u001b[39m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\primary\\SDKStorageAdaptor.py:77\u001b[0m, in \u001b[0;36mSDKStorageAdaptor.post_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 70\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mpost_workspace_storage_object\u001b[39m(\u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 71\u001b[0m workspace_id: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \n\u001b[0;32m 72\u001b[0m storage_name: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 73\u001b[0m src_file: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 74\u001b[0m dst_file: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 75\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mbytes\u001b[39m:\n\u001b[0;32m 76\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39misfile(src_file):\n\u001b[1;32m---> 77\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdomain\u001b[38;5;241m.\u001b[39mpost_workspace_storage_object(\n\u001b[0;32m 78\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 79\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 80\u001b[0m src_file\u001b[38;5;241m=\u001b[39msrc_file,\n\u001b[0;32m 81\u001b[0m dst_file\u001b[38;5;241m=\u001b[39mdst_file,\n\u001b[0;32m 82\u001b[0m )\n\u001b[0;32m 83\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response \n\u001b[0;32m 84\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\StorageDomain.py:117\u001b[0m, in \u001b[0;36mStorageDomain.post_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 114\u001b[0m credentials \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39madaptor\u001b[38;5;241m.\u001b[39mgenerate_credentials(workspace_id, storage_name)\n\u001b[0;32m 115\u001b[0m storage_provider\u001b[38;5;241m.\u001b[39msave_naas_credentials(workspace_id, storage_name, credentials)\n\u001b[1;32m--> 117\u001b[0m response \u001b[38;5;241m=\u001b[39m storage_provider\u001b[38;5;241m.\u001b[39mpost_workspace_storage_object(workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id, storage_name\u001b[38;5;241m=\u001b[39mstorage_name, src_file\u001b[38;5;241m=\u001b[39msrc_file, dst_file\u001b[38;5;241m=\u001b[39mdst_file)\n\u001b[0;32m 118\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py:71\u001b[0m, in \u001b[0;36mS3StorageProviderAdaptor.post_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 69\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n\u001b[0;32m 70\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m---> 71\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m__handle_exceptions(\u001b[38;5;28mstr\u001b[39m(e))\n\u001b[0;32m 72\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py:280\u001b[0m, in \u001b[0;36mS3StorageProviderAdaptor.__handle_exceptions\u001b[1;34m(self, exception)\u001b[0m\n\u001b[0;32m 278\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m :\n\u001b[0;32m 279\u001b[0m logger\u001b[38;5;241m.\u001b[39merror(exception)\n\u001b[1;32m--> 280\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m(exception)\n", + "\u001b[1;31mException\u001b[0m: Parameter validation failed:\nInvalid type for parameter ContentType, value: None, type: , valid types: " + ] + } + ], "source": [ "object = naas_python.storage.post_workspace_storage_object(\n", " workspace_id=workspace_id,\n", @@ -185,10 +240,17 @@ "id": "0de0bf16", "metadata": {}, "source": [ - "### Display Result\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "00846a42", + "metadata": {}, + "outputs": [], + "source": [ + "object" ] }, { @@ -234,7 +296,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/Naas API/Naas_API_Delete_Storage.ipynb b/Naas API/Naas_API_Delete_Storage.ipynb index c2f5593129..c1326a4187 100644 --- a/Naas API/Naas_API_Delete_Storage.ipynb +++ b/Naas API/Naas_API_Delete_Storage.ipynb @@ -91,10 +91,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "32fa0149", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "ERROR:root:Failed to remove log file \\\\wsl.localhost\\Ubuntu\\home\\florentlvr\\awesome-notebooks\\Naas API\\.logs\\2024-07-02_14-42-13.log: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\\\\\wsl.localhost\\\\Ubuntu\\\\home\\\\florentlvr\\\\awesome-notebooks\\\\Naas API\\\\.logs\\\\2024-07-02_14-42-13.log'\n" + ] + } + ], "source": [ "try:\n", " import naas_python\n", @@ -123,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", "metadata": { "tags": [] @@ -132,7 +140,7 @@ "source": [ "# Required\n", "\n", - "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"\n", + "workspace_id = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"\n", "storage_name = \"test\"" ] }, @@ -154,16 +162,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "4856c7a5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'error': {'error': 0, 'message': 'Success'}}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "deleted_storage = naas_python.storage.delete_workspace_storage(\n", + "storage = naas_python.storage.delete_workspace_storage(\n", " workspace_id=workspace_id,\n", " storage_name=storage_name,\n", ")\n", - "deleted_storage" + "storage" ] }, { @@ -179,10 +198,28 @@ "id": "0de0bf16", "metadata": {}, "source": [ - "### Display Result\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "74bc635f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'error': {'error': 0, 'message': 'Success'}}" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "storage" ] }, { @@ -217,7 +254,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/Naas API/Naas_API_Delete_Storage_Object.ipynb b/Naas API/Naas_API_Delete_Storage_Object.ipynb index b7d859b5c4..4e78dd97c2 100644 --- a/Naas API/Naas_API_Delete_Storage_Object.ipynb +++ b/Naas API/Naas_API_Delete_Storage_Object.ipynb @@ -132,10 +132,9 @@ "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\"" + "object_name = \"directory-1/Naas_API_Storage.ipynb\"" ] }, { @@ -161,12 +160,12 @@ "metadata": {}, "outputs": [], "source": [ - "delete_object = naas_python.storage.delete_workspace_storage_object(\n", + "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" + "object" ] }, { @@ -182,10 +181,17 @@ "id": "0de0bf16", "metadata": {}, "source": [ - "### Display Result\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d10f7de5", + "metadata": {}, + "outputs": [], + "source": [ + "object" ] }, { diff --git a/Naas API/Naas_API_Get_Storage_Object.ipynb b/Naas API/Naas_API_Get_Storage_Object.ipynb index 8c0fe9aa0a..d56f721dd0 100644 --- a/Naas API/Naas_API_Get_Storage_Object.ipynb +++ b/Naas API/Naas_API_Get_Storage_Object.ipynb @@ -62,7 +62,7 @@ "id": "b3ed8dac", "metadata": {}, "source": [ - "**Description:** Download an object from your Naas Storage." + "**Description:** This notebook downloads an object from your Naas Storage." ] }, { @@ -86,15 +86,23 @@ } }, "source": [ - "### Import library" + "### Import libraries" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "32fa0149", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "ERROR:root:Failed to remove log file \\\\wsl.localhost\\Ubuntu\\home\\florentlvr\\awesome-notebooks\\Naas API\\.logs\\2024-07-02_14-42-13.log: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\\\\\wsl.localhost\\\\Ubuntu\\\\home\\\\florentlvr\\\\awesome-notebooks\\\\Naas API\\\\.logs\\\\2024-07-02_14-42-13.log'\n" + ] + } + ], "source": [ "try:\n", " import naas_python\n", @@ -125,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", "metadata": { "tags": [] @@ -133,11 +141,10 @@ "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\"" + "workspace_id = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"\n", + "storage_name = \"test\"\n", + "src_file = \"Naas_API_Create_Storage.ipynb\"\n", + "dst_file = \"Naas_API_Create_Storage.ipynb\"" ] }, { @@ -158,18 +165,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "4856c7a5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "FileNotFoundError", + "evalue": "[FileNotFoundError]: File not found.", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mClientError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py:98\u001b[0m, in \u001b[0;36mS3StorageProviderAdaptor.get_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 97\u001b[0m s3 \u001b[38;5;241m=\u001b[39m boto3\u001b[38;5;241m.\u001b[39mclient(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms3\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m---> 98\u001b[0m response \u001b[38;5;241m=\u001b[39m s3\u001b[38;5;241m.\u001b[39mdownload_file(Bucket\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnaas_bucket , Key\u001b[38;5;241m=\u001b[39mobject_key, Filename\u001b[38;5;241m=\u001b[39mfilename)\n\u001b[0;32m 99\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\boto3\\s3\\inject.py:192\u001b[0m, in \u001b[0;36mdownload_file\u001b[1;34m(self, Bucket, Key, Filename, ExtraArgs, Callback, Config)\u001b[0m\n\u001b[0;32m 191\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m S3Transfer(\u001b[38;5;28mself\u001b[39m, Config) \u001b[38;5;28;01mas\u001b[39;00m transfer:\n\u001b[1;32m--> 192\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m transfer\u001b[38;5;241m.\u001b[39mdownload_file(\n\u001b[0;32m 193\u001b[0m bucket\u001b[38;5;241m=\u001b[39mBucket,\n\u001b[0;32m 194\u001b[0m key\u001b[38;5;241m=\u001b[39mKey,\n\u001b[0;32m 195\u001b[0m filename\u001b[38;5;241m=\u001b[39mFilename,\n\u001b[0;32m 196\u001b[0m extra_args\u001b[38;5;241m=\u001b[39mExtraArgs,\n\u001b[0;32m 197\u001b[0m callback\u001b[38;5;241m=\u001b[39mCallback,\n\u001b[0;32m 198\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\boto3\\s3\\transfer.py:406\u001b[0m, in \u001b[0;36mS3Transfer.download_file\u001b[1;34m(self, bucket, key, filename, extra_args, callback)\u001b[0m\n\u001b[0;32m 405\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 406\u001b[0m future\u001b[38;5;241m.\u001b[39mresult()\n\u001b[0;32m 407\u001b[0m \u001b[38;5;66;03m# This is for backwards compatibility where when retries are\u001b[39;00m\n\u001b[0;32m 408\u001b[0m \u001b[38;5;66;03m# exceeded we need to throw the same error from boto3 instead of\u001b[39;00m\n\u001b[0;32m 409\u001b[0m \u001b[38;5;66;03m# s3transfer's built in RetriesExceededError as current users are\u001b[39;00m\n\u001b[0;32m 410\u001b[0m \u001b[38;5;66;03m# catching the boto3 one instead of the s3transfer exception to do\u001b[39;00m\n\u001b[0;32m 411\u001b[0m \u001b[38;5;66;03m# their own retries.\u001b[39;00m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\futures.py:103\u001b[0m, in \u001b[0;36mTransferFuture.result\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 99\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 100\u001b[0m \u001b[38;5;66;03m# Usually the result() method blocks until the transfer is done,\u001b[39;00m\n\u001b[0;32m 101\u001b[0m \u001b[38;5;66;03m# however if a KeyboardInterrupt is raised we want want to exit\u001b[39;00m\n\u001b[0;32m 102\u001b[0m \u001b[38;5;66;03m# out of this and propagate the exception.\u001b[39;00m\n\u001b[1;32m--> 103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_coordinator\u001b[38;5;241m.\u001b[39mresult()\n\u001b[0;32m 104\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\futures.py:266\u001b[0m, in \u001b[0;36mTransferCoordinator.result\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 265\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_exception:\n\u001b[1;32m--> 266\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_exception\n\u001b[0;32m 267\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_result\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\tasks.py:269\u001b[0m, in \u001b[0;36mSubmissionTask._main\u001b[1;34m(self, transfer_future, **kwargs)\u001b[0m\n\u001b[0;32m 267\u001b[0m \u001b[38;5;66;03m# Call the submit method to start submitting tasks to execute the\u001b[39;00m\n\u001b[0;32m 268\u001b[0m \u001b[38;5;66;03m# transfer.\u001b[39;00m\n\u001b[1;32m--> 269\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_submit(transfer_future\u001b[38;5;241m=\u001b[39mtransfer_future, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 270\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 271\u001b[0m \u001b[38;5;66;03m# If there was an exception raised during the submission of task\u001b[39;00m\n\u001b[0;32m 272\u001b[0m \u001b[38;5;66;03m# there is a chance that the final task that signals if a transfer\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 281\u001b[0m \n\u001b[0;32m 282\u001b[0m \u001b[38;5;66;03m# Set the exception, that caused the process to fail.\u001b[39;00m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\s3transfer\\download.py:354\u001b[0m, in \u001b[0;36mDownloadSubmissionTask._submit\u001b[1;34m(self, client, config, osutil, request_executor, io_executor, transfer_future, bandwidth_limiter)\u001b[0m\n\u001b[0;32m 351\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m transfer_future\u001b[38;5;241m.\u001b[39mmeta\u001b[38;5;241m.\u001b[39msize \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 352\u001b[0m \u001b[38;5;66;03m# If a size was not provided figure out the size for the\u001b[39;00m\n\u001b[0;32m 353\u001b[0m \u001b[38;5;66;03m# user.\u001b[39;00m\n\u001b[1;32m--> 354\u001b[0m response \u001b[38;5;241m=\u001b[39m client\u001b[38;5;241m.\u001b[39mhead_object(\n\u001b[0;32m 355\u001b[0m Bucket\u001b[38;5;241m=\u001b[39mtransfer_future\u001b[38;5;241m.\u001b[39mmeta\u001b[38;5;241m.\u001b[39mcall_args\u001b[38;5;241m.\u001b[39mbucket,\n\u001b[0;32m 356\u001b[0m Key\u001b[38;5;241m=\u001b[39mtransfer_future\u001b[38;5;241m.\u001b[39mmeta\u001b[38;5;241m.\u001b[39mcall_args\u001b[38;5;241m.\u001b[39mkey,\n\u001b[0;32m 357\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mtransfer_future\u001b[38;5;241m.\u001b[39mmeta\u001b[38;5;241m.\u001b[39mcall_args\u001b[38;5;241m.\u001b[39mextra_args,\n\u001b[0;32m 358\u001b[0m )\n\u001b[0;32m 359\u001b[0m transfer_future\u001b[38;5;241m.\u001b[39mmeta\u001b[38;5;241m.\u001b[39mprovide_transfer_size(\n\u001b[0;32m 360\u001b[0m response[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mContentLength\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m 361\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\botocore\\client.py:565\u001b[0m, in \u001b[0;36mClientCreator._create_api_method.._api_call\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 564\u001b[0m \u001b[38;5;66;03m# The \"self\" in this scope is referring to the BaseClient.\u001b[39;00m\n\u001b[1;32m--> 565\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_make_api_call(operation_name, kwargs)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\botocore\\client.py:1021\u001b[0m, in \u001b[0;36mBaseClient._make_api_call\u001b[1;34m(self, operation_name, api_params)\u001b[0m\n\u001b[0;32m 1020\u001b[0m error_class \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexceptions\u001b[38;5;241m.\u001b[39mfrom_code(error_code)\n\u001b[1;32m-> 1021\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error_class(parsed_response, operation_name)\n\u001b[0;32m 1022\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n", + "\u001b[1;31mClientError\u001b[0m: An error occurred (404) when calling the HeadObject operation: Not Found", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[3], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mobject\u001b[39m \u001b[38;5;241m=\u001b[39m naas_python\u001b[38;5;241m.\u001b[39mstorage\u001b[38;5;241m.\u001b[39mget_workspace_storage_object(\n\u001b[0;32m 2\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 3\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 4\u001b[0m src_file\u001b[38;5;241m=\u001b[39msrc_file,\n\u001b[0;32m 5\u001b[0m dst_file\u001b[38;5;241m=\u001b[39mdst_file\n\u001b[0;32m 6\u001b[0m )\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28mobject\u001b[39m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\primary\\SDKStorageAdaptor.py:94\u001b[0m, in \u001b[0;36mSDKStorageAdaptor.get_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 87\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_workspace_storage_object\u001b[39m(\u001b[38;5;28mself\u001b[39m, \n\u001b[0;32m 88\u001b[0m workspace_id: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \n\u001b[0;32m 89\u001b[0m storage_name: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 90\u001b[0m src_file: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 91\u001b[0m dst_file: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 92\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mbytes\u001b[39m:\n\u001b[1;32m---> 94\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdomain\u001b[38;5;241m.\u001b[39mget_workspace_storage_object(\n\u001b[0;32m 95\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 96\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 97\u001b[0m src_file\u001b[38;5;241m=\u001b[39msrc_file,\n\u001b[0;32m 98\u001b[0m dst_file\u001b[38;5;241m=\u001b[39mdst_file,\n\u001b[0;32m 99\u001b[0m )\n\u001b[0;32m 100\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\StorageDomain.py:138\u001b[0m, in \u001b[0;36mStorageDomain.get_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 135\u001b[0m credentials \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39madaptor\u001b[38;5;241m.\u001b[39mgenerate_credentials(workspace_id, storage_name)\n\u001b[0;32m 136\u001b[0m storage_provider\u001b[38;5;241m.\u001b[39msave_naas_credentials(workspace_id, storage_name, credentials)\n\u001b[1;32m--> 138\u001b[0m response \u001b[38;5;241m=\u001b[39m storage_provider\u001b[38;5;241m.\u001b[39mget_workspace_storage_object(workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id, storage_name\u001b[38;5;241m=\u001b[39mstorage_name, src_file\u001b[38;5;241m=\u001b[39msrc_file, dst_file\u001b[38;5;241m=\u001b[39mdst_file)\n\u001b[0;32m 139\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py:102\u001b[0m, in \u001b[0;36mS3StorageProviderAdaptor.get_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, src_file, dst_file)\u001b[0m\n\u001b[0;32m 99\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n\u001b[0;32m 101\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 102\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m__handle_exceptions(\u001b[38;5;28mstr\u001b[39m(e))\n\u001b[0;32m 103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\providers\\S3StorageProviderAdaptor.py:265\u001b[0m, in \u001b[0;36mS3StorageProviderAdaptor.__handle_exceptions\u001b[1;34m(self, exception)\u001b[0m\n\u001b[0;32m 263\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m BadRequest(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mBad request. Please retry in few seconds.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 264\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAn error occurred (404)\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m exception \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNot Found\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m exception:\n\u001b[1;32m--> 265\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFile not found.\u001b[39m\u001b[38;5;124m\"\u001b[39m) \n\u001b[0;32m 266\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFilename must be a string or a path-like object\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m exception:\n\u001b[0;32m 267\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFile not found. Must be a string or a path-like object\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[1;31mFileNotFoundError\u001b[0m: [FileNotFoundError]: File not found." + ] + } + ], "source": [ - "get_object = naas_python.storage.get_workspace_storage_object(\n", + "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" + "object" ] }, { @@ -185,10 +220,17 @@ "id": "0de0bf16", "metadata": {}, "source": [ - "### Display Result\n", - "```json\n", - "{'error': {'error': 0, 'message': 'Success'}}\n", - "```" + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "53a76c73", + "metadata": {}, + "outputs": [], + "source": [ + "object" ] }, { @@ -234,7 +276,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/Naas API/Naas_API_List_Storage_Object.ipynb b/Naas API/Naas_API_List_Storage_Object.ipynb deleted file mode 100644 index 42620abeee..0000000000 --- a/Naas API/Naas_API_List_Storage_Object.ipynb +++ /dev/null @@ -1,244 +0,0 @@ -{ - "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 -} diff --git a/Naas API/Naas_API_List_Storage_Objects.ipynb b/Naas API/Naas_API_List_Storage_Objects.ipynb new file mode 100644 index 0000000000..ca03cbf4ee --- /dev/null +++ b/Naas API/Naas_API_List_Storage_Objects.ipynb @@ -0,0 +1,267 @@ +{ + "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 Objects\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 objects 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 libraries" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "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": 14, + "id": "97463fa6-6044-4e69-b4ea-59fc0b243dbd", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Required\n", + "\n", + "workspace_id = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"\n", + "storage_name = \"abi\"\n", + "storage_prefix = \"datalake\"" + ] + }, + { + "cell_type": "markdown", + "id": "627f23e2", + "metadata": {}, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "482962ed", + "metadata": {}, + "source": [ + "### List Storage Object" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4856c7a5", + "metadata": {}, + "outputs": [ + { + "ename": "ServiceAuthenticationError", + "evalue": "[ServiceAuthenticationError]: Unable to authenticate with the service. Please check your credentials and try again. Details: Not authenticated", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\utils\\domains_base\\secondary\\BaseAPIAdaptor.py:88\u001b[0m, in \u001b[0;36mBaseAPIAdaptor.make_api_request\u001b[1;34m(self, method, url, token, payload, headers)\u001b[0m\n\u001b[0;32m 87\u001b[0m api_response \u001b[38;5;241m=\u001b[39m method(url, data\u001b[38;5;241m=\u001b[39mpayload \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mtype\u001b[39m(payload) \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28mstr\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m json\u001b[38;5;241m.\u001b[39mdumps(payload), headers\u001b[38;5;241m=\u001b[39mheaders)\n\u001b[1;32m---> 88\u001b[0m api_response\u001b[38;5;241m.\u001b[39mraise_for_status()\n\u001b[0;32m 89\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m api_response\n", + "File \u001b[1;32mc:\\Users\\flore\\anaconda3\\Lib\\site-packages\\requests\\models.py:1021\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1020\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1021\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 401 Client Error: Unauthorized for url: https://api.naas.ai/workspace/39e3601a-6f8e-412e-9bd7-1ae772bdc10b/storage/abi/?prefix=datalake", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mServiceAuthenticationError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[15], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m objects \u001b[38;5;241m=\u001b[39m naas_python\u001b[38;5;241m.\u001b[39mstorage\u001b[38;5;241m.\u001b[39mlist_workspace_storage_object(\n\u001b[0;32m 2\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 3\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 4\u001b[0m storage_prefix\u001b[38;5;241m=\u001b[39mstorage_prefix,\n\u001b[0;32m 5\u001b[0m )\n\u001b[0;32m 6\u001b[0m objects\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\primary\\SDKStorageAdaptor.py:49\u001b[0m, in \u001b[0;36mSDKStorageAdaptor.list_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, storage_prefix)\u001b[0m\n\u001b[0;32m 44\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mlist_workspace_storage_object\u001b[39m(\u001b[38;5;28mself\u001b[39m, \n\u001b[0;32m 45\u001b[0m workspace_id: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \n\u001b[0;32m 46\u001b[0m storage_name: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \n\u001b[0;32m 47\u001b[0m storage_prefix: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mstr\u001b[39m:\n\u001b[1;32m---> 49\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdomain\u001b[38;5;241m.\u001b[39mlist_workspace_storage_object(\n\u001b[0;32m 50\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 51\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 52\u001b[0m storage_prefix\u001b[38;5;241m=\u001b[39mstorage_prefix,\n\u001b[0;32m 53\u001b[0m )\n\u001b[0;32m 54\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\StorageDomain.py:54\u001b[0m, in \u001b[0;36mStorageDomain.list_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, storage_prefix)\u001b[0m\n\u001b[0;32m 49\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mlist_workspace_storage_object\u001b[39m(\u001b[38;5;28mself\u001b[39m, \n\u001b[0;32m 50\u001b[0m workspace_id: \u001b[38;5;28mstr\u001b[39m, \n\u001b[0;32m 51\u001b[0m storage_name: Storage\u001b[38;5;241m.\u001b[39m__fields__[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m],\n\u001b[0;32m 52\u001b[0m storage_prefix: Object\u001b[38;5;241m.\u001b[39m__fields__[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mprefix\u001b[39m\u001b[38;5;124m'\u001b[39m],\n\u001b[0;32m 53\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mdict\u001b[39m:\n\u001b[1;32m---> 54\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39madaptor\u001b[38;5;241m.\u001b[39mlist_workspace_storage_object(\n\u001b[0;32m 55\u001b[0m workspace_id\u001b[38;5;241m=\u001b[39mworkspace_id,\n\u001b[0;32m 56\u001b[0m storage_name\u001b[38;5;241m=\u001b[39mstorage_name,\n\u001b[0;32m 57\u001b[0m storage_prefix\u001b[38;5;241m=\u001b[39mstorage_prefix,\n\u001b[0;32m 58\u001b[0m )\n\u001b[0;32m 59\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\utils\\domains_base\\secondary\\BaseAPIAdaptor.py:63\u001b[0m, in \u001b[0;36mBaseAPIAdaptor.service_status_decorator..wrapper\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 61\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m 62\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_service_status()\n\u001b[1;32m---> 63\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\domains\\storage\\adaptors\\secondary\\NaasStorageAPIAdaptor.py:86\u001b[0m, in \u001b[0;36mNaasStorageAPIAdaptor.list_workspace_storage_object\u001b[1;34m(self, workspace_id, storage_name, storage_prefix)\u001b[0m\n\u001b[0;32m 78\u001b[0m \u001b[38;5;129m@BaseAPIAdaptor\u001b[39m\u001b[38;5;241m.\u001b[39mservice_status_decorator\n\u001b[0;32m 79\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mlist_workspace_storage_object\u001b[39m(\u001b[38;5;28mself\u001b[39m, \n\u001b[0;32m 80\u001b[0m workspace_id: \u001b[38;5;28mstr\u001b[39m, \n\u001b[0;32m 81\u001b[0m storage_name: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m 82\u001b[0m storage_prefix: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m 83\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mdict\u001b[39m:\n\u001b[0;32m 84\u001b[0m _url \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhost\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/workspace/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mworkspace_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/storage/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mstorage_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m?prefix=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mstorage_prefix\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m---> 86\u001b[0m api_response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmake_api_request(\n\u001b[0;32m 87\u001b[0m requests\u001b[38;5;241m.\u001b[39mget,\n\u001b[0;32m 88\u001b[0m _url,\n\u001b[0;32m 89\u001b[0m )\n\u001b[0;32m 90\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m__handle_response(api_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\naas_python\\utils\\domains_base\\secondary\\BaseAPIAdaptor.py:101\u001b[0m, in \u001b[0;36mBaseAPIAdaptor.make_api_request\u001b[1;34m(self, method, url, token, payload, headers)\u001b[0m\n\u001b[0;32m 99\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 100\u001b[0m _message \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnauthorized\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m--> 101\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ServiceAuthenticationError(\n\u001b[0;32m 102\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnable to authenticate with the service. Please check your credentials and try again. Details: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m_message\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 103\u001b[0m e,\n\u001b[0;32m 104\u001b[0m )\n\u001b[0;32m 105\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m api_response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m500\u001b[39m:\n\u001b[0;32m 106\u001b[0m _message \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "\u001b[1;31mServiceAuthenticationError\u001b[0m: [ServiceAuthenticationError]: Unable to authenticate with the service. Please check your credentials and try again. Details: Not authenticated" + ] + } + ], + "source": [ + "objects = naas_python.storage.list_workspace_storage_object(\n", + " workspace_id=workspace_id,\n", + " storage_name=storage_name,\n", + " storage_prefix=storage_prefix,\n", + ")\n", + "objects" + ] + }, + { + "cell_type": "markdown", + "id": "dcfa8e9c", + "metadata": {}, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "0de0bf16", + "metadata": {}, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b47f4c6c", + "metadata": {}, + "outputs": [], + "source": [ + "objects" + ] + }, + { + "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.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Naas API/Naas_API_List_Storage.ipynb b/Naas API/Naas_API_List_Storages.ipynb similarity index 90% rename from Naas API/Naas_API_List_Storage.ipynb rename to Naas API/Naas_API_List_Storages.ipynb index 24dee57058..0bf950d878 100644 --- a/Naas API/Naas_API_List_Storage.ipynb +++ b/Naas API/Naas_API_List_Storages.ipynb @@ -13,7 +13,7 @@ "id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", "metadata": {}, "source": [ - "# Naas API - List Storage\n", + "# Naas API - List Storages\n", "Give Feedback | Bug report" ] }, @@ -86,7 +86,7 @@ } }, "source": [ - "### Import library" + "### Import libraries" ] }, { @@ -131,7 +131,7 @@ "source": [ "# Required\n", "\n", - "workspace_id = \"f7a7e3a4-6435-48bc-8da3-88d46161c2b8\"" + "workspace_id = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"" ] }, { @@ -147,7 +147,7 @@ "id": "482962ed", "metadata": {}, "source": [ - "### Delete storage" + "### List storage" ] }, { @@ -157,10 +157,10 @@ "metadata": {}, "outputs": [], "source": [ - "storage_list = naas_python.storage.list_workspace_storage(\n", + "storage = naas_python.storage.list_workspace_storage(\n", " workspace_id=workspace_id\n", ")\n", - "storage_list" + "storage" ] }, { @@ -176,21 +176,18 @@ "id": "0de0bf16", "metadata": {}, "source": [ - "### Display Result" + "### Display result" ] }, { - "cell_type": "markdown", - "id": "e4761017", + "cell_type": "code", + "execution_count": null, + "id": "331f945c", "metadata": {}, + "outputs": [], "source": [ - "```json\n", - "{'storage': [{'name': 'test-storage'},\n", - " {'name': 'test-storage2'},\n", - " {'name': 'test'},\n", - " {'name': 'testlib'}],\n", - " 'error': {'error': 0, 'message': 'Sucess'}}\n", - "```" + "storage_list = storage.get(\"storage\")\n", + "storage_list" ] }, { @@ -225,7 +222,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4,