Office365-REST-Python-Client 3.1.0__py3-none-any.whl → 3.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. office365/communications/callrecords/call_record.py +18 -0
  2. office365/communications/calls/call.py +3 -0
  3. office365/communications/presences/presence.py +3 -0
  4. office365/communications/quotas.py +66 -0
  5. office365/communications/virtualevents/virtual_event.py +3 -0
  6. office365/directory/domains/domain.py +3 -0
  7. office365/directory/licenses/subscribed_sku.py +3 -0
  8. office365/directory/objects/object.py +3 -0
  9. office365/directory/quotas.py +34 -0
  10. office365/entity_collection.py +2 -2
  11. office365/graph_client.py +46 -2
  12. office365/limits.py +66 -0
  13. office365/migration/__init__.py +6 -1
  14. office365/migration/adapters/__init__.py +14 -4
  15. office365/migration/adapters/filesystem.py +4 -1
  16. office365/migration/assessment/export.py +5 -5
  17. office365/migration/assessment/issue.py +19 -0
  18. office365/migration/assessment/report.py +11 -0
  19. office365/migration/assessment/scanners/base.py +37 -49
  20. office365/migration/base.py +33 -8
  21. office365/migration/checkpoint.py +1 -1
  22. office365/migration/outlook/assessor.py +4 -4
  23. office365/migration/package/__init__.py +82 -0
  24. office365/migration/package/builder.py +603 -0
  25. office365/migration/package/crypto.py +54 -0
  26. office365/migration/package/manifest_xml.py +495 -0
  27. office365/migration/package/staging.py +180 -0
  28. office365/migration/report.py +7 -2
  29. office365/migration/report_io.py +79 -0
  30. office365/migration/runner.py +117 -10
  31. office365/migration/server_job.py +126 -14
  32. office365/migration/session.py +132 -49
  33. office365/migration/settings.py +67 -0
  34. office365/migration/sharepoint/__init__.py +2 -0
  35. office365/migration/sharepoint/adapters.py +207 -41
  36. office365/migration/sharepoint/assessor.py +45 -9
  37. office365/migration/sharepoint/options.py +57 -0
  38. office365/migration/sharepoint/package_target.py +209 -0
  39. office365/migration/sharepoint/registry.py +22 -0
  40. office365/migration/sharepoint/resolvers.py +96 -0
  41. office365/migration/sharepoint/scanners/__init__.py +29 -0
  42. office365/migration/sharepoint/scanners/browser_file_handling.py +55 -0
  43. office365/migration/sharepoint/scanners/checked_out_files.py +57 -0
  44. office365/migration/sharepoint/scanners/file_versions.py +56 -0
  45. office365/migration/sharepoint/scanners/files.py +5 -2
  46. office365/migration/sharepoint/scanners/large_excel_files.py +56 -0
  47. office365/migration/sharepoint/scanners/large_lists.py +58 -0
  48. office365/migration/sharepoint/scanners/large_sites.py +4 -3
  49. office365/migration/sharepoint/scanners/long_onedrive_urls.py +52 -0
  50. office365/migration/sharepoint/scanners/lookup.py +38 -0
  51. office365/migration/sharepoint/scanners/paths.py +9 -4
  52. office365/migration/sharepoint/scanners/permissions.py +20 -2
  53. office365/migration/sharepoint/scanners/smat.py +51 -0
  54. office365/migration/sharepoint/scanners/summary.py +1 -0
  55. office365/migration/sharepoint/scanners/thicket_folders.py +38 -0
  56. office365/migration/sharepoint/scanners/unsupported_site_templates.py +90 -0
  57. office365/migration/sharepoint/tenant_assessor.py +5 -3
  58. office365/migration/sharepoint/transfer.py +4 -2
  59. office365/migration/tasks.py +121 -0
  60. office365/migration/validators.py +2 -19
  61. office365/onedrive/driveitems/driveItem.py +116 -12
  62. office365/onedrive/termstore/groups/collection.py +2 -9
  63. office365/onedrive/termstore/sets/collection.py +2 -9
  64. office365/onedrive/termstore/terms/collection.py +3 -10
  65. office365/onedrive/workbooks/workbook.py +7 -0
  66. office365/outlook/contacts/folders/collection.py +4 -13
  67. office365/runtime/auth/authentication_context.py +5 -0
  68. office365/runtime/client_object.py +18 -0
  69. office365/runtime/client_object_collection.py +75 -245
  70. office365/runtime/client_request.py +77 -1
  71. office365/runtime/client_request_exception.py +127 -39
  72. office365/runtime/client_runtime_context.py +79 -8
  73. office365/runtime/converters/csv_writer.py +10 -4
  74. office365/runtime/converters/dataframe.py +84 -4
  75. office365/runtime/converters/json_file.py +12 -3
  76. office365/runtime/converters/parquet.py +67 -0
  77. office365/runtime/converters/records.py +31 -12
  78. office365/runtime/converters/registry.py +185 -0
  79. office365/runtime/converters/scalars.py +31 -0
  80. office365/runtime/converters/sql.py +69 -0
  81. office365/runtime/converters/streamers.py +105 -0
  82. office365/runtime/converters/streams.py +42 -0
  83. office365/runtime/converters/upsert.py +101 -0
  84. office365/runtime/exceptions.py +105 -0
  85. office365/runtime/http/prefer.py +26 -0
  86. office365/runtime/http/throttling.py +258 -56
  87. office365/runtime/imports.py +571 -0
  88. office365/runtime/limits.py +455 -0
  89. office365/runtime/odata/request.py +11 -2
  90. office365/runtime/odata/type.py +1 -0
  91. office365/runtime/odata/v3/batch_request.py +4 -2
  92. office365/runtime/odata/v4/batch_request.py +22 -7
  93. office365/runtime/operations.py +29 -0
  94. office365/runtime/parallel.py +12 -14
  95. office365/runtime/paths/v4/entity.py +2 -2
  96. office365/runtime/queries/batch.py +18 -1
  97. office365/runtime/queries/get_or_create.py +109 -0
  98. office365/runtime/record_collection.py +443 -0
  99. office365/runtime/retry.py +92 -26
  100. office365/runtime/transport/base.py +6 -1
  101. office365/runtime/transport/requests_transport.py +4 -0
  102. office365/runtime/transport/throttled_transport.py +67 -0
  103. office365/runtime/verification.py +40 -0
  104. office365/sharepoint/activities/logger.py +118 -8
  105. office365/sharepoint/administration/analytics/usage_service.py +15 -7
  106. office365/sharepoint/administration/sitemove/service.py +791 -8
  107. office365/sharepoint/alerts/alert.py +79 -0
  108. office365/sharepoint/apps/app_collection.py +25 -0
  109. office365/sharepoint/apps/launcher.py +16 -0
  110. office365/sharepoint/authpolicy/tenant/compliancereport.py +5 -0
  111. office365/sharepoint/businessdata/app_bdc_catalog.py +135 -0
  112. office365/sharepoint/businessdata/entityfieldvaluedictionary.py +65 -0
  113. office365/sharepoint/businessdata/entityidentifier.py +23 -0
  114. office365/sharepoint/businessdata/entityinstance.py +52 -0
  115. office365/sharepoint/businessdata/entityview.py +31 -0
  116. office365/sharepoint/businessdata/externalsubscriptionstore.py +9 -0
  117. office365/sharepoint/businessdata/typedescriptor.py +37 -0
  118. office365/sharepoint/client_context.py +40 -23
  119. office365/sharepoint/clientsidecomponent/hostedapps/app.py +21 -0
  120. office365/sharepoint/clientsidecomponent/hostedapps/manager.py +16 -0
  121. office365/sharepoint/comments/comment.py +84 -2
  122. office365/sharepoint/contentcenter/machinelearning/models/model.py +0 -23
  123. office365/sharepoint/contentcenter/machinelearning/publications/publication.py +0 -9
  124. office365/sharepoint/contentcenter/machinelearning/samples/sample.py +0 -14
  125. office365/sharepoint/contentcenter/machinelearning/workitems/item.py +0 -80
  126. office365/sharepoint/contentsolution/template_api.py +148 -0
  127. office365/sharepoint/contenttypes/collection.py +32 -10
  128. office365/sharepoint/convergence/addnoliveblobsinodcservicestateapi.py +9 -0
  129. office365/sharepoint/convergence/consumer_permissions.py +15 -0
  130. office365/sharepoint/convergence/migration_complete_state_api.py +25 -0
  131. office365/sharepoint/convergence/odcmetadatacleanedupapi.py +9 -0
  132. office365/sharepoint/documentmanagement/document_id.py +12 -0
  133. office365/sharepoint/entity.py +11 -2
  134. office365/sharepoint/entity_collection.py +2 -2
  135. office365/sharepoint/exceptions.py +194 -0
  136. office365/sharepoint/fields/builtin_field_id.py +45 -34
  137. office365/sharepoint/fields/builtin_field_name.py +123 -0
  138. office365/sharepoint/fields/coercion.py +131 -0
  139. office365/sharepoint/fields/collection.py +54 -37
  140. office365/sharepoint/fields/field.py +17 -0
  141. office365/sharepoint/fields/name.py +46 -2
  142. office365/sharepoint/files/collection.py +7 -1
  143. office365/sharepoint/files/file.py +54 -8
  144. office365/sharepoint/files/versions/version.py +38 -13
  145. office365/sharepoint/folders/collection.py +4 -0
  146. office365/sharepoint/folders/folder.py +91 -21
  147. office365/sharepoint/htmlpages/html_page.py +16 -0
  148. office365/sharepoint/htmlpages/html_page_service.py +19 -0
  149. office365/sharepoint/ir/migration.py +9 -0
  150. office365/sharepoint/listitems/caml/__init__.py +31 -0
  151. office365/sharepoint/listitems/caml/builder.py +129 -0
  152. office365/sharepoint/listitems/caml/expressions.py +424 -0
  153. office365/sharepoint/listitems/caml/fields.py +68 -0
  154. office365/sharepoint/listitems/caml/guard.py +63 -0
  155. office365/sharepoint/listitems/caml/query.py +71 -2
  156. office365/sharepoint/listitems/caml/values.py +113 -0
  157. office365/sharepoint/listitems/collection.py +21 -20
  158. office365/sharepoint/listitems/upsert.py +75 -0
  159. office365/sharepoint/lists/collection.py +29 -22
  160. office365/sharepoint/lists/exporter.py +4 -3
  161. office365/sharepoint/lists/list.py +397 -39
  162. office365/sharepoint/lists/smart_wiki_library_utility.py +58 -0
  163. office365/sharepoint/logger/export.py +12 -0
  164. office365/sharepoint/marketplace/app_metadata.py +97 -1
  165. office365/sharepoint/marketplace/appstatequeryjobdefinition.py +9 -0
  166. office365/sharepoint/marketplace/corporatecuratedgallery/carddesigns/card_designs.py +35 -0
  167. office365/sharepoint/marketplace/sitecollection/appcatalog/allowed_item.py +5 -0
  168. office365/sharepoint/marketplace/tenant/appcatalog/accessor.py +107 -30
  169. office365/sharepoint/microfeed/data.py +0 -6
  170. office365/sharepoint/microservice/manager.py +61 -0
  171. office365/sharepoint/migrationcenter/common/task.py +193 -4
  172. office365/sharepoint/migrationcenter/common/task_entity_data.py +1 -1
  173. office365/sharepoint/migrationcenter/deploy_status.py +13 -0
  174. office365/sharepoint/migrationcenter/service/properties.py +20 -0
  175. office365/sharepoint/migrationcenter/service/storage.py +34 -0
  176. office365/sharepoint/migrationcenter/spflight.py +13 -0
  177. office365/sharepoint/migrationcenter/urlparseresult.py +77 -0
  178. office365/sharepoint/multigeo/service/spmultigeoproxy.py +13 -0
  179. office365/sharepoint/navigation/servicerest.py +127 -0
  180. office365/sharepoint/oauth/authentication.py +13 -0
  181. office365/sharepoint/portal/theme_manager.py +120 -8
  182. office365/sharepoint/principal/users/user.py +10 -0
  183. office365/sharepoint/publishing/campaign/campaign.py +36 -1
  184. office365/sharepoint/publishing/feedvideopage.py +0 -7
  185. office365/sharepoint/publishing/pages/3d/page.py +0 -6
  186. office365/sharepoint/publishing/pages/page.py +0 -117
  187. office365/sharepoint/publishing/pages/reposts/repost.py +0 -7
  188. office365/sharepoint/publishing/pages/topics/topic.py +0 -7
  189. office365/sharepoint/publishing/subtitlefile.py +0 -40
  190. office365/sharepoint/quotamanagement/consumer/consumer_quota_info_api.py +14 -0
  191. office365/sharepoint/quotamanagement/consumer/non_quota_backfill_api.py +23 -0
  192. office365/sharepoint/quotamanagement/consumer/nonquotamigrationapi.py +9 -0
  193. office365/sharepoint/quotamanagement/consumer/quotamigrationapi.py +13 -0
  194. office365/sharepoint/request.py +57 -16
  195. office365/sharepoint/search/administration/document_crawl_log.py +24 -7
  196. office365/sharepoint/search/administration/providers/crawl_versions_info.py +29 -0
  197. office365/sharepoint/search/administration/providers/recycle_bin_info.py +23 -0
  198. office365/sharepoint/search/administration/providers/site_content_processing_info.py +67 -0
  199. office365/sharepoint/sites/site.py +976 -65
  200. office365/sharepoint/sites/siteprovisioninginfoprovider.py +13 -0
  201. office365/sharepoint/tenant/administration/datagovernance/insight_client.py +292 -23
  202. office365/sharepoint/tenant/administration/ddiadapter.py +97 -0
  203. office365/sharepoint/tenant/administration/internal/aad/collection.py +20 -0
  204. office365/sharepoint/tenant/administration/internal/aad/permission_grant.py +0 -19
  205. office365/sharepoint/tenant/administration/internal/appservice/permission_request.py +72 -1
  206. office365/sharepoint/tenant/administration/internal/appservice/principal.py +1 -3
  207. office365/sharepoint/tenant/administration/odb_license_enforcement_service.py +26 -0
  208. office365/sharepoint/tenant/administration/sites/properties.py +564 -6
  209. office365/sharepoint/tenant/administration/spdatagovernancesarrestapiclient.py +60 -1
  210. office365/sharepoint/tenant/insights/reports/manager.py +24 -12
  211. office365/sharepoint/tenant/management/office365_tenant.py +451 -2
  212. office365/sharepoint/tenantadministration/catalog_management_collection.py +69 -0
  213. office365/sharepoint/tenantadministration/catalog_management_custom_properties_collection.py +237 -0
  214. office365/sharepoint/tenantadministration/catalog_management_restricted_content_discovery_collection.py +56 -0
  215. office365/sharepoint/tenantadministration/sp_data_governance_client_exception.py +7 -0
  216. office365/sharepoint/thresholds.py +529 -0
  217. office365/sharepoint/translation/jobs/job.py +72 -2
  218. office365/sharepoint/translation/jobs/status.py +47 -9
  219. office365/sharepoint/translation/sync_translator.py +15 -2
  220. office365/sharepoint/utilities/move_copy_util.py +2 -1
  221. office365/sharepoint/viva/connections/page.py +27 -0
  222. office365/sharepoint/viva/home.py +38 -0
  223. office365/sharepoint/viva/learningmanager.py +9 -0
  224. office365/sharepoint/viva/vivaresources.py +60 -0
  225. office365/sharepoint/webhooks/subscription.py +0 -11
  226. office365/sharepoint/webparts/definitions/definition.py +13 -0
  227. office365/sharepoint/webparts/limited_manager.py +29 -7
  228. office365/sharepoint/webs/context_web_information.py +14 -9
  229. office365/sharepoint/webs/templates/__init__.py +11 -0
  230. office365/sharepoint/webs/templates/type.py +74 -15
  231. office365/sharepoint/workflow/definition.py +6 -0
  232. office365/sharepoint/workflow/deployment_service.py +155 -0
  233. office365/sharepoint/workflow/instances/service.py +33 -0
  234. office365/sharepoint/workflow/interopservice.py +68 -0
  235. office365/sharepoint/workflow/messagingservice.py +24 -0
  236. office365/sharepoint/workflow/servicesmanager.py +41 -2
  237. office365/sharepoint/workflow/subscriptions/service.py +67 -0
  238. office365/sharepoint/workflow/subscriptions/subscription.py +31 -0
  239. office365/sharepoint/workflow/task.py +425 -0
  240. office365_rest_python_client-3.2.0.dist-info/METADATA +605 -0
  241. {office365_rest_python_client-3.1.0.dist-info → office365_rest_python_client-3.2.0.dist-info}/RECORD +242 -185
  242. office365/migration/_util.py +0 -73
  243. office365/sharepoint/listitems/caml/types.py +0 -70
  244. office365_rest_python_client-3.1.0.dist-info/METADATA +0 -475
  245. {office365_rest_python_client-3.1.0.dist-info → office365_rest_python_client-3.2.0.dist-info}/WHEEL +0 -0
