|
18 | 18 | }, |
19 | 19 | { |
20 | 20 | "cell_type": "code", |
21 | | - "execution_count": 33, |
| 21 | + "execution_count": 1, |
22 | 22 | "id": "0b40bb5b", |
23 | 23 | "metadata": {}, |
24 | 24 | "outputs": [], |
|
52 | 52 | }, |
53 | 53 | { |
54 | 54 | "cell_type": "code", |
55 | | - "execution_count": 34, |
| 55 | + "execution_count": null, |
56 | 56 | "id": "2f981cad", |
57 | 57 | "metadata": {}, |
58 | | - "outputs": [ |
59 | | - { |
60 | | - "name": "stdout", |
61 | | - "output_type": "stream", |
62 | | - "text": [ |
63 | | - "Index 'document-permissions-sample' created with permission filter option enabled.\n" |
64 | | - ] |
65 | | - } |
66 | | - ], |
| 58 | + "outputs": [], |
67 | 59 | "source": [ |
68 | 60 | "from azure.search.documents.indexes.models import SearchField, SearchIndex, PermissionFilter, SearchIndexPermissionFilterOption\n", |
69 | 61 | "from azure.search.documents.indexes import SearchIndexClient\n", |
|
96 | 88 | }, |
97 | 89 | { |
98 | 90 | "cell_type": "code", |
99 | | - "execution_count": 35, |
| 91 | + "execution_count": 3, |
100 | 92 | "id": "b25aaf7b", |
101 | 93 | "metadata": {}, |
102 | 94 | "outputs": [ |
|
129 | 121 | "id": "ff5b912d", |
130 | 122 | "metadata": {}, |
131 | 123 | "source": [ |
132 | | - "## 4. Get group id" |
| 124 | + "## 4. Get group ids" |
133 | 125 | ] |
134 | 126 | }, |
135 | 127 | { |
136 | 128 | "cell_type": "code", |
137 | | - "execution_count": 36, |
| 129 | + "execution_count": 4, |
138 | 130 | "id": "329fe160", |
139 | 131 | "metadata": {}, |
140 | 132 | "outputs": [], |
|
143 | 135 | "client = GraphServiceClient(credentials=credential, scopes=[\"https://graph.microsoft.com/.default\"])\n", |
144 | 136 | "\n", |
145 | 137 | "groups = await client.me.member_of.get()\n", |
146 | | - "group_id = groups.value[0].id " |
| 138 | + "first_group_id = groups.value[0].id\n", |
| 139 | + "second_group_id = groups.value[1].id" |
147 | 140 | ] |
148 | 141 | }, |
149 | 142 | { |
|
156 | 149 | }, |
157 | 150 | { |
158 | 151 | "cell_type": "code", |
159 | | - "execution_count": 37, |
| 152 | + "execution_count": 9, |
160 | 153 | "id": "acd28b29", |
161 | 154 | "metadata": {}, |
162 | 155 | "outputs": [ |
163 | 156 | { |
164 | 157 | "data": { |
165 | 158 | "text/plain": [ |
166 | | - "{'counters': {'directories_successful': 2, 'files_successful': 1, 'failure_count': 0}, 'continuation': None}" |
| 159 | + "{'counters': {'directories_successful': 1, 'files_successful': 1, 'failure_count': 0}, 'continuation': None}" |
167 | 160 | ] |
168 | 161 | }, |
169 | | - "execution_count": 37, |
| 162 | + "execution_count": 9, |
170 | 163 | "metadata": {}, |
171 | 164 | "output_type": "execute_result" |
172 | 165 | } |
173 | 166 | ], |
174 | 167 | "source": [ |
175 | 168 | "from azure.storage.filedatalake import DataLakeServiceClient\n", |
| 169 | + "import requests\n", |
176 | 170 | "\n", |
177 | 171 | "service = DataLakeServiceClient.from_connection_string(adls_gen2_connection_string, credential=credential)\n", |
178 | 172 | "container = service.get_file_system_client(adls_gen2_container_name)\n", |
179 | 173 | "if not container.exists():\n", |
180 | 174 | " container.create_file_system()\n", |
181 | | - "data_dir_client = container.get_directory_client(\"data\")\n", |
182 | | - "data_dir_client.create_directory()\n", |
183 | | - "file_client = data_dir_client.create_file(\"sample.txt\")\n", |
184 | | - "file_client.upload_data(\"This is a sample file.\", overwrite=True)\n", |
185 | | - "\n", |
186 | 175 | "root_dir_client = container.get_directory_client(\"/\")\n", |
187 | | - "root_dir_client.update_access_control_recursive(f\"group:{group_id}:rwx\")\n" |
| 176 | + "state_parks_dir_client = container.get_directory_client(\"state-parks\")\n", |
| 177 | + "state_parks_dir_client.create_directory()\n", |
| 178 | + "root_dir_client.update_access_control_recursive(f\"group:{first_group_id}:rwx\")\n", |
| 179 | + "root_dir_client.update_access_control_recursive(f\"group:{second_group_id}:rwx\")\n", |
| 180 | + "\n", |
| 181 | + "oregon_dir_client = state_parks_dir_client.create_sub_directory(\"oregon\")\n", |
| 182 | + "oregon_dir_client.create_directory()\n", |
| 183 | + "file_client = oregon_dir_client.create_file(\"oregon_state_parks.csv\")\n", |
| 184 | + "oregon_state_parks_content = requests.get(\"https://raw.githubusercontent.com/Azure-Samples/azure-search-sample-data/refs/heads/main/state-parks/Oregon/oregon_state_parks.csv\").content.decode(\"utf-8\")\n", |
| 185 | + "file_client.upload_data(oregon_state_parks_content, overwrite=True)\n", |
| 186 | + "oregon_dir_client.update_access_control_recursive(f\"group:{first_group_id}:rwx\")\n", |
| 187 | + "\n", |
| 188 | + "washington_dir_client = state_parks_dir_client.create_sub_directory(\"washington\")\n", |
| 189 | + "washington_dir_client.create_directory()\n", |
| 190 | + "file_client = washington_dir_client.create_file(\"washington_state_parks.csv\")\n", |
| 191 | + "washington_state_parks_content = requests.get(\"https://raw.githubusercontent.com/Azure-Samples/azure-search-sample-data/refs/heads/main/state-parks/Washington/washington_state_parks.csv\").content.decode(\"utf-8\")\n", |
| 192 | + "file_client.upload_data(washington_state_parks_content, overwrite=True)\n", |
| 193 | + "washington_dir_client.update_access_control_recursive(f\"group:{second_group_id}:rwx\")" |
188 | 194 | ] |
189 | 195 | }, |
190 | 196 | { |
|
197 | 203 | }, |
198 | 204 | { |
199 | 205 | "cell_type": "code", |
200 | | - "execution_count": 39, |
| 206 | + "execution_count": 20, |
201 | 207 | "id": "2ce7eb5e", |
202 | 208 | "metadata": {}, |
203 | 209 | "outputs": [ |
|
236 | 242 | }, |
237 | 243 | { |
238 | 244 | "cell_type": "code", |
239 | | - "execution_count": 43, |
| 245 | + "execution_count": null, |
240 | 246 | "id": "7a899da1", |
241 | 247 | "metadata": {}, |
242 | 248 | "outputs": [ |
|
267 | 273 | }, |
268 | 274 | { |
269 | 275 | "cell_type": "code", |
270 | | - "execution_count": 44, |
| 276 | + "execution_count": 14, |
271 | 277 | "id": "72d203f0", |
272 | 278 | "metadata": {}, |
273 | 279 | "outputs": [ |
274 | 280 | { |
275 | 281 | "name": "stdout", |
276 | 282 | "output_type": "stream", |
277 | 283 | "text": [ |
278 | | - "Path: https://magotteiadlsgen2.blob.core.windows.net/documentpermissionssample/data/sample.txt, OID: ['none'], Group: ['ec5aece9-33fc-4b2e-abe1-aedf771357a3']\n" |
| 284 | + "Path: https://magotteiadlsgen2.blob.core.windows.net/documentpermissionssample/state-parks/oregon/oregon_state_parks.csv, OID: [], Group: []\n", |
| 285 | + "Path: https://magotteiadlsgen2.blob.core.windows.net/documentpermissionssample/state-parks/oregon/oregon_state_parks.csv, OID: [], Group: []\n" |
279 | 286 | ] |
280 | 287 | } |
281 | 288 | ], |
|
0 commit comments