Skip to content

Commit 8dab024

Browse files
committed
feat: use naas_python to add or update secrets
1 parent 70ba52d commit 8dab024

File tree

2 files changed

+18
-57
lines changed

2 files changed

+18
-57
lines changed

Naas/Naas_Add_or_Update_Asset.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,4 @@
264264
},
265265
"nbformat": 4,
266266
"nbformat_minor": 5
267-
}
267+
}

Naas/Naas_Add_or_Update_Secret.ipynb

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"tags": []
5454
},
5555
"source": [
56-
"**Last update:** 2023-05-24 (Created: 2023-05-24)"
56+
"**Last update:** 2024-06-18 (Created: 2023-05-24)"
5757
]
5858
},
5959
{
@@ -64,11 +64,7 @@
6464
"tags": []
6565
},
6666
"source": [
67-
"**Description:** This notebook will show how to add or uppdate a secret to Naas.\n",
68-
"\n",
69-
"Secrets are an important part of Naas, when you need to interact with other services, you need secret, like any other variable the temptation is big to put it straight in your notebook, but this lead to a big security breach since we replicate a lot the notebook, in the versioning system, the output and your ability to share it or send it to git! \n",
70-
"Use this simple feature instead to have global secure storage share with your sandbox and production.\n",
71-
"Secrets are local to your machine and encoded, that a big layer of security with a little effort."
67+
"**Description:** This notebook will show how to add or uppdate a secret to Naas."
7268
]
7369
},
7470
{
@@ -108,22 +104,19 @@
108104
},
109105
{
110106
"cell_type": "code",
111-
"execution_count": 1,
107+
"execution_count": null,
112108
"id": "90760955-5133-4c1a-a43b-e3dee1a02f44",
113109
"metadata": {
114-
"execution": {
115-
"iopub.execute_input": "2024-06-11T22:58:42.589746Z",
116-
"iopub.status.busy": "2024-06-11T22:58:42.589298Z",
117-
"iopub.status.idle": "2024-06-11T22:58:47.313182Z",
118-
"shell.execute_reply": "2024-06-11T22:58:47.312445Z",
119-
"shell.execute_reply.started": "2024-06-11T22:58:42.589666Z"
120-
},
121110
"papermill": {},
122111
"tags": []
123112
},
124113
"outputs": [],
125114
"source": [
126-
"import naas"
115+
"try:\n",
116+
" import naas_python\n",
117+
"except:\n",
118+
" !pip install naas-python --user\n",
119+
" import naas_python"
127120
]
128121
},
129122
{
@@ -134,30 +127,23 @@
134127
"tags": []
135128
},
136129
"source": [
137-
"### Setup Variables\n",
130+
"### Setup variables\n",
138131
"- `naas_secret_name`: Name of the secret to add\n",
139132
"- `naas_secret_value`: Value of the secret to add"
140133
]
141134
},
142135
{
143136
"cell_type": "code",
144-
"execution_count": 5,
137+
"execution_count": null,
145138
"id": "ddca8d9b-a981-4b11-82be-80ccd7d9b2b6",
146139
"metadata": {
147-
"execution": {
148-
"iopub.execute_input": "2024-06-11T23:02:22.675682Z",
149-
"iopub.status.busy": "2024-06-11T23:02:22.675455Z",
150-
"iopub.status.idle": "2024-06-11T23:02:22.678569Z",
151-
"shell.execute_reply": "2024-06-11T23:02:22.677924Z",
152-
"shell.execute_reply.started": "2024-06-11T23:02:22.675659Z"
153-
},
154140
"papermill": {},
155141
"tags": []
156142
},
157143
"outputs": [],
158144
"source": [
159-
"naas_secret_name = \"GITHUB_TOKEN\"\n",
160-
"naas_secret_value = \"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\""
145+
"naas_secret_name = \"YOUR_SECRET_NAME\"\n",
146+
"naas_secret_value = \"YOUR_SECRET_VALUE\""
161147
]
162148
},
163149
{
@@ -184,22 +170,15 @@
184170
},
185171
{
186172
"cell_type": "code",
187-
"execution_count": 6,
173+
"execution_count": null,
188174
"id": "f30c11f1-d027-4a13-86e3-49f408e46e6b",
189175
"metadata": {
190-
"execution": {
191-
"iopub.execute_input": "2024-06-11T23:02:25.648567Z",
192-
"iopub.status.busy": "2024-06-11T23:02:25.648266Z",
193-
"iopub.status.idle": "2024-06-11T23:02:27.948988Z",
194-
"shell.execute_reply": "2024-06-11T23:02:27.948095Z",
195-
"shell.execute_reply.started": "2024-06-11T23:02:25.648534Z"
196-
},
197176
"papermill": {},
198177
"tags": []
199178
},
200179
"outputs": [],
201180
"source": [
202-
"naas.secret.add(naas_secret_name, naas_secret_value)"
181+
"naas_python.secret.add(naas_secret_name, naas_secret_value)"
203182
]
204183
},
205184
{
@@ -227,33 +206,15 @@
227206
},
228207
{
229208
"cell_type": "code",
230-
"execution_count": 7,
209+
"execution_count": null,
231210
"id": "40de06c9-967a-4ac9-886e-a1c943e42308",
232211
"metadata": {
233-
"execution": {
234-
"iopub.execute_input": "2024-06-11T23:02:27.952437Z",
235-
"iopub.status.busy": "2024-06-11T23:02:27.952262Z",
236-
"iopub.status.idle": "2024-06-11T23:02:29.595335Z",
237-
"shell.execute_reply": "2024-06-11T23:02:29.587381Z",
238-
"shell.execute_reply.started": "2024-06-11T23:02:27.952417Z"
239-
},
240212
"papermill": {},
241213
"tags": []
242214
},
243-
"outputs": [
244-
{
245-
"data": {
246-
"text/plain": [
247-
"'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'"
248-
]
249-
},
250-
"execution_count": 7,
251-
"metadata": {},
252-
"output_type": "execute_result"
253-
}
254-
],
215+
"outputs": [],
255216
"source": [
256-
"naas.secret.get(naas_secret_name)"
217+
"naas_python.secret.get(naas_secret_name)"
257218
]
258219
},
259220
{

0 commit comments

Comments
 (0)