-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2537 from jupyter-naas/2523-feat-create-notebooks…
…-for-crud-operations-using-naas-python-for-storage feat: Naas Storage API notebook
- Loading branch information
Showing
7 changed files
with
1,823 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "28d10a4c-3c77-4088-9b67-db6e5f1ee7f0", | ||
"metadata": {}, | ||
"source": [ | ||
"<img width=\"8%\" alt=\"Naas API.png\" src=\"https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/Naas%20API.png\" style=\"border-radius: 15%\">" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "90cdfd58-d74b-4ec9-aea8-72fe64903f81", | ||
"metadata": {}, | ||
"source": [ | ||
"## Naas API - Create Storage\n", | ||
"<a href=\"https://bit.ly/3JyWIk6\">Give Feedback</a> | <a href=\"https://github.com/jupyter-naas/awesome-notebooks/issues/new?assignees=&labels=bug&template=bug_report.md&title=Naas+API+-+Update+Asset:+Error+short+description\">Bug report</a>" | ||
] | ||
}, | ||
{ | ||
"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 libraries" | ||
] | ||
}, | ||
{ | ||
"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 = \"39e3601a-6f8e-412e-9bd7-1ae772bdc10b\"\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" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a114a720", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"storage.get(\"storage\")" | ||
] | ||
}, | ||
{ | ||
"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", | ||
"```" | ||
] | ||
} | ||
], | ||
"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 | ||
} |
Oops, something went wrong.