|
53 | 53 | "tags": []
|
54 | 54 | },
|
55 | 55 | "source": [
|
56 |
| - "**Last update:** 2023-05-24 (Created: 2023-05-24)" |
| 56 | + "**Last update:** 2024-06-18 (Created: 2023-05-24)" |
57 | 57 | ]
|
58 | 58 | },
|
59 | 59 | {
|
|
64 | 64 | "tags": []
|
65 | 65 | },
|
66 | 66 | "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." |
72 | 68 | ]
|
73 | 69 | },
|
74 | 70 | {
|
|
108 | 104 | },
|
109 | 105 | {
|
110 | 106 | "cell_type": "code",
|
111 |
| - "execution_count": 1, |
| 107 | + "execution_count": null, |
112 | 108 | "id": "90760955-5133-4c1a-a43b-e3dee1a02f44",
|
113 | 109 | "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 |
| - }, |
121 | 110 | "papermill": {},
|
122 | 111 | "tags": []
|
123 | 112 | },
|
124 | 113 | "outputs": [],
|
125 | 114 | "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" |
127 | 120 | ]
|
128 | 121 | },
|
129 | 122 | {
|
|
134 | 127 | "tags": []
|
135 | 128 | },
|
136 | 129 | "source": [
|
137 |
| - "### Setup Variables\n", |
| 130 | + "### Setup variables\n", |
138 | 131 | "- `naas_secret_name`: Name of the secret to add\n",
|
139 | 132 | "- `naas_secret_value`: Value of the secret to add"
|
140 | 133 | ]
|
141 | 134 | },
|
142 | 135 | {
|
143 | 136 | "cell_type": "code",
|
144 |
| - "execution_count": 5, |
| 137 | + "execution_count": null, |
145 | 138 | "id": "ddca8d9b-a981-4b11-82be-80ccd7d9b2b6",
|
146 | 139 | "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 |
| - }, |
154 | 140 | "papermill": {},
|
155 | 141 | "tags": []
|
156 | 142 | },
|
157 | 143 | "outputs": [],
|
158 | 144 | "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\"" |
161 | 147 | ]
|
162 | 148 | },
|
163 | 149 | {
|
|
184 | 170 | },
|
185 | 171 | {
|
186 | 172 | "cell_type": "code",
|
187 |
| - "execution_count": 6, |
| 173 | + "execution_count": null, |
188 | 174 | "id": "f30c11f1-d027-4a13-86e3-49f408e46e6b",
|
189 | 175 | "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 |
| - }, |
197 | 176 | "papermill": {},
|
198 | 177 | "tags": []
|
199 | 178 | },
|
200 | 179 | "outputs": [],
|
201 | 180 | "source": [
|
202 |
| - "naas.secret.add(naas_secret_name, naas_secret_value)" |
| 181 | + "naas_python.secret.add(naas_secret_name, naas_secret_value)" |
203 | 182 | ]
|
204 | 183 | },
|
205 | 184 | {
|
|
227 | 206 | },
|
228 | 207 | {
|
229 | 208 | "cell_type": "code",
|
230 |
| - "execution_count": 7, |
| 209 | + "execution_count": null, |
231 | 210 | "id": "40de06c9-967a-4ac9-886e-a1c943e42308",
|
232 | 211 | "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 |
| - }, |
240 | 212 | "papermill": {},
|
241 | 213 | "tags": []
|
242 | 214 | },
|
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": [], |
255 | 216 | "source": [
|
256 |
| - "naas.secret.get(naas_secret_name)" |
| 217 | + "naas_python.secret.get(naas_secret_name)" |
257 | 218 | ]
|
258 | 219 | },
|
259 | 220 | {
|
|
0 commit comments