@@ -1,73 +0,0 @@
1
- """Shared helpers for the migration toolkit (progress, CSV/JSON, timestamps).
2
-
3
- Keeps the small, repeated idioms (progress emission, record export, ISO-8601
4
- timestamps) in one place instead of inlining them in every adapter/runner.
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- import csv
10
- import json
11
- import os
12
- from datetime import datetime, timezone
13
- from pathlib import Path
14
-
15
-
16
- def emit_progress(progress, *, done: int, total: int | None = None, stage: str, items=None) -> None:
17
- """Invoke a progress hook (if any) with a ``Progress`` snapshot.
18
-
19
- Centralizes the ``if callable(progress): Progress(...)`` idiom used across
20
- the toolkit.
21
- """
22
- if callable(progress):
23
- from office365.runtime.operations import Progress
24
-
25
- progress(Progress(done=done, total=total, stage=stage, items=items))
26
-
27
-
28
- def write_csv_json(dir_: str | Path, stem: str, records: list[dict], columns: list[str] | None = None) -> list[str]:
29
- """Write records as both CSV and JSON under ``dir_``; returns the file paths."""
30
- os.makedirs(dir_, exist_ok=True)
31
- columns = list(columns) if columns else (list(records[0]) if records else [])
32
-
33
- csv_path = os.path.join(str(dir_), f"{stem}.csv")
34
- with open(csv_path, "w", newline="", encoding="utf-8") as f:
35
- writer = csv.DictWriter(f, fieldnames=columns, restval="n/a")
36
- writer.writeheader()
37
- writer.writerows(records)
38
-
39
- json_path = os.path.join(str(dir_), f"{stem}.json")
40
- with open(json_path, "w", encoding="utf-8") as f:
41
- json.dump(records, f, indent=2)
42
-
43
- return [csv_path, json_path]
44
-
45
-
46
- def coerce_int(value) -> int | None:
47
- """Best-effort ``int`` conversion (``None`` for unset/invalid values)."""
48
- try:
49
- return int(value) if value is not None else None
50
- except (TypeError, ValueError):
51
- return None
52
-
53
-
54
- def utc_now_iso() -> str:
55
- """Current UTC time as an ISO-8601 string (second precision)."""
56
- return datetime.now(timezone.utc).isoformat(timespec="seconds")
57
-
58
-
59
- def iso(value) -> str:
60
- """ISO-8601 string for a datetime (second precision); ``""`` for ``None``."""
61
- if value is None:
62
- return ""
63
- return value.isoformat(timespec="seconds")
64
-
65
-
66
- def record_to_json(payload: object) -> str:
67
- """Serialize a record to the canonical JSON text used when persisting it.
68
-
69
- SharePoint property values are often entity/datetime objects, so a str
70
- fallback keeps the payload JSON-safe. Source/target checksums both use this
71
- form, so content verification compares identical text.
72
- """
73
- return json.dumps(payload, indent=2, default=str)
@@ -1,70 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from office365.sharepoint.views.scope import ViewScope
4
-
5
-
6
- class WhereElement:
7
- """Used within the context of a query to specify a filter."""
8
-
9
- def __str__(self):
10
- return "<Where></Where>"
11
-
12
-
13
- class OrderByElement:
14
- """Determines the sort order for a query"""
15
-
16
- def __str__(self):
17
- return "<OrderBy></OrderBy>"
18
-
19
-
20
- class GroupByElement:
21
- """Contains a Group By section for grouping the data returned through a query in a list view."""
22
-
23
- def __str__(self):
24
- return "<GroupBy></GroupBy>"
25
-
26
-
27
- class QueryElement:
28
- """Defines the query for a view."""
29
-
30
- def __init__(self):
31
- self.Where = WhereElement()
32
- self.OrderBy = OrderByElement()
33
- self.GroupBy = GroupByElement()
34
-
35
- @staticmethod
36
- def parse(expr):
37
- return QueryElement()
38
-
39
- def __repr__(self):
40
- return f"<Query>{str(self.Where)}</Query>"
41
-
42
-
43
- class RowLimitElement:
44
- """Sets the row limit for the number of items to display in a view."""
45
-
46
- def __init__(self, top=None):
47
- """Args:
48
- top (int):
49
- """
50
- self.Top = top
51
-
52
- def __str__(self):
53
- return f'<RowLimit Paged="TRUE">{self.Top}</RowLimit>'
54
-
55
-
56
- class ViewElement:
57
- """"""
58
-
59
- def __init__(
60
- self,
61
- scope=ViewScope.DefaultValue,
62
- query=QueryElement(),
63
- row_limit=RowLimitElement(),
64
- ):
65
- self.Scope = scope
66
- self.Query = query
67
- self.RowLimit = row_limit
68
-
69
- def __str__(self):
70
- return f'<View Scope="{self.Scope}"><Query>{str(self.Query)}</Query></View>'
@@ -1,475 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: office365-rest-python-client
3
- Version: 3.1.0
4
- Summary: Microsoft 365 & Microsoft Graph Library for Python
5
- Author: Vadim Gremyachev
6
- Author-email: Vadim Gremyachev <vvgrem@gmail.com>
7
- License: The MIT License (MIT)
8
-
9
- Copyright (c) 2016 Vadim Gremyachev
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
- Classifier: Development Status :: 4 - Beta
29
- Classifier: Intended Audience :: Developers
30
- Classifier: License :: OSI Approved :: MIT License
31
- Classifier: Programming Language :: Python
32
- Classifier: Programming Language :: Python :: 3 :: Only
33
- Classifier: Programming Language :: Python :: 3.8
34
- Classifier: Programming Language :: Python :: 3.9
35
- Classifier: Programming Language :: Python :: 3.10
36
- Classifier: Programming Language :: Python :: 3.11
37
- Classifier: Programming Language :: Python :: 3.12
38
- Classifier: Programming Language :: Python :: 3.13
39
- Classifier: Programming Language :: Python :: 3.14
40
- Classifier: Topic :: Internet :: WWW/HTTP
41
- Classifier: Topic :: Software Development :: Libraries
42
- Requires-Dist: msal>=1.28,<2
43
- Requires-Dist: pytz>=2021.1
44
- Requires-Dist: requests>=2.32.4,<3
45
- Requires-Dist: typing-extensions>=4.5
46
- Requires-Dist: faker ; extra == 'examples'
47
- Requires-Dist: openpyxl>=3.1 ; extra == 'excel'
48
- Requires-Dist: pandas>=1.3.0 ; extra == 'notebooks'
49
- Requires-Dist: jupyter ; extra == 'notebooks'
50
- Requires-Dist: nbformat ; extra == 'notebooks'
51
- Requires-Dist: jinja2 ; extra == 'notebooks'
52
- Requires-Dist: requests-ntlm ; extra == 'ntlm'
53
- Requires-Dist: pandas>=1.5 ; extra == 'pandas'
54
- Maintainer: Domenico Di Nicola
55
- Maintainer-email: Domenico Di Nicola <dom.dinicola@gmail.com>
56
- Requires-Python: >=3.8.0
57
- Project-URL: repository, https://github.com/vgrem/office365-rest-python-client
58
- Provides-Extra: examples
59
- Provides-Extra: excel
60
- Provides-Extra: notebooks
61
- Provides-Extra: ntlm
62
- Provides-Extra: pandas
63
- Description-Content-Type: text/markdown
64
-
65
- # office365-rest-python-client
66
-
67
- [![Downloads](https://pepy.tech/badge/office365-rest-python-client/month)](https://pepy.tech/project/office365-rest-python-client)
68
- [![PyPI](https://img.shields.io/pypi/v/office365-rest-python-client.svg)](https://pypi.python.org/pypi/office365-rest-python-client)
69
- [![PyPI pyversions](https://img.shields.io/pypi/pyversions/office365-rest-python-client.svg)](https://pypi.python.org/pypi/office365-rest-python-client/)
70
- [![Sponsor](https://img.shields.io/badge/-Sponsor-%23EA4AAA?logo=github&logoColor=white)](https://github.com/sponsors/vgrem)
71
-
72
- **Python client library for Microsoft 365 and Microsoft Graph APIs.**
73
-
74
- Covers SharePoint REST API v1, Microsoft Graph (Outlook, OneDrive, Teams, OneNote, Planner, and more), and supports all modern Azure AD authentication flows.
75
-
76
- > **Python 3.8+ required.**
77
-
78
- ---
79
-
80
- ## Support
81
-
82
- `office365-rest-python-client` is free and maintained in the open. Sponsorship funds security updates, new API coverage, documentation, and releases. See the [roadmap](ROADMAP.md) for what's funded.
83
-
84
- - [**GitHub Sponsors**](https://github.com/sponsors/vgrem) — recurring monthly support
85
- - [**PayPal**](https://paypal.me/ossvgrem) — one-off donation
86
- - **Using this in production?** The [Organization tier](https://github.com/sponsors/vgrem) adds priority issue response and a roadmap vote; [contact us](https://github.com/vgrem/office365-rest-python-client/discussions) for paid support, custom feature work, or help migrating from 2.6.2 → 3.0.0.
87
-
88
- ---
89
-
90
- ## Table of Contents
91
-
92
- - [Installation](#installation)
93
- - [Support](#support)
94
- - [Which client do I need?](#which-client-do-i-need)
95
- - [Authentication](#authentication)
96
- - [ClientContext — SharePoint auth](#clientcontext--sharepoint-auth)
97
- - [GraphClient — Microsoft Graph auth](#graphclient--microsoft-graph-auth)
98
- - [Azure Environments](#azure-environments)
99
- - [SharePoint — ClientContext](#sharepoint--clientcontext)
100
- - [Microsoft Graph — GraphClient](#microsoft-graph--graphclient)
101
- - [Dependencies](#dependencies)
102
-
103
- ---
104
-
105
- ## Installation
106
-
107
- ```bash
108
- pip install office365-rest-python-client
109
- ```
110
-
111
- With [uv](https://github.com/astral-sh/uv):
112
-
113
- ```bash
114
- uv pip install office365-rest-python-client
115
- ```
116
-
117
- Latest from GitHub (includes unreleased changes):
118
-
119
- ```bash
120
- pip install git+https://github.com/vgrem/office365-rest-python-client.git
121
- ```
122
-
123
- ---
124
-
125
- ## Which client do I need?
126
-
127
- | | `ClientContext` | `GraphClient` |
128
- |---|---|---|
129
- | **Target API** | SharePoint REST API v1 | Microsoft Graph API |
130
- | **Use for** | SharePoint lists, files, folders, search, site admin, permissions | Outlook, OneDrive, Teams, OneNote, Planner, Users, Groups |
131
- | **SharePoint via Graph?** | — | Partial - use `ClientContext` for full SharePoint fidelity |
132
- | **Docs** | [SharePoint REST API](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service) | [Microsoft Graph](https://learn.microsoft.com/en-us/graph/overview) |
133
-
134
- ---
135
-
136
- ## Authentication
137
-
138
- > All modern auth flows use **Azure AD** via the [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-python) library.
139
- > Legacy flows (ACS, SAML) are fully retired as of April/May 2026.
140
- >
141
- > [ACS retirement notice](https://aka.ms/retirement/acs/support) | [SAML retirement MC1184649](https://learn.microsoft.com/en-us/sharepoint/dev/security/saml-auth-retirement)
142
- >
143
- > Migrating from SAML? See [examples/sharepoint/auth/modern/migrate_from_saml_to_cert.py](examples/sharepoint/auth/modern/migrate_from_saml_to_cert.py)
144
-
145
- Two clients, different auth capabilities:
146
-
147
- | | `ClientContext` | `GraphClient` |
148
- |---|---|---|
149
- | **Target** | SharePoint REST API v1 | Microsoft Graph API |
150
- | **Resource** | `{tenant}.sharepoint.com` | `graph.microsoft.com` |
151
-
152
- ### ClientContext — SharePoint auth
153
-
154
- | Flow | Method | User/App | MFA | Status | Docs |
155
- |------|--------|----------|-----|--------|------|
156
- | **Certificate** (Azure AD) | `with_client_certificate(tenant, client_id, thumbprint, cert_path)` | App-only | — | ✅ Recommended | [Docs](https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread) |
157
- | **Username & password** (MSAL ROPC) | `with_username_and_password(tenant, client_id, username, password)` | Delegated | ❌ | ✅ Supported | [Docs](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc) |
158
- | **Interactive** (browser) | `with_interactive(tenant, client_id)` | Delegated | ✅ | ✅ Supported | [Docs](https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows) |
159
- | **Device code** | `with_device_flow(tenant, client_id)` | Delegated | ✅ | ✅ Supported | [Docs](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code) |
160
- | **NTLM** (on-prem only) | `with_user_credentials(username, password)` | Delegated | — | ✅ On-prem only | [Example](examples/sharepoint/auth/legacy/with_ntlm.py) |
161
- | **Client secret** (Azure AD) | `with_client_secret(tenant, client_id, secret)` | App-only | — | ❌ Not documented | [Microsoft's own migration guidance](https://mc.merill.net/message/MC1184649) confirms: replace legacy ACS auth with OAuth2 client credentials flow using certificates, not client secrets, for SharePoint access. |
162
- | ~~SAML user auth~~ | `with_user_credentials(username, password)` | Delegated | ❌ | 🚫 Retired May 2026 | [Migration guide](examples/sharepoint/auth/modern/migrate_from_saml_to_cert.py) |
163
- | ~~ACS app-only~~ | `with_credentials(ClientCredential(...))` | App-only | — | 🚫 Retired Apr 2026 | [Notice](https://aka.ms/retirement/acs/support) |
164
-
165
- ### GraphClient — Microsoft Graph auth
166
-
167
- | Flow | Method | User/App | MFA | Status | Docs |
168
- |------|--------|----------|-----|--------|------|
169
- | **Client secret** | `with_client_secret(client_id, secret)` | App-only | — | ✅ Recommended | [Docs](https://learn.microsoft.com/en-us/graph/auth-v2-service) |
170
- | **Certificate** | `with_client_certificate(client_id, thumbprint, key)` | App-only | — | ✅ Recommended | [Docs](https://learn.microsoft.com/en-us/graph/auth-v2-service) |
171
- | **Interactive** | `with_token_interactive(client_id)` | Delegated | ✅ | ✅ Supported | [Docs](https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows) |
172
- | **Username & password** | `with_username_and_password(client_id, username, password)` | Delegated | ❌ | ✅ Supported | [Docs](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc) |
173
- | **Custom token** | `GraphClient(acquire_token_func)` | Both | ✅ | ✅ Supported | — |
174
-
175
- ---
176
-
177
- ### Azure Environments
178
-
179
- For national and sovereign clouds, pass the `environment` parameter:
180
-
181
- ```python
182
- from office365.azure_env import AzureEnvironment
183
- from office365.sharepoint.client_context import ClientContext
184
-
185
- ctx = ClientContext("{site_url}", environment=AzureEnvironment.USGovernmentHigh)\
186
- .with_client_certificate(...)
187
- ```
188
-
189
- | Environment | Constant |
190
- |---|---|
191
- | Global (default) | `AzureEnvironment.Global` |
192
- | US Government GCC | `AzureEnvironment.USGovernment` |
193
- | US Government GCC High | `AzureEnvironment.USGovernmentHigh` |
194
- | US Government DoD | `AzureEnvironment.USGovernmentDoD` |
195
- | China (21Vianet) | `AzureEnvironment.China` |
196
- | Germany (legacy) | `AzureEnvironment.Germany` |
197
-
198
- ---
199
-
200
- ## SharePoint — ClientContext
201
-
202
- ### Quick start
203
-
204
- ```python
205
- from office365.sharepoint.client_context import ClientContext
206
-
207
- ctx = ClientContext("{site_url}").with_client_certificate(
208
- tenant="{tenant}", client_id="{client_id}",
209
- thumbprint="{thumbprint}", cert_path="./cert.pem"
210
- )
211
- web = ctx.web.get().execute_query()
212
- print(f"Site title: {web.title}")
213
- ```
214
-
215
- ### Lists & Items
216
-
217
- ```python
218
- # Get all items (handles 5000+ row threshold automatically)
219
- items = ctx.web.lists.get_by_title("Orders").items.get_all().execute_query()
220
- for item in items:
221
- print(item.properties["Title"])
222
-
223
- # Create item
224
- target_list = ctx.web.lists.get_by_title("Tasks")
225
- item = target_list.add_item({"Title": "New task", "Status": "Active"}).execute_query()
226
-
227
- # Bulk create — auto-batches in chunks of 100 (sequential by default)
228
- for row in data:
229
- target_list.add_item({"Title": row["name"]})
230
- ctx.execute_batch()
231
-
232
- # Parallel bulk create — up to 5 batch requests in flight at once, cutting
233
- # wall time for large imports. Transient failures (e.g. HTTP 429) are retried,
234
- # honoring Retry-After. With concurrency > 1 the success_callback runs on the
235
- # caller thread in completion order (not submission order).
236
- ctx.execute_batch(concurrency=5)
237
-
238
- # Filter, select, expand
239
- items = ctx.web.lists.get_by_title("Projects")\
240
- .items\
241
- .filter("Status eq 'Active'")\
242
- .select(["Title", "Author/Title"])\
243
- .expand(["Author"])\
244
- .get_all().execute_query()
245
- ```
246
-
247
- [All list examples](examples/sharepoint/lists/)
248
-
249
- ### Files & Folders
250
-
251
- ```python
252
- # Upload file
253
- with open("report.pdf", "rb") as f:
254
- folder = ctx.web.get_folder_by_server_relative_url("/sites/mysite/Shared Documents")
255
- file = folder.upload_file("report.pdf", f).execute_query()
256
-
257
- # Download file
258
- with open("report.pdf", "wb") as f:
259
- ctx.web.get_file_by_server_relative_path("/sites/mysite/Shared Documents/report.pdf")\
260
- .download(f).execute_query()
261
-
262
- # Large file upload (chunked)
263
- folder.files.create_upload_session(
264
- local_path, chunk_size=10*1024*1024,
265
- chunk_uploaded=lambda offset: print(f"{offset} bytes uploaded")
266
- ).execute_query()
267
-
268
- # Download folder as zip
269
- with open("archive.zip", "wb") as f:
270
- folder.download_folder(f).execute_query()
271
-
272
- # Create nested folders
273
- base = ctx.web.get_folder_by_server_relative_url("/sites/mysite/Shared Documents")
274
- sub = base.add("Projects").execute_query()
275
- sub.add("2025").execute_query()
276
- ```
277
-
278
- [All file examples](examples/sharepoint/files/) | [All folder examples](examples/sharepoint/folders/)
279
-
280
- ### Search
281
-
282
- ```python
283
- from office365.sharepoint.search.request import SearchRequest
284
- from office365.sharepoint.search.service import SearchService
285
-
286
- search = SearchService(ctx)
287
- request = SearchRequest("IsDocument:1", RowLimit=50, StartRow=0)
288
- result = search.post_query(request).execute_query()
289
-
290
- rows = result.value.PrimaryQueryResult.RelevantResults.Table.Rows
291
- for row in rows:
292
- print(row)
293
- ```
294
-
295
- [All search examples](examples/sharepoint/search/)
296
-
297
- ### Permissions
298
-
299
- ```python
300
- from office365.sharepoint.roles.type import RoleType
301
-
302
- # Break inheritance and grant access to a user
303
- role_def = ctx.web.role_definitions.get_by_type(RoleType.Reader)
304
- user = ctx.web.ensure_user("i:0#.f|membership|user@company.com")
305
- item = ctx.web.lists.get_by_title("Confidential").items.get_by_id(1)
306
- item.break_role_inheritance(copy_role_assignments=False)
307
- item.add_role_assignment(user, role_def)
308
- ctx.execute_query()
309
- ```
310
-
311
- [Permissions examples](examples/sharepoint/permissions/)
312
-
313
- ### Site Administration (Tenant)
314
-
315
- ```python
316
- from office365.sharepoint.tenant.administration.tenant import Tenant
317
-
318
- tenant = Tenant(ctx)
319
-
320
- # List all sites
321
- sites = tenant.get_site_properties_from_sharepoint_by_filters().execute_query()
322
- for site in sites:
323
- print(site.url)
324
-
325
- # Create a site
326
- tenant.create_site({"Url": "https://tenant.sharepoint.com/sites/newsite", "Title": "New Site"}).execute_query()
327
- ```
328
-
329
- [All tenant/admin examples](examples/sharepoint/tenant/)
330
-
331
- ---
332
-
333
- ## Microsoft Graph - GraphClient
334
-
335
- ### Quick start
336
-
337
- ```python
338
- from office365.graph_client import GraphClient
339
-
340
- client = GraphClient(tenant="{tenant}").with_client_secret(
341
- client_id="{client_id}", client_secret="{client_secret}"
342
- )
343
- me = client.me.get().execute_query()
344
- print(f"Signed in as: {me.user_principal_name}")
345
- ```
346
-
347
- ### Outlook - Mail & Calendar
348
-
349
- ```python
350
- # Send email
351
- client.me.send_mail(
352
- subject="Hello",
353
- body="Message body",
354
- to_recipients=["user@company.com"]
355
- ).execute_query()
356
-
357
- # List messages
358
- messages = client.me.messages.top(10).get().execute_query()
359
- for msg in messages:
360
- print(msg.subject)
361
-
362
- # Create calendar event
363
- from office365.outlook.calendar.events.event import Event
364
- event = client.me.calendar.events.add(
365
- subject="Team standup",
366
- start="2025-06-01T09:00:00",
367
- end="2025-06-01T09:30:00"
368
- ).execute_query()
369
- ```
370
-
371
- [All Outlook examples](examples/outlook/)
372
-
373
- ### OneDrive
374
-
375
- ```python
376
- # List drives
377
- drives = client.drives.get().execute_query()
378
-
379
- # Upload file to OneDrive
380
- with open("report.xlsx", "rb") as f:
381
- client.me.drive.root.upload("report.xlsx", f).execute_query()
382
-
383
- # Download file
384
- with open("report.xlsx", "wb") as local_file:
385
- client.me.drive.root.get_by_path("Documents/report.xlsx")\
386
- .download(local_file).execute_query()
387
- ```
388
-
389
- [All OneDrive examples](examples/onedrive/)
390
-
391
- ### Teams
392
-
393
- ```python
394
- # List all teams
395
- teams = client.groups.get().execute_query()
396
-
397
- # Send channel message
398
- client.teams["{team_id}"].channels["{channel_id}"]\
399
- .messages.add(body="Hello team!").execute_query()
400
-
401
- # Create a team
402
- new_team = client.groups["{group_id}"].add_team().execute_query()
403
- ```
404
-
405
- [All Teams examples](examples/teams/)
406
-
407
- ### OneNote
408
-
409
- ```python
410
- # Create a page
411
- with open("MyPage.html", "rb") as f:
412
- page = client.me.onenote.pages.add(presentation_file=f).execute_query()
413
- ```
414
-
415
- [All OneNote examples](examples/onenote/)
416
-
417
- ### Planner
418
-
419
- ```python
420
- # Create a task
421
- task = client.planner.tasks.add(
422
- title="Review PR",
423
- planId="{plan_id}"
424
- ).execute_query()
425
- ```
426
-
427
- [All Planner examples](examples/planner/)
428
-
429
- ### Users & Groups
430
-
431
- ```python
432
- # List users
433
- users = client.users.top(100).get().execute_query()
434
-
435
- # Create group
436
- group = client.groups.add(
437
- display_name="Engineering",
438
- mail_nickname="engineering",
439
- mail_enabled=False,
440
- security_enabled=True
441
- ).execute_query()
442
- ```
443
-
444
- [All user examples](examples/entraid/users/)
445
-
446
- ---
447
-
448
- ## Dependencies
449
-
450
- Installed automatically:
451
-
452
- | Package | Purpose |
453
- |---|---|
454
- | [requests](https://github.com/psf/requests) | HTTP transport |
455
- | [msal](https://github.com/AzureAD/microsoft-authentication-library-for-python) | Azure AD authentication |
456
-
457
- Optional:
458
-
459
- ```bash
460
- pip install office365-rest-python-client[pandas] # to_dataframe() on collections
461
- ```
462
-
463
- ---
464
-
465
- ## Contributing
466
-
467
- PRs welcome. See [issues](https://github.com/vgrem/office365-rest-python-client/issues) for things to work on.
468
-
469
- ## Links
470
-
471
- - [PyPI](https://pypi.org/project/office365-rest-python-client/)
472
- - [Changelog](CHANGELOG.md)
473
- - [SharePoint REST API docs](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service)
474
- - [Microsoft Graph docs](https://learn.microsoft.com/en-us/graph/overview)
475
- - [MSAL for Python](https://github.com/AzureAD/microsoft-authentication-library-for-python)