Microsoft 365¶
The M365 class is the client for the Microsoft Graph API.
It manages users, groups, Teams, SharePoint sites and apps in a Microsoft 365 tenant.
m365
¶
M365 Module to interact with the MS Graph API.
See also https://learn.microsoft.com/en-us/graph/
Classes:
| Name | Description |
|---|---|
M365 |
Used to automate settings in Microsoft 365 via the Graph API. |
M365
¶
M365(
tenant_id: str,
client_id: str,
client_secret: str,
domain: str,
sku_id: str,
teams_app_name: str,
teams_app_external_id: str,
sharepoint_app_root_site: str = "",
sharepoint_app_client_id: str = "",
sharepoint_app_client_secret: str = "",
logger: Logger = default_logger,
)
Used to automate settings in Microsoft 365 via the Graph API.
Initialize the M365 object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tenant_id
|
str
|
The M365 Tenant ID. |
required |
client_id
|
str
|
The M365 Client ID. |
required |
client_secret
|
str
|
The M365 Client Secret. |
required |
domain
|
str
|
The M365 domain. |
required |
sku_id
|
str
|
License SKU for M365 users. |
required |
teams_app_name
|
str
|
The name of the Extended ECM app for MS Teams. |
required |
teams_app_external_id
|
str
|
The external ID of the Extended ECM app for MS Teams |
required |
sharepoint_app_root_site
|
str
|
The URL to the SharePoint root site. |
''
|
sharepoint_app_client_id
|
str
|
The SharePoint App client ID. |
''
|
sharepoint_app_client_secret
|
str
|
The SharePoint App client secret. |
''
|
logger
|
Logger
|
The logging object to use for all log messages. Defaults to default_logger. |
default_logger
|
Methods:
| Name | Description |
|---|---|
config |
Return the configuration dictionary. |
credentials |
Return the login credentials. |
credentials_user |
Get user credentials. |
request_header |
Return the request header used for Application calls. |
request_header_user |
Return the request header used for user specific calls. |
do_request |
Call an M365 Graph API in a safe way. |
parse_request_response |
Convert the request response (JSon) to a Python dict in a safe way. |
exist_result_item |
Check existence of key / value pair in the response properties of an MS Graph API call. |
get_result_value |
Get value of a result property with a given key of an MS Graph API call. |
lookup_result_value |
Look up a property value for a provided key-value pair of a REST response. |
authenticate |
Authenticate at M365 Graph API with client ID and client secret. |
authenticate_user |
Authenticate at M365 Graph API with username and password. |
get_users |
Get list of all (or filtered) users in M365 tenant. |
get_users_iterator |
Get an iterator object that can be used to traverse all M365 users. |
get_user |
Get a M365 User based on its email or ID. |
add_user |
Add a M365 user. |
update_user |
Update selected properties of an M365 user. |
get_user_licenses |
Get the assigned license SKUs of a user. |
assign_license_to_user |
Add an M365 license to a user (e.g. to use Office 365). |
get_user_photo |
Get the photo of a M365 user. |
download_user_photo |
Download the M365 user photo and save it to the local file system. |
update_user_photo |
Update the M365 user photo. |
get_user_drive |
Get the mysite (OneDrive) of the user. |
get_groups |
Get list of all groups in M365 tenant. |
get_groups_iterator |
Get an iterator object that can be used to traverse all M365 groups. |
get_group |
Get a M365 Group based on its name. |
add_group |
Add a M365 Group. |
get_group_members |
Get members (users and groups) of the specified group. |
add_group_member |
Add a member (user or group) to a (parent) group. |
is_member |
Check whether a M365 user is already in a M365 group. |
get_group_owners |
Get owners (users) of the specified group. |
add_group_owner |
Add an owner (user) to a group. |
purge_deleted_items |
Purge all deleted users and groups. |
purge_deleted_item |
Purge a single deleted user or group. |
has_team |
Check if a M365 Group has a M365 Team connected or not. |
get_team |
Get a M365 Team based on its name. |
add_team |
Add M365 Team based on an existing M365 Group. |
delete_team |
Delete Microsoft 365 Team with a specific ID. |
delete_teams |
Delete Microsoft 365 Teams with a specific name. |
delete_all_teams |
Delete all teams (groups) based on patterns and exceptions. |
get_team_channels |
Get channels of a M365 Team based on the team name. |
get_team_channel_tabs |
Get tabs of an M365 Team channel based on the team and channel names. |
get_teams_apps |
Get a list of MS Teams apps in catalog that match a given filter criterion. |
get_teams_app |
Get a specific MS Teams app in catalog based on the known (internal) app ID. |
get_teams_apps_of_user |
Get a list of MS Teams apps of a user that match a given filter criterion. |
get_teams_apps_of_team |
Get a list of MS Teams apps of a M365 team that match a given filter criterion. |
extract_version_from_app_manifest |
Extract the version number from the MS Teams app manifest file. |
upload_teams_app |
Upload a new app package to the catalog of MS Teams apps. |
remove_teams_app |
Remove MS Teams App from the app catalog. |
assign_teams_app_to_user |
Assign (add) a M365 Teams app to a M365 user. |
upgrade_teams_app_of_user |
Upgrade a MS teams app for a user. |
remove_teams_app_from_user |
Remove a M365 Teams app from a M365 user. |
assign_teams_app_to_team |
Assign (add) a MS Teams app to a M365 team. |
upgrade_teams_app_of_team |
Upgrade a MS teams app for a specific team. |
add_teams_app_to_channel |
Add tab for Extended ECM app to an M365 Team channel. |
update_teams_app_of_channel |
Update an existing tab for Extended ECM app in an M365 Team channel. |
delete_teams_app_from_channel |
Delete an existing tab for Extended ECM app from an M365 Team channel. |
add_sensitivity_label |
Create a new sensitivity label in M365. |
assign_sensitivity_label_to_user |
Assign an existing sensitivity label to a user. |
upload_outlook_app |
Upload the M365 Outlook Add-In as "Integrated" App to M365 Admin Center. |
get_app_registration |
Find an Azure App Registration based on its name. |
add_app_registration |
Add an Azure App Registration. |
update_app_registration |
Update an Azure App Registration. |
get_mail |
Get email from inbox of a given user and a given sender (from). |
get_mail_body |
Get full email body for a given email ID. |
extract_url_from_message_body |
Parse the email body to extract (a potentially multi-line) URL from the body. |
delete_mail |
Delete email from inbox of a given user and a given email ID. |
email_verification |
Process email verification. |
get_sharepoint_sites |
Retrieve a list of SharePoint sites. |
get_sharepoint_root_sites |
Get all SharePoint root sites. |
get_sharepoint_sites_iterator |
Get an iterator object that can be used to traverse all SharePoint sites matching the filter. |
get_sharepoint_site |
Retrieve a SharePoint site by its ID. |
get_sharepoint_site_by_name |
Retrieve a SharePoint site by its name. |
get_sharepoint_site_for_group |
Retrieve a SharePoint site for a M365 group. |
get_sharepoint_site_drive |
Get the default document library drive of a SharePoint site. |
get_sharepoint_pages |
Retrieve a list of SharePoint site pages accessible to the authenticated user. |
get_sharepoint_page |
Retrieve a page of a SharePoint site accessible to the authenticated user. |
add_sharepoint_page |
Add a new SharePoint site page using Microsoft Graph API. |
publish_sharepoint_page |
Publish a page of a SharePoint site. |
get_sharepoint_sections |
Retrieve all sections of a SharePoint site page. |
get_sharepoint_section |
Retrieve a section of a SharePoint site page. |
add_sharepoint_section |
Create a specific section (horizontal or vertical) on a SharePoint page. |
delete_sharepoint_section |
Delete a specific section (horizontal or vertical) on a SharePoint page. |
get_sharepoint_webparts |
Retrieve the configured webparts on a SharePoint site page. |
get_sharepoint_webpart |
Retrieve a web part of a SharePoint site page. |
add_sharepoint_webpart |
Create a specific web part on a SharePoint page. |
update_sharepoint_webpart |
Update the data of a specific web part on a SharePoint page. |
follow_sharepoint_site |
Let a user follow a particular SharePoint site. |
get_container_types |
Get a list of container types in the tenant. |
get_container_type |
Get a specific container type by its ID. |
add_container_type |
Create a new container type. |
update_container_type |
Update an existing container type. |
delete_container_type |
Delete a trial container type. |
register_container_type |
Register a container type in a consuming tenant. |
get_containers |
Get a list of file storage containers for a given container type. |
get_container |
Get a specific file storage container by its ID. |
add_container |
Create a new file storage container. |
update_container |
Update an existing file storage container. |
delete_container |
Delete (soft-delete) a file storage container. |
activate_container |
Activate a newly created file storage container. |
restore_container |
Restore a soft-deleted file storage container. |
permanently_delete_container |
Permanently delete a file storage container. |
lock_container |
Lock a file storage container. |
unlock_container |
Unlock a locked file storage container. |
get_container_permissions |
List permissions on a file storage container. |
get_container_permission |
Get a specific permission on a file storage container. |
add_container_permission |
Add a permission to a file storage container. |
update_container_permission |
Update a permission on a file storage container. |
delete_container_permission |
Delete a permission from a file storage container. |
get_container_custom_properties |
List custom properties of a file storage container. |
add_container_custom_property |
Add a custom property to a file storage container. |
update_container_custom_property |
Update a custom property on a file storage container. |
delete_container_custom_property |
Delete a custom property from a file storage container. |
get_container_columns |
List column definitions of a file storage container. |
get_container_column |
Get a specific column definition of a file storage container. |
add_container_column |
Create a column for a file storage container. |
update_container_column |
Update a column definition of a file storage container. |
delete_container_column |
Delete a column definition from a file storage container. |
get_container_drive |
Get the drive resource of a file storage container. |
get_container_recycle_bin_items |
List recycle bin items in a file storage container. |
restore_container_recycle_bin_items |
Restore recycle bin items in a file storage container. |
delete_container_recycle_bin_item |
Permanently delete a recycle bin item from a file storage container. |
update_container_recycle_bin_settings |
Update recycle bin settings for a file storage container. |
get_drive_items |
List items (files and folders) in the root or a specific folder of a drive. |
get_drive_item_children |
List children of a specific folder (by item ID) in a drive. |
get_drive_item |
Get metadata for a specific item (file or folder) in a drive. |
add_drive_folder |
Create a new folder in a drive. |
upload_drive_item |
Upload a small file (up to 4 MB) to a drive. |
upload_drive_item_session |
Upload a large file (> 4 MB) to a drive using an upload session. |
download_drive_item |
Download a file from a drive to the local file system. |
update_drive_item |
Update metadata of a drive item (file or folder). |
delete_drive_item |
Delete a drive item (file or folder). |
copy_drive_item |
Copy a drive item (file or folder) to a new location. |
move_drive_item |
Move a drive item (file or folder) to a new location. |
get_drive_item_fields |
Get the custom column (field) values of a drive item. |
add_drive_item_permission |
Grant an additive permission on a drive item. |
get_drive_item_permissions |
List permissions on a drive item. |
get_drive_item_permission |
Get a specific permission on a drive item. |
delete_drive_item_permission |
Delete an additive permission from a drive item. |
update_drive_item_fields |
Update the custom column (field) values of a drive item. |
search_drive_items |
Search for drive items within a drive. |
search_containers |
Search SharePoint Embedded containers with Microsoft Search. |
search_container_content |
Search content in SharePoint Embedded containers. |
update_container_sensitivity_label |
Assign or update the sensitivity label on a file storage container. |
get_deleted_containers |
List deleted (soft-deleted) file storage containers. |
upsert_container_permissions |
Upsert (create or update) multiple permissions on a container in one request. |
provision_migration_containers |
Provision temporary Azure blob containers for content migration. |
create_container_migration_job |
Create a migration job to import content into an SPE container. |
get_drive_item_activities |
Get the activity history (audit trail) of a single drive item. |
get_audit_events |
Get tenant-wide audit events from the Office 365 unified audit log. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
config
¶
Return the configuration dictionary.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Configuration dictionary |
credentials
¶
Return the login credentials.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary with (admin) login credentials for M365. |
credentials_user
¶
Get user credentials.
In some cases MS Graph APIs cannot be called via application permissions (client_id, client_secret) but requires a token of a user authenticated with username + password. This is e.g. the case to upload a MS teams app to the catalog.
See https://learn.microsoft.com/en-us/graph/api/teamsapp-publish
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
The M365 username. |
required |
password
|
str
|
The password of the M365 user. |
required |
scope
|
str
|
The scope of the delegated permission. It is important to provide a scope for the intended operation like "Files.ReadWrite". Defaults to "Files.ReadWrite". |
'Files.ReadWrite'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary with the (user) credentials for M365. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
request_header
¶
Return the request header used for Application calls.
Consists of Bearer access token and Content Type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_type
|
str
|
The content type for the request. Default is "application/json". |
'application/json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The request header values. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
request_header_user
¶
Return the request header used for user specific calls.
Consists of Bearer access token and Content Type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_type
|
str
|
The content type for the request. Defaults to "application/json". |
'application/json'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The request header values. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
do_request
¶
do_request(
url: str,
method: str = "GET",
headers: dict | None = None,
data: dict | None = None,
json_data: dict | None = None,
files: dict | None = None,
params: dict | None = None,
timeout: float | None = REQUEST_TIMEOUT,
show_error: bool = True,
show_warning: bool = False,
warning_message: str = "",
failure_message: str = "",
success_message: str = "",
max_retries: int = REQUEST_MAX_RETRIES,
retry_forever: bool = False,
parse_request_response: bool = True,
stream: bool = False,
) -> dict | None
Call an M365 Graph API in a safe way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to send the request to. |
required |
method
|
str
|
HTTP method (GET, POST, etc.). Defaults to "GET". |
'GET'
|
headers
|
dict | None
|
Request Headers. Defaults to None. |
None
|
data
|
dict | None
|
Request payload. Defaults to None. |
None
|
json_data
|
dict | None
|
Request payload for the JSON parameter. Defaults to None. |
None
|
files
|
dict | None
|
Dictionary of {"name": file-tuple} for multipart encoding upload. file-tuple can be a 2-tuple ("filename", fileobj) or a 3-tuple ("filename", fileobj, "content_type") |
None
|
params
|
dict | None
|
Add key-value pairs to the query string of the URL. When you use the params parameter, requests automatically appends the key-value pairs to the URL as part of the query string |
None
|
timeout
|
float | None
|
Timeout for the request in seconds. Defaults to REQUEST_TIMEOUT. |
REQUEST_TIMEOUT
|
show_error
|
bool
|
Whether or not an error should be logged in case of a failed REST call. If False, then a warning is logged only if show_warning is True. Defaults to True. |
True
|
show_warning
|
bool
|
Whether or not a warning should be logged in case of a failed REST call (only used if show_error is False). Defaults to False. |
False
|
warning_message
|
str
|
Specific warning message. Defaults to "". If not given the error_message will be used. |
''
|
failure_message
|
str
|
Specific error message. Defaults to "". |
''
|
success_message
|
str
|
Specific success message. Defaults to "". |
''
|
max_retries
|
int
|
How many retries on Connection errors? Default is REQUEST_MAX_RETRIES. |
REQUEST_MAX_RETRIES
|
retry_forever
|
bool
|
Eventually wait forever - without timeout. Defaults to False. |
False
|
parse_request_response
|
bool
|
Defines whether the response.text should be interpreted as json and loaded into a dictionary. True is the default. |
True
|
stream
|
bool
|
This parameter is used to control whether the response content should be immediately downloaded or streamed incrementally. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of M365 Graph REST API or None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
parse_request_response
¶
parse_request_response(
response_object: Response,
additional_error_message: str = "",
show_error: bool = True,
) -> dict | None
Convert the request response (JSon) to a Python dict in a safe way.
It first tries to load the response.text via json.loads() that produces a dict output. Only if response.text is not set or is empty it just converts the response_object to a dict using the vars() built-in method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_object
|
Response
|
This is the response object delivered by the request call. |
required |
additional_error_message
|
str
|
Use a more specific error message in case of an error. |
''
|
show_error
|
bool
|
True: write an error to the log file False: write a warning to the log file Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: API response information or None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
exist_result_item
¶
Check existence of key / value pair in the response properties of an MS Graph API call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict | None
|
REST response from an MS Graph REST Call. |
required |
key
|
str
|
The property name (key). |
required |
value
|
str
|
The value to find in the item with the matching key |
required |
sub_dict_name
|
str
|
Some MS Graph API calls include nested dict structures that can be requested with an "expand" query parameter. In such a case we use the sub_dict_name to access it. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value was found, False otherwise |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_result_value
¶
get_result_value(
response: dict | None,
key: str,
index: int = 0,
sub_dict_name: str = "",
) -> str | None
Get value of a result property with a given key of an MS Graph API call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict | None
|
REST response from an MS Graph REST Call. |
required |
key
|
str
|
The property name (key). |
required |
index
|
int
|
Index to use (1st element has index 0). Defaults to 0. |
0
|
sub_dict_name
|
str
|
Some MS Graph API calls include nested dict structures that can be requested with an "expand" query parameter. In such a case we use the sub_dict_name to access it. |
''
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The value for the key, None otherwise. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
lookup_result_value
¶
lookup_result_value(
response: dict,
key: str,
value: str,
return_key: str,
sub_dict_name: str = "",
) -> str | None
Look up a property value for a provided key-value pair of a REST response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict
|
The REST response from an MS Graph REST call, containing property data. |
required |
key
|
str
|
Property name (key) to match in the response. |
required |
value
|
str
|
Value to find in the item with the matching key. |
required |
return_key
|
str
|
Name of the dictionary key whose value should be returned. |
required |
sub_dict_name
|
str
|
Some MS Graph API calls include nested dict structures that can be requested with an "expand" query parameter. In such a case we use the sub_dict_name to access it. |
''
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The value of the property specified by "return_key" if found, or None if the lookup fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
authenticate
¶
Authenticate at M365 Graph API with client ID and client secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
revalidate
|
bool
|
Determines if a re-authentication is enforced. (e.g. if session has timed out with 401 error) |
False
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The access token. Also stores access token in self._access_token. None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
authenticate_user
¶
Authenticate at M365 Graph API with username and password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
The name (email) of the M365 user. |
required |
password
|
str
|
The password of the M365 user. |
required |
scope
|
str | None
|
The scope of the delegated permission. E.g. "Files.ReadWrite". Multiple delegated permissions should be separated by spaces. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The access token for the user. Also stores access token in self._user_access_token. None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_users
¶
get_users(
max_number: int = 250,
next_page_url: str | None = None,
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
) -> dict | None
Get list of all (or filtered) users in M365 tenant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_number
|
int
|
The maximum result values (limit). Defaults to 250. |
250
|
next_page_url
|
str
|
The MS Graph URL to retrieve the next page of M365 users (pagination). This is used for the iterator get_users_iterator() below. |
None
|
select
|
str
|
Fields to select from the result set (e.g., "userPrincipalName,displayName,mail"). If not specified, all fields are returned. Reduces payload size when set. |
None
|
filter_expression
|
str
|
OData filter expression to filter the results (e.g., "accountEnabled eq true"). See https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter |
None
|
order_by
|
str
|
Field(s) to order results by (e.g., "displayName asc" or "createdDateTime desc"). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Dictionary of M365 users. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_users_iterator
¶
get_users_iterator(
max_number: int = 250,
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
) -> iter
Get an iterator object that can be used to traverse all M365 users.
Returning a generator avoids loading a large number of nodes into memory at once. Instead you can iterate over the potential large list of users.
Example
users = m365_object.get_users_iterator()
for user in users:
logger.info("Traversing M365 user -> '%s'...", user.get("displayName", "
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_number
|
int
|
The maximum result values (limit) per request page. Defaults to 250. |
250
|
select
|
str | None
|
Fields to select from the result set. |
None
|
filter_expression
|
str | None
|
OData filter expression to filter the results. |
None
|
order_by
|
str | None
|
Field(s) to order results by. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
iter |
iter
|
A generator yielding one M365 user per iteration. If the REST API fails, returns no value. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_user
¶
Get a M365 User based on its email or ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_email
|
str
|
The M365 user email. |
required |
user_id
|
str | None
|
The ID of the M365 user (alternatively to user_email). Optional. |
None
|
show_error
|
bool
|
Whether or not an error should be displayed if the user is not found. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: User information or None if the user couldn't be retrieved (e.g. because it doesn't exist or if there is a permission problem). |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#users/$entity', 'businessPhones': [], 'displayName': 'Bob Davis', 'givenName': 'Bob', 'id': '72c80809-094f-4e6e-98d4-25a736385d10', 'jobTitle': None, 'mail': 'bdavis@M365x12345678.onmicrosoft.com', 'mobilePhone': None, 'officeLocation': None, 'preferredLanguage': None, 'surname': 'Davis', 'userPrincipalName': 'bdavis@M365x12345678.onmicrosoft.com' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 | |
add_user
¶
add_user(
email: str,
password: str,
first_name: str,
last_name: str,
location: str = "US",
department: str = "",
company_name: str = "Innovate",
) -> dict | None
Add a M365 user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
The email address of the user. This is also the unique identifier. |
required |
password
|
str
|
The password of the user. |
required |
first_name
|
str
|
The first name of the user. |
required |
last_name
|
str
|
The last name of the user. |
required |
location
|
str
|
The country ISO 3166-1 alpha-2 code (e.g. US, CA, FR, DE, CN, ...). Defaults to "US". |
'US'
|
department
|
str
|
The department of the user. Defaults to "". |
''
|
company_name
|
str
|
The name of the company the user works for. Defaults to "Innovate". |
'Innovate'
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: User information or None if the user couldn't be created (e.g. because it exists already or if a permission problem occurs). |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | |
update_user
¶
Update selected properties of an M365 user.
Documentation on user properties is here: https://learn.microsoft.com/en-us/graph/api/user-update
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The ID of the user (can also be email). This is also the unique identifier. |
required |
updated_settings
|
dict
|
The new data to update the user with. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the M365 Graph API or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_user_licenses
¶
Get the assigned license SKUs of a user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict | None
|
A list of user licenses or None if request fails. |
Example
{ '@odata.context': "https://graph.microsoft.com/v1.0/$metadata#users('a5875311-f0a5-486d-a746-bd7372b91115')/licenseDetails", 'value': [ { 'id': '8DRPYHK6IUOra-Nq6L0A7GAn38eBLPdOtXhbU5K1cd8', 'skuId': 'c7df2760-2c81-4ef7-b578-5b5392b571df', 'skuPartNumber': 'ENTERPRISEPREMIUM', 'servicePlans': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, ...] } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
assign_license_to_user
¶
Add an M365 license to a user (e.g. to use Office 365).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user) |
required |
sku_id
|
str
|
M365 GUID of the SKU. (e.g. c7df2760-2c81-4ef7-b578-5b5392b571df for E5 and 6fd2c87f-b296-42f0-b197-1e91e994b900 for E3) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict | None
|
The API response or None if request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_user_photo
¶
Get the photo of a M365 user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
show_error
|
bool
|
Whether or not an error should be logged if the user does not have a photo in M365. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
bytes | None
|
bytes | None: Image of the user photo or None if the user photo couldn't be retrieved. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
download_user_photo
¶
Download the M365 user photo and save it to the local file system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
photo_path
|
str
|
The directory where the photo should be saved. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The name of the photo file in the file system (with full path) or None if the call of the REST API fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | |
update_user_photo
¶
Update the M365 user photo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
photo_path
|
str
|
The file system path with the location of the photo file. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of Graph REST API or None if the user photo couldn't be updated. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_user_drive
¶
Get the mysite (OneDrive) of the user.
It may be required to do this before certain other operations are possible. These operations may require that the mydrive is initialized for that user. If you get errors like "User's mysite not found." this may be the case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
me
|
bool
|
Should be True if the user itself is accessing the drive. Defaults to False. |
False
|
show_error
|
bool
|
Log a failed request as an error. Set this to False while polling for a mySite that is still being provisioned - a 404 is expected there and should not be reported as an error. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The drive information of the user or None if request fails. |
Example: { '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#drives/$entity', 'createdDateTime': '2025-04-10T23:43:26Z', 'description': '', 'id': 'b!VsxYN1IbrEqbiwMiba_M7FCkNAhL5LRFnQEZpEYbxDAxvvcvUMAhSqfgWW_4eAUP', 'lastModifiedDateTime': '2025-04-12T15:50:20Z', 'name': 'OneDrive', 'webUrl': 'https://ideateqa-my.sharepoint.com/personal/jbenham_qa_idea-te_eimdemo_com/Documents', 'driveType': 'business', 'createdBy': { 'user': { 'displayName': 'System Account' } }, 'lastModifiedBy': { 'user': { 'email': 'jbenham@qa.idea-te.eimdemo.com', 'id': '470060cc-4d9f-439e-8a6e-8d567c5bda80', 'displayName': 'Jeff Benham' } }, 'owner': { 'user': {...} }, 'quota': { 'deleted': 0, 'remaining': 1099511518137, 'state': 'normal', 'total': 1099511627776, 'used': 109639 } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 | |
get_groups
¶
get_groups(
max_number: int = 250,
next_page_url: str | None = None,
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
) -> dict | None
Get list of all groups in M365 tenant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_number
|
int
|
The maximum result values (limit). Defaults to 250. |
250
|
next_page_url
|
str
|
The MS Graph URL to retrieve the next page of M365 groups (pagination). This is used for the iterator get_groups_iterator() below. |
None
|
select
|
str
|
Fields to select from the result set (e.g., "id,displayName,mail,visibility"). If not specified, all fields are returned. Reduces payload size when set. |
None
|
filter_expression
|
str
|
OData filter expression to filter the results (e.g., "groupTypes/any(c:c eq 'Unified')"). See https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter |
None
|
order_by
|
str
|
Field(s) to order results by (e.g., "displayName asc" or "createdDateTime desc"). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary of all groups or None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 | |
get_groups_iterator
¶
get_groups_iterator(
max_number: int = 250,
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
) -> iter
Get an iterator object that can be used to traverse all M365 groups.
Returning a generator avoids loading a large number of nodes into memory at once. Instead you can iterate over the potential large list of groups.
Example
groups = m365_object.get_groups_iterator()
for group in groups:
logger.info("Traversing M365 group -> '%s'...", group.get("displayName", "
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_number
|
int
|
The maximum result values (limit) per request page. Defaults to 250. |
250
|
select
|
str | None
|
Fields to select from the result set. |
None
|
filter_expression
|
str | None
|
OData filter expression to filter the results. |
None
|
order_by
|
str | None
|
Field(s) to order results by. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
iter |
iter
|
A generator yielding one M365 group per iteration. If the REST API fails, returns no value. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 | |
get_group
¶
Get a M365 Group based on its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_name
|
str
|
The M365 Group name. |
required |
show_error
|
bool
|
Should an error be logged if group is not found. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Group information or None if the group doesn't exist. |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#groups', 'value': [ { 'id': 'b65f7dba-3ed1-49df-91bf-2bf99affcc8d', 'deletedDateTime': None, 'classification': None, 'createdDateTime': '2023-04-01T13:46:26Z', 'creationOptions': [], 'description': 'Engineering & Construction', 'displayName': 'Engineering & Construction', 'expirationDateTime': None, 'groupTypes': ['Unified'], 'isAssignableToRole': None, 'mail': 'Engineering&Construction@M365x12345678.onmicrosoft.com', 'mailEnabled': True, 'mailNickname': 'Engineering&Construction', 'membershipRule': None, 'membershipRuleProcessingState': None, 'onPremisesDomainName': None, 'onPremisesLastSyncDateTime': None, 'onPremisesNetBiosName': None, 'onPremisesSamAccountName': None, 'onPremisesSecurityIdentifier': None, 'onPremisesSyncEnabled': None, 'preferredDataLocation': None, 'preferredLanguage': None, 'proxyAddresses': ['SPO:SPO_d9deb3e7-c72f-4e8d-80fb-5d9411ca1458@SPO_604f34f0-ba72-4321-ab6b-e36ae8bd00ec', ...], 'renewedDateTime': '2023-04-01T13:46:26Z', 'resourceBehaviorOptions': [], 'resourceProvisioningOptions': [], 'securityEnabled': False, 'securityIdentifier': 'S-1-12-1-3059711418-1239367377-4180393873-2379022234', 'theme': None, 'visibility': 'Public', 'onPremisesProvisioningErrors': [] }, { 'id': '61359860-302e-4016-b5cc-abff2293dff1', ... } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 | |
add_group
¶
add_group(
name: str,
security_enabled: bool = False,
mail_enabled: bool = True,
description: str = "",
visibility: str = "Public",
mail_nickname: str = "",
owners: list | None = None,
members: list | None = None,
resource_behavior_options: list | None = None,
) -> dict | None
Add a M365 Group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the group. |
required |
security_enabled
|
bool
|
Whether or not this group is used for permission management. Defaults to False. |
False
|
mail_enabled
|
bool
|
Whether or not this group is email enabled. Defaults to True. |
True
|
description
|
str
|
A description for the group. Defaults to "". |
''
|
visibility
|
str
|
Group visibility. One of "Public" (default), "Private", or "HiddenMembership". Only applies to Unified (Microsoft 365) groups. |
'Public'
|
mail_nickname
|
str
|
The mail alias for the group. When omitted, the display name with spaces removed is used. Useful for names containing special characters. |
''
|
owners
|
list | None
|
List of M365 user-object IDs to seed as group owners at creation time. Supplying owners here is more efficient than calling add_group_owner() afterwards because it avoids a separate API round-trip. |
None
|
members
|
list | None
|
List of M365 user/group-object IDs to seed as members at creation time. |
None
|
resource_behavior_options
|
list | None
|
Optional list of behavioural flags, e.g.: "WelcomeEmailDisabled", "HideGroupInOutlook", "SubscribeMembersToCalendarEventsDisabled". |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Group information or None if the group couldn't be created (e.g. because it exists already). |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#groups/$entity', 'id': '28906460-a69c-439e-84ca-c70becf37655', 'deletedDateTime': None, 'classification': None, 'createdDateTime': '2023-04-01T11:40:13Z', 'creationOptions': [], 'description': None, 'displayName': 'Test', 'expirationDateTime': None, 'groupTypes': ['Unified'], 'isAssignableToRole': None, 'mail': 'xyz@M365x12345678.onmicrosoft.com', 'mailEnabled': True, 'mailNickname': 'Test', 'membershipRule': None, 'membershipRuleProcessingState': None, 'onPremisesDomainName': None, 'onPremisesLastSyncDateTime': None, 'onPremisesNetBiosName': None, 'onPremisesSamAccountName': None, 'onPremisesSecurityIdentifier': None, 'onPremisesSyncEnabled': None, 'onPremisesProvisioningErrors': [], 'preferredDataLocation': None, 'preferredLanguage': None, 'proxyAddresses': ['SMTP:xyz@M365x12345678.onmicrosoft.com'], 'renewedDateTime': '2023-04-01T11:40:13Z', 'resourceBehaviorOptions': [], 'resourceProvisioningOptions': [], 'securityEnabled': True, 'securityIdentifier': 'S-1-12-1-680551520-1134470812-197772884-1433859052', 'theme': None, 'visibility': 'Public' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 | |
get_group_members
¶
Get members (users and groups) of the specified group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_name
|
str
|
The name of the group. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of Graph REST API or None if the REST call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_group_member
¶
Add a member (user or group) to a (parent) group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id
|
str
|
The M365 GUID of the group. |
required |
member_id
|
str
|
The M365 GUID of the new member. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
is_member
¶
Check whether a M365 user is already in a M365 group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id
|
str
|
The M365 GUID of the group. |
required |
member_id
|
str
|
The M365 GUID of the user (member). |
required |
show_error
|
bool
|
Whether or not an error should be logged if the user is not a member of the group. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the user is in the group. False otherwise. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_group_owners
¶
Get owners (users) of the specified group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_name
|
str
|
The name of the group. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of Graph REST API or None if the REST call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_group_owner
¶
Add an owner (user) to a group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id
|
str
|
The M365 GUID of the group. |
required |
owner_id
|
str
|
The M365 GUID of the new owner. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
purge_deleted_items
¶
Purge all deleted users and groups.
Purging users and groups requires administrative rights that typically are not provided in Contoso example org.
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
purge_deleted_item
¶
Purge a single deleted user or group.
This requires elevated permissions that are typically not available via Graph API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str
|
The M365 GUID of the item to purge. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
has_team
¶
Check if a M365 Group has a M365 Team connected or not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_name
|
str
|
The name of the M365 group. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Returns True if a Team is assigned and False otherwise. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_team
¶
Get a M365 Team based on its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the M365 Team. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Teams data structure (dictionary) or None if the request fails. |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#teams', '@odata.count': 1, 'value': [ { 'id': '951bd036-c6fc-4da4-bb80-1860f5472a2f', 'createdDateTime': None, 'displayName': 'Procurement', 'description': 'Procurement', 'internalId': None, 'classification': None, 'specialization': None, 'visibility': 'public', 'webUrl': None, ...}]} 'isArchived': None, 'isMembershipLimitedToOwners': None, 'memberSettings': None, 'guestSettings': None, 'messagingSettings': None, ... } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 | |
add_team
¶
add_team(
name: str,
template_name: str = "standard",
member_settings: dict | None = None,
guest_settings: dict | None = None,
messaging_settings: dict | None = None,
fun_settings: dict | None = None,
) -> dict | None
Add M365 Team based on an existing M365 Group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the team. It is assumed that a group with the same name does already exist! |
required |
template_name
|
str
|
The name of the team template. "standard" is the default value. |
'standard'
|
member_settings
|
dict | None
|
Controls what regular members may do, e.g.:: |
None
|
guest_settings
|
dict | None
|
Controls what guest users may do, e.g.:: |
None
|
messaging_settings
|
dict | None
|
Controls messaging behaviour, e.g.:: |
None
|
fun_settings
|
dict | None
|
Controls fun features, e.g.:: |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Team information (json - empty text!) or None if the team couldn't be created (e.g. because it exists already). |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 | |
delete_team
¶
Delete Microsoft 365 Team with a specific ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
str
|
The ID of the Microsoft 365 Team to delete. |
required |
show_error
|
bool
|
Should an error be logged if the team cannot be deleted. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response dictionary if the team has been deleted, None otherwise. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_teams
¶
Delete Microsoft 365 Teams with a specific name.
Microsoft 365 allows to have multiple teams with the same name. So this method may delete multiple teams if they have the same name. The Graph API we use here is the M365 Group API as deleting the group also deletes the associated team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the Microsoft 365 Team. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if teams have been deleted, False otherwise. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 | |
delete_all_teams
¶
Delete all teams (groups) based on patterns and exceptions.
Only delete MS Teams that are NOT on the exception list AND that are matching at least one of the patterns in the provided pattern list.
This method is used for general cleanup of teams. Be aware that deleted teams are still listed under https://admin.microsoft.com/#/deletedgroups and it may take some days until M365 finally deletes them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exception_list
|
list | None
|
A list of group names that should not be deleted. |
None
|
pattern_list
|
list | None
|
A list of patterns for group names to be deleted (regular expression). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if teams have been deleted, False otherwise. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 | |
get_team_channels
¶
get_team_channels(
name: str,
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
) -> dict | None
Get channels of a M365 Team based on the team name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the M365 team. |
required |
select
|
str
|
Fields to select from the result set (e.g., "id,displayName,description"). If not specified, all fields are returned. Reduces payload size when set. |
None
|
filter_expression
|
str
|
OData filter expression to filter the results (e.g., "displayName eq 'General'"). See https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter |
None
|
order_by
|
str
|
Field(s) to order results by (e.g., "displayName asc" or "createdDateTime desc"). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The channel data structure (dictionary) or None if the request fails. |
Example
{ '@odata.context': "https://graph.microsoft.com/v1.0/$metadata#teams('951bd036-c6fc-4da4-bb80-1860f5472a2f')/channels", '@odata.count': 1, 'value': [ { 'id': '19:yPmPnXoFtvs5jmgL7fG-iXNENVMLsB_WSrxYK-zKakY1@thread.tacv2', 'createdDateTime': '2023-08-11T14:11:35.986Z', 'displayName': 'General', 'description': 'Procurement', 'isFavoriteByDefault': None, 'email': None, 'tenantId': '417e6e3a-82e6-4aa0-9d47-a7734ca3daea', 'webUrl': 'https://teams.microsoft.com/l/channel/19%3AyPmPnXoFtvs5jmgL7fG-iXNENVMLsB_WSrxYK-zKakY1%40thread.tacv2/Procurement?groupId=951bd036-c6fc-4da4-bb80-1860f5472a2f&tenantId=417e6e3a-82e6-4aa0-9d47-a7734ca3daea&allowXTenantAccess=False', 'membershipType': 'standard' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 | |
get_team_channel_tabs
¶
Get tabs of an M365 Team channel based on the team and channel names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_name
|
str
|
The name of the M365 Team. |
required |
channel_name
|
str
|
The name of the M365 Team channel. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Tabs data structure (dictionary) or None if the request fails. |
Example
{ '@odata.context': "https://graph.microsoft.com/v1.0/$metadata#teams('951bd036-c6fc-4da4-bb80-1860f5472a2f')/channels('19%3AyPmPnXoFtvs5jmgL7fG-iXNENVMLsB_WSrxYK-zKakY1%40thread.tacv2')/tabs", '@odata.count': 1, 'value': [ { 'id': '66f44e9a-0741-49a4-9500-ec82cc120115', 'displayName': 'Procurement', 'webUrl': 'https://teams.microsoft.com/l/entity/2851980b-95dc-4118-a1f5-5ae1894eaaaf/_djb2_msteams_prefix_66f44e9a-0741-49a4-9500-ec82cc120115?webUrl=https%3a%2f%2fotcs.fqdn.tld.com%2fcssupport%2fxecmoffice%2fteamsapp.html%3fnodeId%3d13178%26type%3dcontainer%26parentId%3d2000%26target%3dcontent%26csurl%3dhttps%3a%2f%2fotcs.fqdn.tld.com%2fcs%2fcs%26appId%3da168b00d-3ad9-46ac-8798-578c1961e1ed%26showBW%3dtrue%26title%3dProcurement&label=Procurement&context=%7b%0d%0a++%22canvasUrl%22%3a+%22https%3a%2f%2fotcs.fqdn.tld.com%2fcssupport%2fxecmoffice%2fteamsapp.html%3fnodeId%3d13178%26type%3dcontainer%26parentId%3d2000%26target%3dcontent%26csurl%3dhttps%3a%2f%2fotcs.fqdn.tld.com%2fcs%2fcs%26appId%3da168b00d-3ad9-46ac-8798-578c1961e1ed%22%2c%0d%0a++%22channelId%22%3a+%2219%3ayPmPnXoFtvs5jmgL7fG-iXNENVMLsB_WSrxYK-zKakY1%40thread.tacv2%22%2c%0d%0a++%22subEntityId%22%3a+null%0d%0a%7d&groupId=951bd036-c6fc-4da4-bb80-1860f5472a2f&tenantId=417e6e3a-82e6-4aa0-9d47-a7734ca3daea', 'configuration': { 'entityId': '13178', 'contentUrl': 'https://otcs.fqdn.tld.com/cssupport/xecmoffice/teamsapp.html?nodeId=13178&type=container&parentId=2000&target=content&csurl=https://otcs.fqdn.tld.com/cs/cs&appId=a168b00d-3ad9-46ac-8798-578c1961e1ed', 'removeUrl': None, 'websiteUrl': 'https://otcs.fqdn.tld.com/cssupport/xecmoffice/teamsapp.html?nodeId=13178&type=container&parentId=2000&target=content&csurl=https://otcs.fqdn.tld.com/cs/cs&appId=a168b00d-3ad9-46ac-8798-578c1961e1ed&showBW=true&title=Procurement', 'dateAdded': '2023-08-12T08:57:35.895Z' } } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 | |
get_teams_apps
¶
Get a list of MS Teams apps in catalog that match a given filter criterion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_expression
|
str
|
Filter string see https://learn.microsoft.com/en-us/graph/filter-query-parameter |
''
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#appCatalogs/teamsApps(appDefinitions())', '@odata.count': 1, 'value': [ { 'id': '2851980b-95dc-4118-a1f5-5ae1894eaaaf', 'externalId': 'dd4af790-d8ff-47a0-87ad-486318272c7a', 'displayName': 'OpenText Extended ECM', 'distributionMethod': 'organization', 'appDefinitions@odata.context': "https://graph.microsoft.com/v1.0/$metadata#appCatalogs/teamsApps('2851980b-95dc-4118-a1f5-5ae1894eaaaf')/appDefinitions", 'appDefinitions': [ { 'id': 'Mjg1MTk4MGItOTVkYy00MTE4LWExZjUtNWFlMTg5NGVhYWFmIyMyMi40IyNQdWJsaXNoZWQ=', 'teamsAppId': '2851980b-95dc-4118-a1f5-5ae1894eaaaf', 'displayName': 'OpenText Extended ECM', 'version': '22.4', 'publishingState': 'published', 'shortDescription': 'Add a tab for an Extended ECM business workspace.', 'description': 'View and interact with OpenText Extended ECM business workspaces', 'lastModifiedDateTime': None, 'createdBy': None, 'authorization': { 'requiredPermissionSet': {...} } } ] } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 | |
get_teams_app
¶
Get a specific MS Teams app in catalog based on the known (internal) app ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_id
|
str
|
ID of the app (this is NOT the external ID but the internal ID). |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#appCatalogs/teamsApps(appDefinitions())/$entity', 'id': 'ccabe3fb-316f-40e0-a486-1659682cb8cd', 'externalId': 'dd4af790-d8ff-47a0-87ad-486318272c7a', 'displayName': 'Extended ECM', 'distributionMethod': 'organization', 'appDefinitions@odata.context': "https://graph.microsoft.com/v1.0/$metadata#appCatalogs/teamsApps('ccabe3fb-316f-40e0-a486-1659682cb8cd')/appDefinitions", 'appDefinitions': [ { 'id': 'Y2NhYmUzZmItMzE2Zi00MGUwLWE0ODYtMTY1OTY4MmNiOGNkIyMyNC4yLjAjI1B1Ymxpc2hlZA==', 'teamsAppId': 'ccabe3fb-316f-40e0-a486-1659682cb8cd', 'displayName': 'Extended ECM', 'version': '24.2.0', 'publishingState': 'published', 'shortDescription': 'Add a tab for an Extended ECM business workspace.', 'description': 'View and interact with OpenText Extended ECM business workspaces', 'lastModifiedDateTime': None, 'createdBy': None, 'authorization': {...} } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_teams_apps_of_user
¶
Get a list of MS Teams apps of a user that match a given filter criterion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user) |
required |
filter_expression
|
str
|
Filter string see https://learn.microsoft.com/en-us/graph/filter-query-parameter |
''
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_teams_apps_of_team
¶
Get a list of MS Teams apps of a M365 team that match a given filter criterion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
str
|
The M365 ID of the team. |
required |
filter_expression
|
str
|
Filter string see https://learn.microsoft.com/en-us/graph/filter-query-parameter |
''
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
extract_version_from_app_manifest
¶
Extract the version number from the MS Teams app manifest file.
This can be used to check if the app package includes a newer app version then the already installed one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_path
|
str
|
The file path (with directory) to the app package to extract the version from. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The version number or None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
upload_teams_app
¶
upload_teams_app(
app_path: str,
update_existing_app: bool = False,
app_catalog_id: str = "",
) -> dict | None
Upload a new app package to the catalog of MS Teams apps.
This is not possible with client secret credentials but requires a token of a user authenticated with username + password. See https://learn.microsoft.com/en-us/graph/api/teamsapp-publish (permissions table on that page).
For updates see: https://learn.microsoft.com/en-us/graph/api/teamsapp-update?view=graph-rest-1.0&tabs=http
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_path
|
str
|
The file path (with directory) to the app package to upload. |
required |
update_existing_app
|
bool
|
Whether or not to update an existing app with the same name. Defaults to False. |
False
|
app_catalog_id
|
str
|
The unique ID of the app. It is the ID the app has in the catalog - which is different from the ID an app gets after installation (which is tenant specific). Required if update_existing_app is True. Defaults to "". |
''
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS GRAPH API REST call or None if the request fails The responses are different depending if it is an install or upgrade!! |
Example return for upgrades ("teamsAppId" is the "internal" ID of the app): { '@odata.context': "https://graph.microsoft.com/v1.0/$metadata#appCatalogs/teamsApps('3f749cca-8cb0-4925-9fa0-ba7aca2014af')/appDefinitions/$entity", 'id': 'M2Y3NDljY2EtOGNiMC00OTI1LTlmYTAtYmE3YWNhMjAxNGFmIyMyNC4yLjAjI1B1Ymxpc2hlZA==', 'teamsAppId': '3f749cca-8cb0-4925-9fa0-ba7aca2014af', 'displayName': 'IDEA-TE - Extended ECM 24.2.0', 'version': '24.2.0', 'publishingState': 'published', 'shortDescription': 'Add a tab for an Extended ECM business workspace.', 'description': 'View and interact with OpenText Extended ECM business workspaces', 'lastModifiedDateTime': None, 'createdBy': None, 'authorization': { 'requiredPermissionSet': {...} } }
Example return for new installations ("id" is the "internal" ID of the app):
{
'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#appCatalogs/teamsApps/$entity',
'id': '6c672afd-37fc-46c6-8365-d499aba3808b',
'externalId': 'dd4af790-d8ff-47a0-87ad-486318272c7a',
'displayName': 'OpenText Extended ECM',
'distributionMethod': 'organization'
}
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 | |
remove_teams_app
¶
Remove MS Teams App from the app catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_id
|
str
|
The Microsoft 365 GUID of the MS Teams app. |
required |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
assign_teams_app_to_user
¶
assign_teams_app_to_user(
user_id: str,
app_name: str = "",
app_internal_id: str = "",
show_error: bool = False,
) -> dict | None
Assign (add) a M365 Teams app to a M365 user.
See: https://learn.microsoft.com/en-us/graph/api/userteamwork-post-installedapps?view=graph-rest-1.0&tabs=http
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
app_name
|
str
|
The exact name of the app. Not needed if app_internal_id is provided. |
''
|
app_internal_id
|
str
|
The internal ID of the app. If not provided it will be derived from app_name. |
''
|
show_error
|
bool
|
Whether or not an error should be displayed if the user is not found. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 | |
upgrade_teams_app_of_user
¶
upgrade_teams_app_of_user(
user_id: str,
app_name: str,
app_installation_id: str | None = None,
) -> dict | None
Upgrade a MS teams app for a user.
The call will fail if the user does not already have the app assigned. So this needs to be checked before calling this method.
See: https://learn.microsoft.com/en-us/graph/api/userteamwork-teamsappinstallation-upgrade?view=graph-rest-1.0&tabs=http
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
app_name
|
str
|
The exact name of the app. |
required |
app_installation_id
|
str | None
|
The ID of the app installation for the user. This is neither the internal nor external app ID. It is specific for each user and app. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 | |
remove_teams_app_from_user
¶
remove_teams_app_from_user(
user_id: str,
app_name: str,
app_installation_id: str | None = None,
) -> dict | None
Remove a M365 Teams app from a M365 user.
See: https://learn.microsoft.com/en-us/graph/api/userteamwork-delete-installedapps?view=graph-rest-1.0&tabs=http
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 GUID of the user (can also be the M365 email of the user). |
required |
app_name
|
str
|
The exact name of the app. |
required |
app_installation_id
|
str | None
|
The installation ID of the app. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 | |
assign_teams_app_to_team
¶
Assign (add) a MS Teams app to a M365 team.
Afterwards the app can be added as a Tab in a M365 Teams Channel).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
str
|
The ID of the Microsoft 365 Team. |
required |
app_id
|
str
|
The ID of the M365 Team App. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: API response or None if the Graph API call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
upgrade_teams_app_of_team
¶
Upgrade a MS teams app for a specific team.
The call will fail if the team does not already have the app assigned. So this needs to be checked before calling this method.
THIS IS CURRENTLY NOT WORKING AS EXPECTED.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id
|
str
|
The M365 GUID of the team. |
required |
app_name
|
str
|
The exact name of the app. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response of the MS Graph API call or None if the call fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_teams_app_to_channel
¶
add_teams_app_to_channel(
team_name: str,
channel_name: str,
app_id: str,
tab_name: str,
app_url: str,
cs_node_id: int,
) -> dict | None
Add tab for Extended ECM app to an M365 Team channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_name
|
str
|
The name of the M365 Team |
required |
channel_name
|
str
|
The name of the channel. |
required |
app_id
|
str
|
ID of the MS Teams Application (e.g. the Extended ECM Teams App). |
required |
tab_name
|
str
|
The name of the tab. |
required |
app_url
|
str
|
The web URL of the app. |
required |
cs_node_id
|
int
|
The node ID of the target workspace or container in Extended ECM. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Return data structure (dictionary) or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 | |
update_teams_app_of_channel
¶
update_teams_app_of_channel(
team_name: str,
channel_name: str,
tab_name: str,
app_url: str,
cs_node_id: int,
) -> dict | None
Update an existing tab for Extended ECM app in an M365 Team channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_name
|
str
|
The name of the M365 Team. |
required |
channel_name
|
str
|
The name of the channel. |
required |
tab_name
|
str
|
The name of the tab. |
required |
app_url
|
str
|
The web URL of the app. |
required |
cs_node_id
|
int
|
The node ID of the target workspace or container in Content Server. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Return data structure (dictionary) or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 | |
delete_teams_app_from_channel
¶
Delete an existing tab for Extended ECM app from an M365 Team channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_name
|
str
|
The name of the M365 Team. |
required |
channel_name
|
str
|
The name of the channel. |
required |
tab_name
|
str
|
The name of the tab. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True = success, False = Error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 | |
add_sensitivity_label
¶
add_sensitivity_label(
name: str,
display_name: str,
description: str = "",
color: str = "red",
enabled: bool = True,
admin_description: str = "",
user_description: str = "",
enable_encryption: bool = False,
enable_marking: bool = False,
) -> dict | None
Create a new sensitivity label in M365.
TODO: THIS IS CURRENTLY NOT WORKING!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the label. |
required |
display_name
|
str
|
The display name of the label. |
required |
description
|
str
|
Description of the label. Defaults to "". |
''
|
color
|
str
|
Color of the label. Defaults to "red". |
'red'
|
enabled
|
bool
|
Whether this label is enabled. Defaults to True. |
True
|
admin_description
|
str
|
Description for administrators. Defaults to "". |
''
|
user_description
|
str
|
Description for users. Defaults to "". |
''
|
enable_encryption
|
bool
|
Enable encryption. Defaults to False. |
False
|
enable_marking
|
bool
|
Enable marking. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Request response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 | |
assign_sensitivity_label_to_user
¶
Assign an existing sensitivity label to a user.
TODO: THIS IS CURRENTLY NOT WORKING!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_email
|
str
|
The email address of the user (as unique identifier). |
required |
label_name
|
str
|
The name of the label (need to exist). |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Return the request response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
upload_outlook_app
¶
Upload the M365 Outlook Add-In as "Integrated" App to M365 Admin Center.
TODO: THIS IS CURRENTLY NOT IMPLEMENTED DUE TO MISSING MS GRAPH API SUPPORT!
https://admin.microsoft.com/#/Settings/IntegratedApps
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_path
|
str
|
Path to manifest file in local file system. Needs to be downloaded before. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Response of the MS Graph API or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_app_registration
¶
Find an Azure App Registration based on its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_registration_name
|
str
|
Name of the App Registration. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: App Registration data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_app_registration
¶
add_app_registration(
app_registration_name: str,
description: str = "",
api_permissions: list | None = None,
supported_account_type: str = "AzureADMyOrg",
) -> dict
Add an Azure App Registration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_registration_name
|
str
|
The name of the App Registration. |
required |
description
|
str
|
The description of the app. Defaults to "". |
''
|
api_permissions
|
list | None
|
The API permissions. Defaults to None. |
None
|
supported_account_type
|
str
|
The type of account that is supposed to use the App Registration. Defaults to "AzureADMyOrg". |
'AzureADMyOrg'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
App Registration data or None if the request fails. |
dict
|
Example data: |
|
dict
|
{ 'id': 'd70bee91-3689-4239-a626-30756968e99c', 'deletedDateTime': None, 'appId': 'd288ba5f-9313-4b38-b4a4-d7edcce089b0', 'applicationTemplateId': None, 'disabledByMicrosoftStatus': None, 'createdDateTime': '2023-09-06T21:06:05Z', 'displayName': 'Test 1', 'description': None, 'groupMembershipClaims': None, 'identifierUris': [], 'isDeviceOnlyAuthSupported': None, 'isFallbackPublicClient': None, 'notes': None, 'publisherDomain': 'M365x12345678.onmicrosoft.com', 'signInAudience': 'AzureADMyOrg', ... 'requiredResourceAccess': [ { 'resourceAppId': '00000003-0000-0ff1-ce00-000000000000', 'resourceAccess': [ { 'id': '741f803b-c850-494e-b5df-cde7c675a1ca', 'type': 'Role' }, { 'id': 'c8e3537c-ec53-43b9-bed3-b2bd3617ae97', 'type': 'Role' }, ] }, ] |
|
dict
|
} |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 | |
update_app_registration
¶
update_app_registration(
app_registration_id: str,
app_registration_name: str,
api_permissions: list,
supported_account_type: str = "AzureADMyOrg",
) -> dict
Update an Azure App Registration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_registration_id
|
str
|
The ID of the existing App Registration. |
required |
app_registration_name
|
str
|
The name of the App Registration. |
required |
api_permissions
|
list
|
The API permissions. |
required |
supported_account_type
|
str
|
The type of account that is supposed to use the App Registration. Defaults to "AzureADMyOrg". |
'AzureADMyOrg'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
App Registration data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_mail
¶
get_mail(
user_id: str,
sender: str = "",
subject: str = "",
num_emails: int | None = None,
show_error: bool = False,
folder: str = "inbox",
select_fields: list[str] | None = None,
order_by: str = "receivedDateTime desc",
received_after: str | None = None,
include_attachments: bool = False,
use_server_filter: bool = False,
additional_filter: str | None = None,
exact_sender_match: bool = True,
case_sensitive_subject: bool = False,
) -> dict | None
Get email from inbox of a given user and a given sender (from).
This requires Mail.Read Application permissions for the Azure App being used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 ID of the user. |
required |
sender
|
str
|
The sender email address to filter for. If empty no sender filtering is performed. Defaults to "". |
''
|
subject
|
str
|
The subject to filter for. If empty no subject filtering is performed. Defaults to "". |
''
|
num_emails
|
int | None
|
The number of matching emails to retrieve. Defaults to None. |
None
|
show_error
|
bool
|
Whether or not an error should be displayed if the user is not found. Defaults to False. |
False
|
folder
|
str
|
Mail folder to query (e.g. "inbox", "sentitems"). Defaults to "inbox". |
'inbox'
|
select_fields
|
list[str] | None
|
Optional list of fields for $select. |
None
|
order_by
|
str
|
Value for $orderby. Defaults to "receivedDateTime desc". |
'receivedDateTime desc'
|
received_after
|
str | None
|
If set, adds a receivedDateTime ge filter. Use ISO8601 format (e.g. "2026-05-03T00:00:00Z"). |
None
|
include_attachments
|
bool
|
Whether to expand attachments in the response. Defaults to False. |
False
|
use_server_filter
|
bool
|
If True, applies sender/subject/date filters via Graph $filter. If False (default), sender/subject filtering happens client-side for maximum compatibility. |
False
|
additional_filter
|
str | None
|
Additional raw Graph $filter expression combined with "and". |
None
|
exact_sender_match
|
bool
|
For client-side filtering: exact sender match if True, substring match if False. |
True
|
case_sensitive_subject
|
bool
|
For client-side filtering: case-sensitive subject matching if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Email or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 | |
get_mail_body
¶
Get full email body for a given email ID.
This requires Mail.Read Application permissions for the Azure App being used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 ID of the user. |
required |
email_id
|
str
|
The M365 ID of the email. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Email body or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
extract_url_from_message_body
¶
extract_url_from_message_body(
message_body: str,
search_pattern: str,
multi_line: bool = False,
multi_line_end_marker: str = "%3D",
line_end_marker: str = "=",
replacements: list | None = None,
) -> str | None
Parse the email body to extract (a potentially multi-line) URL from the body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_body
|
str
|
Text of the Email body. |
required |
search_pattern
|
str
|
Pattern that needs to be in first line of the URL. This makes sure it is the right URL we are looking for. |
required |
multi_line
|
bool
|
Is the URL spread over multiple lines?. Defaults to False. |
False
|
multi_line_end_marker
|
str
|
If it is a multi-line URL, what marks the end of the URL in the last line? Defaults to "%3D". |
'%3D'
|
line_end_marker
|
str
|
What marks the end of lines 1-(n-1)? Defaults to "=". |
'='
|
replacements
|
list
|
A list of replacements. |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The URL text that has been extracted. None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 | |
delete_mail
¶
Delete email from inbox of a given user and a given email ID.
This requires Mail.ReadWrite Application permissions for the Azure App being used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The M365 ID of the user. |
required |
email_id
|
str
|
The M365 ID of the email. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Email or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
email_verification
¶
email_verification(
user_email: str,
sender: str,
subject: str,
url_search_pattern: str,
line_end_marker: str = "=",
multi_line: bool = True,
multi_line_end_marker: str = "%3D",
replacements: list | None = None,
max_retries: int = 6,
use_browser_automation: bool = False,
password: str = "",
password_field_id: str = "",
password_confirmation_field_id: str = "",
password_submit_xpath: str = "",
terms_of_service_xpath: str = "",
) -> bool
Process email verification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_email
|
str
|
Email address of user receiving the verification mail. |
required |
sender
|
str
|
Email sender (address) |
required |
subject
|
str
|
Email subject to look for (can be substring) |
required |
url_search_pattern
|
str
|
String the URL needs to contain to identify it. |
required |
line_end_marker
|
str
|
The character that marks line ends in the mail. Defaults to "=". |
'='
|
multi_line
|
bool
|
Whether or not this is a multi-line mail. Defaults to True. |
True
|
multi_line_end_marker
|
str
|
If the URL spans multiple lines this is the "end" marker for the last line. Defaults to "%3D". |
'%3D'
|
replacements
|
list
|
If the URL needs some treatment these replacements can be applied. Defaults to None, which means that "=3D" is replaced by "=". |
None
|
max_retries
|
int
|
The number of retries in case of an error. Defaults to 6. |
6
|
use_browser_automation
|
bool
|
If Selenium-based browser automation should be used or not. Default = False. |
False
|
password
|
str
|
In case a password is required for browser automation. Default = "", |
''
|
password_field_id
|
str
|
The password field name in the HTML page of a confirmation dialog. Default = "", |
''
|
password_confirmation_field_id
|
str
|
The password confirmation field name in the HTML page of a confirmation dialog. Default = "". |
''
|
password_submit_xpath
|
str
|
Default = "". |
''
|
terms_of_service_xpath
|
str
|
Default = "". |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True = Success, False = Failure. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 | |
get_sharepoint_sites
¶
get_sharepoint_sites(
search: str | None = None,
filter_expression: str | None = None,
select: str | None = None,
limit: int = 50,
next_page_url: str | None = None,
) -> dict | None
Retrieve a list of SharePoint sites.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search
|
str
|
A string to search for to filter the results. Default is None = no filtering. |
None
|
filter_expression
|
str | None
|
Filter string to filter the results. Default is None = no filtering. |
None
|
select
|
str | None
|
Fields to select. Make sure that all fields are selected that are used in filters. Otherwise you will get no results. |
None
|
limit
|
int
|
The maximum number of sites to return in one call. Default is set to 50. |
50
|
next_page_url
|
str | None
|
The MS Graph URL to retrieve the next page of SharePoint sites (pagination). This is used for the iterator get_sharepoint_sites_iterator() below. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A list of SharePoint sites embedded in a "value" key in the dictionary. |
Example response: { '@odata.context': 'https://graph.microsoft.com/beta/$metadata#sites', '@odata.nextLink': 'https://graph.microsoft.com/beta/sites?$top=50&$skiptoken=UGFnZWQ9VFJVRSZwX1RpbWVEZWxldGVkPSZwX0lEPTE5MDM4', 'value': [ { 'createdDateTime': '2025-02-11T12:11:49Z', 'id': 'ideatedev-my.sharepoint.com,eeed2961-91ba-46c1-abc2-159f0277130f,5aa8a98d-659d-4a52-8701-6b9a728092d8', 'name': 'Diane Conner', 'webUrl': 'https://ideatedev-my.sharepoint.com/personal/dconner_dev_idea-te_eimdemo_com', 'displayName': 'Diane Conner', 'isPersonalSite': True, 'siteCollection': { 'hostname': 'ideatedev-my.sharepoint.com' }, 'root': {} }, { 'createdDateTime': '2025-02-06T07:44:44Z', 'id': 'ideatedev.sharepoint.com,570e67bc-1e69-4a62-89ea-994be9642b93,a1462b54-26f9-4a24-9660-2bc7859ce9af', 'name': 'SG325B - SEMI325B,ECM,PD,ExternalProcurement', 'webUrl': 'https://ideatedev.sharepoint.com/sites/SG325B-SEMI325BECMPDExternalProcurement698', 'displayName': 'SG325B - SEMI325B,ECM,PD,ExternalProcurement', 'isPersonalSite': False, 'siteCollection': { 'hostname': 'ideatedev.sharepoint.com' }, 'root': {} }, ... ] ]
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_root_sites
¶
get_sharepoint_sites_iterator
¶
get_sharepoint_sites_iterator(
search: str | None = None,
filter_expression: str | None = None,
select: str | None = None,
limit: int = 50,
) -> iter
Get an iterator object that can be used to traverse all SharePoint sites matching the filter.
Returning a generator avoids loading a large number of nodes into memory at once. Instead you can iterate over the potential large list of SharePoint sites.
Example
sites = m365_object.get_sharepoint_sites_iterator(limit=10)
for site in sites:
logger.info("Traversing SharePoint site -> '%s'...", site.get("name", "
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search
|
str | None
|
A string to search for to filter the results. Default is None = no filtering. |
None
|
filter_expression
|
str | None
|
Filter string to filter the results. Default is None = no filtering. |
None
|
select
|
str | None
|
Fields to select. Make sure that all fields are selected that are used in filters. Otherwise you will get no results. |
None
|
limit
|
int
|
The maximum number of sites to return in one call. Default is set to 50. |
50
|
Returns:
| Name | Type | Description |
|---|---|---|
iter |
iter
|
A generator yielding one SharePoint site per iteration. If the REST API fails, returns no value. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_site
¶
Retrieve a SharePoint site by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The data of the SharePoint site. |
Example: { '@odata.context': 'https://graph.microsoft.com/beta/$metadata#sites/$entity', 'createdDateTime': '2025-02-06T07:41:53.41Z', 'description': '', 'id': 'ideatedev.sharepoint.com,9b203cbe-27ca-45b2-944a-663cc99e5e8f,a1462b54-26f9-4a24-9660-2bc7859ce9af', 'lastModifiedDateTime': '2025-02-10T20:37:11Z', 'name': 'TG11-Trad.Good11PDReg.Trading795', 'webUrl': 'https://ideatedev.sharepoint.com/sites/TG11-Trad.Good11PDReg.Trading795', 'displayName': 'TG11 - Trad.Good 11,PD,Reg.Trading', 'root': {}, 'siteCollection': { 'hostname': 'ideatedev.sharepoint.com' } }
get_sharepoint_site_by_name
¶
Retrieve a SharePoint site by its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_name
|
str
|
The name of the SharePoint site to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The data of the SharePoint site. |
Example: { '@odata.context': 'https://graph.microsoft.com/beta/$metadata#sites/$entity', 'createdDateTime': '2025-02-06T07:41:53.41Z', 'description': '', 'id': 'ideatedev.sharepoint.com,9b203cbe-27ca-45b2-944a-663cc99e5e8f,a1462b54-26f9-4a24-9660-2bc7859ce9af', 'lastModifiedDateTime': '2025-02-10T20:37:11Z', 'name': 'TG11-Trad.Good11PDReg.Trading795', 'webUrl': 'https://ideatedev.sharepoint.com/sites/TG11-Trad.Good11PDReg.Trading795', 'displayName': 'TG11 - Trad.Good 11,PD,Reg.Trading', 'root': {}, 'siteCollection': { 'hostname': 'ideatedev.sharepoint.com' } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_site_for_group
¶
Retrieve a SharePoint site for a M365 group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id
|
str
|
The ID of the M365 group the site should be retrieved for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The data of the SharePoint site. |
Example: { '@odata.context': 'https://graph.microsoft.com/beta/$metadata#sites/$entity', 'createdDateTime': '2025-02-06T07:41:53.41Z', 'description': '', 'id': 'ideatedev.sharepoint.com,9b203cbe-27ca-45b2-944a-663cc99e5e8f,a1462b54-26f9-4a24-9660-2bc7859ce9af', 'lastModifiedDateTime': '2025-02-10T20:37:11Z', 'name': 'TG11-Trad.Good11PDReg.Trading795', 'webUrl': 'https://ideatedev.sharepoint.com/sites/TG11-Trad.Good11PDReg.Trading795', 'displayName': 'TG11 - Trad.Good 11,PD,Reg.Trading', 'root': {}, 'siteCollection': { 'hostname': 'ideatedev.sharepoint.com' } }
get_sharepoint_site_drive
¶
Get the default document library drive of a SharePoint site.
This returns the drive resource for the site's default document
library. The returned drive ID can then be used with the drive item
methods (get_drive_items(), upload_drive_item(), etc.) to
manage files and folders in the site's document library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The drive resource data or None if the request fails. |
Example
{ 'id': 'b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z', 'driveType': 'documentLibrary', 'name': 'Documents', 'webUrl': 'https://contoso.sharepoint.com/sites/MySite/Shared Documents', 'owner': { 'group': { 'displayName': 'MySite Owners', 'id': '...' } }, 'quota': { 'total': 27487790694400, 'used': 1048576, 'remaining': 27487789645824 } }
Usage with drive item methods:
site = m365.get_sharepoint_site_by_name("MySite")
site_id = site["id"]
drive = m365.get_sharepoint_site_drive(site_id=site_id)
drive_id = drive["id"]
items = m365.get_drive_items(drive_id=drive_id)
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_pages
¶
Retrieve a list of SharePoint site pages accessible to the authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site the pages should be retrieved for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary including the list of SharePoint pages for a given site. The actual list is included inside the "value" key of the dictionary. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C61c0f9cb-39d3-4c04-b60c-31576954a2ab%2Ca678aeab-68ac-46a1-bd95-28020c12de26')/pages", 'value': [ { '@odata.type': '#microsoft.graph.sitePage', '@odata.etag': '"{A546CE61-21E6-431D-B2CD-67D1F722BE5F},4"', 'createdDateTime': '2025-01-26T00:03:24Z', 'eTag': '"{A546CE61-21E6-431D-B2CD-67D1F722BE5F},4"', 'id': 'a546ce61-21e6-431d-b2cd-67d1f722be5f', 'lastModifiedDateTime': '2025-01-26T00:03:24Z', 'name': 'Home.aspx', 'webUrl': 'https://ideatedev.sharepoint.com/sites/TG11-Trad.Good11PDReg.Trading795/SitePages/Home.aspx', 'title': 'Home', 'pageLayout': 'home', 'promotionKind': 'page', 'showComments': False, 'showRecommendedPages': False, 'contentType': { 'id': '0x0101009D1CB255DA76424F860D91F20E6C411800813863BBF9FE6A408AE59965D98FE3DA', 'name': 'Site Page' }, 'createdBy': {'user': {'displayName': 'System Account'}}, 'lastModifiedBy': {'user': {'displayName': 'Terrarium Admin', 'email': 'admin@dev.idea-te.eimdemo.com'}}, 'parentReference': {'siteId': '61c0f9cb-39d3-4c04-b60c-31576954a2ab'}, 'publishingState': {'level': 'published', 'versionId': '4.0'}, 'reactions': {} }, ... ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_page
¶
Retrieve a page of a SharePoint site accessible to the authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site the page should be retrieved from. |
required |
page_id
|
str
|
The ID of the page to be retrieved. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A SharePoint site page. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C9b203cbe-27ca-45b2-944a-663cc99e5e8f%2Ca1462b54-26f9-4a24-9660-2bc7859ce9af')/pages/$entity", '@odata.type': '#microsoft.graph.sitePage', '@odata.etag': '"{A546CE61-21E6-431D-B2CD-67D1F722BE5F},4"', 'createdDateTime': '2025-01-26T00:03:24Z', 'eTag': '"{A546CE61-21E6-431D-B2CD-67D1F722BE5F},4"', 'id': 'a546ce61-21e6-431d-b2cd-67d1f722be5f', 'lastModifiedDateTime': '2025-01-26T00:03:24Z', 'name': 'Home.aspx', 'webUrl': 'https://ideatedev.sharepoint.com/sites/TG11-Trad.Good11PDReg.Trading795/SitePages/Home.aspx', 'title': 'Home', 'pageLayout': 'home', 'promotionKind': 'page', 'showComments': False, 'showRecommendedPages': False, 'contentType': { 'id': '0x0101009D1CB255DA76424F860D91F20E6C4118003CD261A156017A45BA0F28B5923AE8F6', 'name': 'Site Page' }, 'createdBy': { 'user': {...} }, 'lastModifiedBy': { 'user': {...} }, 'parentReference': { 'siteId': '9b203cbe-27ca-45b2-944a-663cc99e5e8f' }, 'publishingState': { 'level': 'published', 'versionId': '1.0' }, 'reactions': {} }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_sharepoint_page
¶
Add a new SharePoint site page using Microsoft Graph API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site the page should be created on. |
required |
page_name
|
str
|
The name/title of the new page. |
required |
publish
|
bool
|
If True, the page is immediately published. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Details of the created SharePoint page or an error response. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
publish_sharepoint_page
¶
Publish a page of a SharePoint site.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site the page should be published on. |
required |
page_id
|
str
|
The ID of the page to be published. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True = Success, False = Error. |
get_sharepoint_sections
¶
get_sharepoint_sections(
site_id: str,
page_id: str,
section_type: str = "horizontalSections",
section_id: str | int | None = None,
show_error: bool = True,
) -> dict
Retrieve all sections of a SharePoint site page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the sections. |
required |
section_type
|
str
|
"horizontalSections" (note the plural!) "verticalSection" (note the singular!) |
'horizontalSections'
|
section_id
|
str | int | None
|
The ID of the section. Only relevant for horizontal sections. Simple values like 1,2,3... Should be None for vertical section. |
None
|
show_error
|
bool
|
Whether or not an error should be displayed if the section is not found. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary including the list of SharePoint sections for a given page. The actual list is included inside the "value" key of the dictionary. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C61c0f9cb-39d3-4c04-b60c-31576954a2ab%2Ca678aeab-68ac-46a1-bd95-28020c12de26')/pages('ac7675ee-8891-43b9-b1b2-2d2ced8eb17e')/microsoft.graph.sitePage/canvasLayout/horizontalSections", 'value': [ { 'layout': 'fullWidth', 'id': '1', 'emphasis': 'none' }, { 'layout': 'twoColumns', 'id': '2', 'emphasis': 'none' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_section
¶
get_sharepoint_section(
site_id: str,
page_id: str,
section_type: str = "horizontalSections",
section_id: int | str = 1,
show_error: bool = True,
) -> dict
Retrieve a section of a SharePoint site page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the section. |
required |
section_type
|
str
|
"horizontalSections" (note the plural!) "verticalSection" (note the singular!) |
'horizontalSections'
|
section_id
|
int | str
|
The ID of the section. Only relevant for horizontal sections. Simple values like 1,2,3... |
1
|
show_error
|
bool
|
Whether or not an error should be displayed if the section is not found. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A SharePoint site page section. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C61c0f9cb-39d3-4c04-b60c-31576954a2ab%2Ca678aeab-68ac-46a1-bd95-28020c12de26')/pages('ac7675ee-8891-43b9-b1b2-2d2ced8eb17e')/microsoft.graph.sitePage/canvasLayout/horizontalSections/$entity", 'layout': 'fullWidth', 'id': '1', 'emphasis': 'none' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_sharepoint_section
¶
add_sharepoint_section(
site_id: str,
page_id: str,
section_type: str = "horizontalSections",
section_id: int | str = 1,
columns: str = "oneColumn",
emphasis: str = "none",
republish: bool = True,
) -> dict | None
Create a specific section (horizontal or vertical) on a SharePoint page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the section. |
required |
section_type
|
str
|
"horizontalSections" (note the plural!) "verticalSection" (note the singular!) Defaults to "horizontalSections". |
'horizontalSections'
|
section_id
|
int | str
|
The ID of the section. Only relevant for horizontal sections. Simple values like 1,2,3... Defaults to 1. |
1
|
columns
|
str
|
"fullWidth" "oneColumn" "twoColumns" "threeColumns" |
'oneColumn'
|
emphasis
|
str
|
The emphasis for the section. Possible values: "none" (default) "neutral" "soft" "strong" |
'none'
|
republish
|
bool
|
If True, the page is republished to make the section active. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The horizontal or vertical section. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C61c0f9cb-39d3-4c04-b60c-31576954a2ab%2Ca678aeab-68ac-46a1-bd95-28020c12de26')/pages('ac7675ee-8891-43b9-b1b2-2d2ced8eb17e')/microsoft.graph.sitePage/canvasLayout/horizontalSections/$entity", 'layout': 'fullWidth', 'id': '2', 'emphasis': 'none' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_sharepoint_section
¶
delete_sharepoint_section(
site_id: str,
page_id: str,
section_type: str = "horizontalSections",
section_id: int | str = 1,
) -> dict | None
Delete a specific section (horizontal or vertical) on a SharePoint page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the section. |
required |
section_type
|
str
|
"horizontalSections" (note the plural!) "verticalSection" (note the singular!) |
'horizontalSections'
|
section_id
|
int | str
|
The ID of the section. Only relevant for horizontal sections. Simple values like 1,2,3... Defaults to 1. |
1
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Empty response. |
Example:
{
'_content': b'',
'_content_consumed': True,
'_next': None,
'status_code': 204,
'headers': {
'Cache-Control': 'no-store, no-cache',
'Strict-Transport-Security': 'max-age=31536000',
'request-id': 'bd21c7fa-751c-43ca-b290-12c30f50d7e1',
'client-request-id': 'bd21c7fa-751c-43ca-b290-12c30f50d7e1',
'x-ms-ags-diagnostic': '{"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"004","RoleInstance":"FR2PEPF00000393"}}', 'Date': 'Fri, 14 Feb 2025 20:40:06 GMT'},
'raw':
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_webparts
¶
get_sharepoint_webparts(
site_id: str,
page_id: str,
section_type: str | None = None,
section_id: str | int = 1,
column_id: int | str = 1,
) -> dict | None
Retrieve the configured webparts on a SharePoint site page.
Can retrieve all webparts on the page or the ones in a defined page section (like horizontal section or vertical section).
OpenText WebPart Type IDs
Content Browser: 'cecfdba4-2e82-4538-9436-dbd1c4c01a80' Related Workspaces: 'e24d7154-4554-4db6-a44f-d306b6b3a5d4' Team members of Workspace: '635a2800-8833-410d-b1f1-f209b28ea2ad'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the web part. |
required |
section_type
|
str
|
"horizontalSections" (note the plural!) "verticalSection" (note the singular!) Use None (default) if you want to retrieve all webparts on page. |
None
|
section_id
|
str | int
|
The ID of the section. Only relevant for horizontal sections. Simple values like 1,2,3... Defaults to 1. Not relevant for vertical section or if you want to retrieve all webparts on the page. |
1
|
column_id
|
int | str
|
For horizontalSections the column ID has to be provided. Defaults to 1. |
1
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary including the SharePoint webparts of a given page for a given site. The actual list is included inside the "value" key of the dictionary. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C61c0f9cb-39d3-4c04-b60c-31576954a2ab%2Ca678aeab-68ac-46a1-bd95-28020c12de26')/pages('561c65b4-3418-4698-a4c3-7ca7f04812bb')/microsoft.graph.sitePage/webParts", 'value': [ { '@odata.type': '#microsoft.graph.standardWebPart', 'id': '405b669e-3c09-45fe-822f-ff60ac7fffce', 'webPartType': 'c4bd7b2f-7b6e-4599-8485-16504575f590', 'data': { 'audiences': [], 'dataVersion': '1.5', 'description': 'Prominently display up to 5 pieces of content with links, images, pictures, videos, or photos in a highly visual layout.', 'title': 'Hero', 'properties': { 'heroLayoutThreshold': 640, 'carouselLayoutMaxWidth': 639, 'layoutCategory': 1, 'layout': 5, 'content@odata.type': '#Collection(graph.Json)', 'content': [ { 'id': '20cb6611-c7cc-4ba7-91e1-65a6cb576025', 'type': 'UrlLink', 'color': 4, 'description': '', 'title': '', 'showDescription': False, 'showTitle': True, 'alternateText': '', 'imageDisplayOption': 1, 'isDefaultImage': False, 'showCallToAction': True, 'isDefaultImageLoaded': False, 'isCustomImageLoaded': False, 'showFeatureText': False, 'previewImage': {...} }, { 'id': '83133733-960b-4139-a73f-17ce2ca5f71c', 'type': 'Image', 'color': 4, 'description': '', 'title': '', 'showDescription': False, 'showTitle': True, 'alternateText': '', 'imageDisplayOption': 0, 'isDefaultImage': False, 'showCallToAction': False, 'isDefaultImageLoaded': False, 'isCustomImageLoaded': False, 'showFeatureText': False }, ... ] }, 'serverProcessedContent': { 'htmlStrings': [...], 'searchablePlainTexts': [...], 'links': [...], 'imageSources': [...], 'componentDependencies': [...], 'customMetadata': [...] } } }, { '@odata.type': '#microsoft.graph.standardWebPart', 'id': 'f7bfdec9-09c5-4fb6-bc97-3ba225d35ad4', 'webPartType': '8c88f208-6c77-4bdb-86a0-0c47b4316588', 'data': {...} }, { '@odata.type': '#microsoft.graph.standardWebPart', 'id': 'f2a8650b-5ea0-4ac2-9cde-56e0fd0279b0', 'webPartType': 'eb95c819-ab8f-4689-bd03-0c2d65d47b1f', 'data': {...} }, { '@odata.type': '#microsoft.graph.standardWebPart', 'id': '418ba70b-4cf7-410a-a5fd-ea38386915ac', 'webPartType': 'c70391ea-0b10-4ee9-b2b4-006d3fcad0cd', 'data': {...} }, { '@odata.type': '#microsoft.graph.standardWebPart', 'id': '416a4c58-61fc-4166-aa19-1099fad50545', 'webPartType': 'f92bf067-bc19-489e-a556-7fe95f508720', 'data': {...} } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_sharepoint_webpart
¶
Retrieve a web part of a SharePoint site page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the web part. |
required |
webpart_id
|
str
|
The ID of the SharePoint web part to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The data of the SharePoint web part. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C9b203cbe-27ca-45b2-944a-663cc99e5e8f%2Ca1462b54-26f9-4a24-9660-2bc7859ce9af')/pages('a546ce61-21e6-431d-b2cd-67d1f722be5f')/microsoft.graph.sitePage/webParts/$entity", '@odata.type': '#microsoft.graph.standardWebPart', 'id': '405b669e-3c09-45fe-822f-ff60ac7fffce', 'webPartType': 'c4bd7b2f-7b6e-4599-8485-16504575f590', 'data': { 'audiences': [...], 'dataVersion': '1.5', 'description': 'Prominently display up to 5 pieces of content with links, images, pictures, videos, or photos in a highly visual layout.', 'title': 'Hero', 'properties': { 'heroLayoutThreshold': 640, 'carouselLayoutMaxWidth': 639, 'layoutCategory': 1, 'layout': 5, 'content@odata.type': '#Collection(graph.Json)', 'content': [ { 'id': '20cb6611-c7cc-4ba7-91e1-65a6cb576025', 'type': 'UrlLink', 'color': 4, 'description': '', 'title': '', 'showDescription': False, 'showTitle': True, 'alternateText': '', 'imageDisplayOption': 1, 'isDefaultImage': False, 'showCallToAction': True, 'isDefaultImageLoaded': False, 'isCustomImageLoaded': False, 'showFeatureText': False, 'previewImage': { '@odata.type': '#graph.Json', 'zoomRatio': 1, 'resolvedUrl': '', 'imageUrl': '', 'widthFactor': 0.5, 'minCanvasWidth': 1 } }, {...} ] }, 'serverProcessedContent': {...} } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_sharepoint_webpart
¶
add_sharepoint_webpart(
site_id: str,
page_id: str,
webpart_type_id: str,
create_data: dict,
section_type: str = "horizontalSections",
section_id: int | str = 1,
column_id: int | str = 1,
republish: bool = True,
) -> dict | None
Create a specific web part on a SharePoint page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the web part. |
required |
webpart_type_id
|
str
|
The ID of the web part to create. Content Browser: 'cecfdba4-2e82-4538-9436-dbd1c4c01a80' Related Workspaces: 'e24d7154-4554-4db6-a44f-d306b6b3a5d4' Team members of Workspace: '635a2800-8833-410d-b1f1-f209b28ea2ad' |
required |
create_data
|
dict
|
A dictionary with the webpart data items that will be used to update the "data" structure of the webpart. |
required |
section_type
|
str
|
"horizontalSections" (note the plural!) "verticalSection" (note the singular!) Defaults to "horizontalSections". |
'horizontalSections'
|
section_id
|
str | int
|
The ID of the section. Only relevant for horizontal sections. Simple values like 1,2,3... Defaults to 1. |
1
|
column_id
|
int | str
|
For horizontalSections the column ID has to be provided. Defaults to 1. |
1
|
republish
|
bool
|
If True, the page is republished to make the section active. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created web part or None in case of an error. |
Example: { '@odata.context': "https://graph.microsoft.com/beta/$metadata#sites('ideatedev.sharepoint.com%2C61c0f9cb-39d3-4c04-b60c-31576954a2ab%2Ca678aeab-68ac-46a1-bd95-28020c12de26')/pages('ac7675ee-8891-43b9-b1b2-2d2ced8eb17e')/microsoft.graph.sitePage/canvasLayout/horizontalSections('1')/columns('1')/webparts/$entity", '@odata.type': '#microsoft.graph.standardWebPart', 'id': '3df7fe9a-a1e0-4212-968c-73bd70ca3e31', 'webPartType': 'eb95c819-ab8f-4689-bd03-0c2d65d47b1f', 'data': { 'audiences': [...], 'dataVersion': '1.0', 'title': 'Site activity', 'properties': {'maxItems': 9}, 'serverProcessedContent': { 'htmlStrings': [], 'searchablePlainTexts': [], 'links': [], 'imageSources': [] } } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
update_sharepoint_webpart
¶
update_sharepoint_webpart(
site_id: str,
page_id: str,
webpart_id: str,
update_data: dict,
republish: bool = True,
) -> dict | None
Update the data of a specific web part on a SharePoint page.
Any data elements not provided for the update will remain unchanged!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
page_id
|
str
|
The ID of the SharePoint page containing the web part. |
required |
webpart_id
|
str
|
The ID of the web part to update. |
required |
update_data
|
dict
|
A dictionary with the updated data items that will be used to update the "data" structure of the webpart. |
required |
republish
|
bool
|
If True, the page is republished to make the section active. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated web part. None in case of an error. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
follow_sharepoint_site
¶
follow_sharepoint_site(
site_id: str,
username: str | None = None,
user_id: str | None = None,
) -> dict | None
Let a user follow a particular SharePoint site.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
str
|
The ID of the SharePoint site. |
required |
username
|
str | None
|
The login name of the user. Only relevant if the user ID is not provided. |
None
|
user_id
|
str | None
|
The user ID. If it is not provided it will be derived from the username. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The Graph API response or None in case an error occurred. |
Example: { '@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#sites', 'value': [ { 'id': 'ideateqa.sharepoint.com,c605327f-8531-47da-8c85-9bb63845dda6,34b48533-af41-4743-8b41-185a21f0b80f', 'webUrl': 'https://ideateqa.sharepoint.com/sites/Procurement', 'displayName': 'Procurement', 'sharepointIds': { 'siteId': 'c605327f-8531-47da-8c85-9bb63845dda6', 'siteUrl': 'https://ideateqa.sharepoint.com/sites/Procurement', 'webId': '34b48533-af41-4743-8b41-185a21f0b80f' }, 'siteCollection': { 'hostname': 'ideateqa.sharepoint.com' } } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_types
¶
Get a list of container types in the tenant.
Container types are managed via the beta endpoint. Non-administrator users see only container types they have a permission on. SharePoint Embedded Administrators and Global Administrators see every container type in the tenant.
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of container types, or None if the request fails. |
Example
{ '@odata.context': 'https://graph.microsoft.com/beta/$metadata#storage/fileStorage/containerTypes', 'value': [ { 'id': 'e2756c4d-fa33-4452-9c36-2325686e1082', 'displayName': 'My Container Type', 'owningAppId': 'd288ba5f-9313-4b38-b4a4-d7edcce089b0', 'billingClassification': 'standard', 'createdDateTime': '2024-01-15T10:00:00Z' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_type
¶
Get a specific container type by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The ID of the container type. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The container type data or None if the request fails. |
Example
{ '@odata.context': 'https://graph.microsoft.com/beta/$metadata#storage/fileStorage/containerTypes/$entity', 'id': 'e2756c4d-fa33-4452-9c36-2325686e1082', 'displayName': 'My Container Type', 'owningAppId': 'd288ba5f-9313-4b38-b4a4-d7edcce089b0', 'billingClassification': 'standard', 'createdDateTime': '2024-01-15T10:00:00Z' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_container_type
¶
add_container_type(
name: str,
owning_app_id: str,
billing_classification: Literal[
"trial", "standard", "directToCustomer"
] = "trial",
settings: dict | None = None,
) -> dict | None
Create a new container type.
The calling user must be a non-guest member of the owning tenant. The calling user is automatically assigned as an owner of the new container type. Requires the FileStorageContainerType.Manage.All delegated permission.
Container type settings control platform-level features for all containers of this type. These settings are managed via the beta API endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A user-friendly name for the container type. |
required |
owning_app_id
|
str
|
The application ID of the owning app registration. |
required |
billing_classification
|
Literal['trial', 'standard', 'directToCustomer']
|
The billing classification. Valid values are "trial", "standard", or "directToCustomer". Defaults to "trial". Important: Once a container type is created, its billing model cannot be changed — create a new container type to switch billing models. Billing Model Details:
|
'trial'
|
settings
|
dict | None
|
Optional settings for the container type. Supported keys:
|
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created container type data or None if the request fails. |
Example
{ 'id': 'e2756c4d-fa33-4452-9c36-2325686e1082', 'displayName': 'My Container Type', 'owningAppId': 'd288ba5f-9313-4b38-b4a4-d7edcce089b0', 'billingClassification': 'trial', 'createdDateTime': '2024-01-15T10:00:00Z' }
Example settings to enable search, Copilot, and versioning:
{ 'isSearchEnabled': True, 'isDiscoverabilityEnabled': True, 'isItemVersioningEnabled': True, 'itemMajorVersionLimit': 50, 'agent': { 'isAgentContainerDefault': True } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 | |
update_container_type
¶
update_container_type(
container_type_id: str,
display_name: str | None = None,
settings: dict | None = None,
) -> dict | None
Update an existing container type.
Updating settings on a container type may take up to 24 hours for the new values to be replicated on all consuming tenants. If a consuming tenant applied overrides on container type settings, the new values are not applied and the overrides remain in place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The ID of the container type to update. |
required |
display_name
|
str | None
|
The new display name for the container type. |
None
|
settings
|
dict | None
|
The updated settings for the container type. See
|
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated container type data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_container_type
¶
Delete a trial container type.
Only trial container types can be deleted. Before deleting a container type, all containers of that type must be removed, including from the deleted container collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The ID of the container type to delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
register_container_type
¶
register_container_type(
container_type_id: str,
application_permissions: list | None = None,
delegated_permissions: list | None = None,
) -> dict | None
Register a container type in a consuming tenant.
The owning application defines the permissions for the container type. This step is required before containers of this type can be created or accessed in the consuming tenant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The ID of the container type to register. |
required |
application_permissions
|
list | None
|
A list of application permission strings (e.g. ["full", "readContent"]). |
None
|
delegated_permissions
|
list | None
|
A list of delegated permission strings. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The registration response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_containers
¶
Get a list of file storage containers for a given container type.
The containerTypeId filter parameter is required by the Graph API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The ID of the container type to filter by (required). |
required |
filter_expression
|
str | None
|
Additional OData filter expression to combine with the required containerTypeId filter (e.g. "viewpoint/effectiveRole eq 'principalOwner'"). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of containers, or None if the request fails. |
Example
{ '@odata.context': 'https://graph.microsoft.com/v1.0/storage/fileStorage/containers', '@odata.count': 1, 'value': [ { 'id': 'b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z', 'displayName': 'My File Storage Container', 'containerTypeId': 'e2756c4d-fa33-4452-9c36-2325686e1082', 'createdDateTime': '2021-11-24T15:41:52.347Z' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 | |
get_container
¶
Get a specific file storage container by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the file storage container. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The container data or None if the request fails. |
Example
{ '@odata.type': '#microsoft.graph.fileStorageContainer', 'id': 'b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z', 'displayName': 'My File Storage Container', 'description': 'Description of My Application Storage Container', 'containerTypeId': 'e2756c4d-fa33-4452-9c36-2325686e1082', 'status': 'active', 'createdDateTime': '2021-11-24T15:41:52.347Z' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_container
¶
add_container(
display_name: str,
container_type_id: str,
description: str = "",
settings: dict | None = None,
) -> dict | None
Create a new file storage container.
The container type identified by containerTypeId must be registered in the tenant. For delegated calls, the calling user is set as the owner of the container. Newly created containers have status "inactive" and must be activated within 24 hours or they are automatically deleted.
Note: Platform-level features like Search, Copilot, Discoverability,
and Sharing are controlled at the container type level (see
add_container_type() and update_container_type()). The
container-level settings below only control OCR and versioning
overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str
|
The display name of the container. |
required |
container_type_id
|
str
|
The container type ID for the new container. |
required |
description
|
str
|
A user-visible description of the container. |
''
|
settings
|
dict | None
|
Optional container-level settings. Supported keys:
|
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created container data or None if the request fails. |
Example
{ 'id': 'b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z', 'displayName': 'My Application Storage Container', 'description': 'Description of My Application Storage Container', 'containerTypeId': '91710488-5756-407f-9046-fbe5f0b4de73', 'status': 'inactive', 'createdDateTime': '2021-11-24T15:41:52.347Z', 'settings': { 'isOcrEnabled': True, 'isItemVersioningEnabled': True, 'itemMajorVersionLimit': 50 } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 | |
update_container
¶
update_container(
container_id: str,
display_name: str | None = None,
description: str | None = None,
settings: dict | None = None,
) -> dict | None
Update an existing file storage container.
Note: Platform-level features like Search, Copilot, Discoverability,
and Sharing are controlled at the container type level (see
add_container_type() and update_container_type()). Only
OCR and versioning settings can be changed at the container level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container to update. |
required |
display_name
|
str | None
|
The new display name for the container. |
None
|
description
|
str | None
|
The new description for the container. |
None
|
settings
|
dict | None
|
Updated container-level settings. Supported keys:
|
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated container data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 | |
delete_container
¶
Delete (soft-delete) a file storage container.
The container is moved to the deleted container collection and can be restored within the retention period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container to delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
activate_container
¶
Activate a newly created file storage container.
Containers are created as inactive and require activation within 24 hours. Inactive containers that are not activated are automatically deleted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container to activate. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
restore_container
¶
Restore a soft-deleted file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the deleted container to restore. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The restored container data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
permanently_delete_container
¶
Permanently delete a file storage container.
This action is irreversible. The container and all its contents will be permanently removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container to permanently delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
lock_container
¶
Lock a file storage container.
A locked container is set to read-only. No new content can be added and existing content cannot be modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container to lock. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
unlock_container
¶
Unlock a locked file storage container.
Removes the read-only lock from the container, allowing content modifications again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container to unlock. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_permissions
¶
List permissions on a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of permissions, or None if the request fails. |
Example
{ '@odata.context': '...', 'value': [ { 'id': 'cmVhZGVyX2...', 'roles': ['reader'], 'grantedToV2': { 'user': { 'id': 'user-id', 'displayName': 'John Doe' } } } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_permission
¶
Get a specific permission on a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
permission_id
|
str
|
The ID of the permission. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The permission data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_container_permission
¶
Add a permission to a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
user_id
|
str
|
The M365 user ID to grant access to. |
required |
role
|
str
|
The role to assign. Valid values are "reader", "writer", "manager", or "owner". Defaults to "reader". |
'reader'
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created permission data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
update_container_permission
¶
Update a permission on a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
permission_id
|
str
|
The ID of the permission to update. |
required |
role
|
str
|
The new role. Valid values are "reader", "writer", "manager", or "owner". |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated permission data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_container_permission
¶
Delete a permission from a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
permission_id
|
str
|
The ID of the permission to delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_custom_properties
¶
List custom properties of a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The custom properties dictionary or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_container_custom_property
¶
add_container_custom_property(
container_id: str,
property_name: str,
value: str,
is_searchable: bool = False,
) -> dict | None
Add a custom property to a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
property_name
|
str
|
The name (key) of the custom property. |
required |
value
|
str
|
The value of the custom property. |
required |
is_searchable
|
bool
|
Whether the property should be searchable. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated custom properties or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
update_container_custom_property
¶
update_container_custom_property(
container_id: str,
property_name: str,
value: str,
is_searchable: bool = False,
) -> dict | None
Update a custom property on a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
property_name
|
str
|
The name (key) of the custom property. |
required |
value
|
str
|
The new value of the custom property. |
required |
is_searchable
|
bool
|
Whether the property should be searchable. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated custom properties or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_container_custom_property
¶
Delete a custom property from a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
property_name
|
str
|
The name (key) of the custom property to delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_columns
¶
List column definitions of a file storage container.
Columns define custom structured metadata supported by the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of column definitions, or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_column
¶
Get a specific column definition of a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
column_id
|
str
|
The ID of the column. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The column definition data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_container_column
¶
add_container_column(
container_id: str,
name: str,
column_definition: dict | None = None,
) -> dict | None
Create a column for a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
name
|
str
|
The name of the column. |
required |
column_definition
|
dict | None
|
The column definition body. If not provided, a basic text column is created. The dict should follow the Graph API columnDefinition resource schema (e.g. include "text", "number", "dateTime", "choice", etc.). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created column definition or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
update_container_column
¶
update_container_column(
container_id: str,
column_id: str,
column_definition: dict,
) -> dict | None
Update a column definition of a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
column_id
|
str
|
The ID of the column to update. |
required |
column_definition
|
dict
|
The updated column definition body following the Graph API columnDefinition resource schema. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated column definition or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_container_column
¶
Delete a column definition from a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
column_id
|
str
|
The ID of the column to delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_drive
¶
Get the drive resource of a file storage container.
The drive is the entry point for accessing files (driveItems) stored within the container using the standard OneDrive/SharePoint drive API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The drive resource data or None if the request fails. |
Example
{ 'id': 'b!ISJs1WRro0y0EWgkUYcktDa0mE8zSlFEqFzqRn70Zwp1CEtDEBZgQICPkRbil_5Z', 'driveType': 'documentLibrary', 'name': 'My Application Storage Container', 'webUrl': 'https://contoso.sharepoint.com/contentstorage/...', 'owner': {...}, 'quota': { 'total': 27487790694400, 'used': 0, 'remaining': 27487790694400 } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_container_recycle_bin_items
¶
List recycle bin items in a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of recycle bin items, or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
restore_container_recycle_bin_items
¶
Restore recycle bin items in a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
item_ids
|
list
|
A list of recycle bin item IDs to restore. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The restored items data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_container_recycle_bin_item
¶
Permanently delete a recycle bin item from a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
item_id
|
str
|
The ID of the recycle bin item to permanently delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
update_container_recycle_bin_settings
¶
update_container_recycle_bin_settings(
container_id: str, retention_period_days: int
) -> dict | None
Update recycle bin settings for a file storage container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
retention_period_days
|
int
|
The number of days items are retained in the recycle bin before automatic permanent deletion. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated recycle bin settings or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_drive_items
¶
get_drive_items(
drive_id: str,
folder_path: str = "",
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> dict | None
List items (files and folders) in the root or a specific folder of a drive.
This method works with any drive — SPE container drives, OneDrive,
or SharePoint document library drives. To get the drive ID for an
SPE container, use get_container_drive() first:
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
items = m365.get_drive_items(drive_id=drive_id)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. Obtain this from |
required |
folder_path
|
str
|
A path relative to the drive root (e.g. "Documents/Reports"). If empty, lists items in the drive root. Use forward slashes. |
''
|
select
|
str | None
|
Comma-separated list of fields to select (e.g. "id,name,size,lastModifiedDateTime"). |
None
|
filter_expression
|
str | None
|
OData filter expression (e.g. "file ne null" to list only files). |
None
|
order_by
|
str | None
|
Field(s) to order results by (e.g. "name asc"). |
None
|
limit
|
int | None
|
Maximum number of items to return ($top). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing a list of driveItem resources, or None if the request fails. |
Example
{ '@odata.context': '...', 'value': [ { 'id': '01ABCDEF...', 'name': 'Report.pdf', 'size': 1048576, 'file': {'mimeType': 'application/pdf'}, 'lastModifiedDateTime': '2024-03-15T10:30:00Z', 'createdBy': {'user': {'displayName': 'John Doe'}} }, { 'id': '01GHIJKL...', 'name': 'Archive', 'folder': {'childCount': 5}, 'lastModifiedDateTime': '2024-03-10T08:00:00Z' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 | |
get_drive_item_children
¶
get_drive_item_children(
drive_id: str,
item_id: str,
select: str | None = None,
filter_expression: str | None = None,
order_by: str | None = None,
limit: int | None = None,
) -> dict | None
List children of a specific folder (by item ID) in a drive.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
item_id
|
str
|
The ID of the folder item to list children for. |
required |
select
|
str | None
|
Comma-separated list of fields to select. |
None
|
filter_expression
|
str | None
|
OData filter expression. |
None
|
order_by
|
str | None
|
Field(s) to order results by. |
None
|
limit
|
int | None
|
Maximum number of items to return ($top). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing a list of driveItem resources (children), or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 | |
get_drive_item
¶
get_drive_item(
drive_id: str,
item_id: str | None = None,
item_path: str | None = None,
select: str | None = None,
) -> dict | None
Get metadata for a specific item (file or folder) in a drive.
You can identify the item either by its ID or by its path relative
to the drive root. Exactly one of item_id or item_path must
be provided.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
item_id
|
str | None
|
The ID of the item. Provide either this or |
None
|
item_path
|
str | None
|
The path to the item relative to the drive root
(e.g. "Documents/Report.pdf"). Provide either this or
|
None
|
select
|
str | None
|
Comma-separated list of fields to select. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The driveItem resource data or None if the request fails. |
Example
{ 'id': '01ABCDEF...', 'name': 'Report.pdf', 'size': 1048576, 'file': {'mimeType': 'application/pdf'}, 'lastModifiedDateTime': '2024-03-15T10:30:00Z', 'webUrl': 'https://contoso.sharepoint.com/...', 'parentReference': { 'driveId': '...', 'id': '...', 'path': '/drive/root:' }, 'createdBy': {'user': {'displayName': 'John Doe'}}, 'lastModifiedBy': {'user': {'displayName': 'John Doe'}} }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 | |
add_drive_folder
¶
add_drive_folder(
drive_id: str,
folder_name: str,
parent_item_id: str | None = None,
parent_path: str | None = None,
conflict_behavior: str = "rename",
) -> dict | None
Create a new folder in a drive.
The folder is created either under a specific parent item (by ID) or under a path relative to the drive root. If neither is provided, the folder is created in the drive root.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
folder = m365.add_drive_folder(drive_id=drive_id, folder_name="Reports")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
folder_name
|
str
|
The name of the new folder. |
required |
parent_item_id
|
str | None
|
The ID of the parent folder. If not provided and
|
None
|
parent_path
|
str | None
|
The path of the parent folder relative to the drive root
(e.g. "Documents/Archive"). Used if |
None
|
conflict_behavior
|
str
|
Behavior when a folder with the same name already exists. Valid values: "rename" (default), "replace", "fail". |
'rename'
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created driveItem (folder) data or None if the request fails. |
Example
{ 'id': '01GHIJKL...', 'name': 'Reports', 'folder': {'childCount': 0}, 'createdDateTime': '2024-03-15T10:00:00Z', 'parentReference': { 'driveId': '...', 'id': '...', 'path': '/drive/root:' } }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 | |
upload_drive_item
¶
upload_drive_item(
drive_id: str,
file_path: str,
target_filename: str | None = None,
parent_item_id: str | None = None,
parent_path: str | None = None,
conflict_behavior: str = "replace",
) -> dict | None
Upload a small file (up to 4 MB) to a drive.
For files larger than 4 MB, use upload_drive_item_session() instead.
The file is uploaded to the drive root unless a parent folder is
specified via parent_item_id or parent_path.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
result = m365.upload_drive_item(
drive_id=drive_id,
file_path="/local/path/report.pdf",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
file_path
|
str
|
The local file system path to the file to upload. |
required |
target_filename
|
str | None
|
The filename to use in the drive. If not provided, the local filename is used. |
None
|
parent_item_id
|
str | None
|
The ID of the parent folder. If not provided and
|
None
|
parent_path
|
str | None
|
The path of the parent folder relative to the drive root (e.g. "Documents/Reports"). |
None
|
conflict_behavior
|
str
|
Behavior when a file with the same name already exists. Valid values: "replace" (default), "rename", "fail". |
'replace'
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created/updated driveItem data or None if the request fails. |
Example
{ 'id': '01ABCDEF...', 'name': 'report.pdf', 'size': 1048576, 'file': {'mimeType': 'application/pdf'}, 'createdDateTime': '2024-03-15T10:30:00Z', 'webUrl': 'https://contoso.sharepoint.com/...' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 | |
upload_drive_item_session
¶
upload_drive_item_session(
drive_id: str,
file_path: str,
target_filename: str | None = None,
parent_item_id: str | None = None,
parent_path: str | None = None,
conflict_behavior: str = "replace",
chunk_size: int = 10 * 1024 * 1024,
) -> dict | None
Upload a large file (> 4 MB) to a drive using an upload session.
This method handles the full upload session lifecycle: creates the session, uploads the file in chunks, and returns the completed driveItem. Suitable for files of any size.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
result = m365.upload_drive_item_session(
drive_id=drive_id,
file_path="/local/path/large-video.mp4",
parent_path="Media",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
file_path
|
str
|
The local file system path to the file to upload. |
required |
target_filename
|
str | None
|
The filename to use in the drive. If not provided, the local filename is used. |
None
|
parent_item_id
|
str | None
|
The ID of the parent folder. If not provided and
|
None
|
parent_path
|
str | None
|
The path of the parent folder relative to the drive root. |
None
|
conflict_behavior
|
str
|
Behavior when a file with the same name already exists. Valid values: "replace" (default), "rename", "fail". |
'replace'
|
chunk_size
|
int
|
The size of each upload chunk in bytes. Must be a multiple of 320 KiB. Defaults to 10 MiB. |
10 * 1024 * 1024
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created/updated driveItem data or None if the upload fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 | |
download_drive_item
¶
download_drive_item(
drive_id: str,
target_path: str,
item_id: str | None = None,
item_path: str | None = None,
) -> str | None
Download a file from a drive to the local file system.
You can identify the file either by its item ID or by its path
relative to the drive root. Exactly one of item_id or
item_path must be provided.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
local_file = m365.download_drive_item(
drive_id=drive_id,
item_path="Documents/Report.pdf",
target_path="/tmp/Report.pdf",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
target_path
|
str
|
The local file system path where the file should be saved. |
required |
item_id
|
str | None
|
The ID of the file item. Provide either this or |
None
|
item_path
|
str | None
|
The path to the file relative to the drive root.
Provide either this or |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The local file path where the file was saved, or None if the download fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 | |
update_drive_item
¶
update_drive_item(
drive_id: str,
item_id: str,
name: str | None = None,
description: str | None = None,
parent_reference: dict | None = None,
) -> dict | None
Update metadata of a drive item (file or folder).
This can be used to rename an item, update its description, or
move it to a different parent folder (by providing a new
parent_reference).
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
item_id
|
str
|
The ID of the item to update. |
required |
name
|
str | None
|
The new name for the item (rename). |
None
|
description
|
str | None
|
The new description for the item. |
None
|
parent_reference
|
dict | None
|
A new parent reference to move the item. Must include
"id" (the target folder ID). Example:
|
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated driveItem data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 | |
delete_drive_item
¶
Delete a drive item (file or folder).
Deleted items are moved to the recycle bin (if enabled for the
drive/container). Use get_container_recycle_bin_items() and
restore_container_recycle_bin_items() to manage recycled items
for SPE containers.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
m365.delete_drive_item(drive_id=drive_id, item_id="01ABCDEF...")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
item_id
|
str
|
The ID of the item to delete. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
copy_drive_item
¶
copy_drive_item(
drive_id: str,
item_id: str,
target_parent_id: str,
target_name: str | None = None,
target_drive_id: str | None = None,
) -> dict | None
Copy a drive item (file or folder) to a new location.
The copy operation is asynchronous. The response includes a
Location header with a URL to monitor the copy progress.
This method returns the response from the initial copy request.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the source drive. |
required |
item_id
|
str
|
The ID of the item to copy. |
required |
target_parent_id
|
str
|
The ID of the target parent folder. |
required |
target_name
|
str | None
|
The new name for the copied item. If not provided, the original name is used. |
None
|
target_drive_id
|
str | None
|
The ID of the target drive. If not provided, the item is copied within the same drive. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The response or None if the request fails. For successful copy requests the Graph API returns 202 Accepted. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 | |
move_drive_item
¶
move_drive_item(
drive_id: str,
item_id: str,
target_parent_id: str,
new_name: str | None = None,
target_drive_id: str | None = None,
) -> dict | None
Move a drive item (file or folder) to a new location.
Moving is done by updating the parentReference of the item.
You can optionally rename the item at the same time.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
m365.move_drive_item(
drive_id=drive_id,
item_id="01ABCDEF...",
target_parent_id="01GHIJKL...",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive. |
required |
item_id
|
str
|
The ID of the item to move. |
required |
target_parent_id
|
str
|
The ID of the target parent folder. |
required |
new_name
|
str | None
|
A new name for the item (combine move and rename). |
None
|
target_drive_id
|
str | None
|
The ID of the target drive. If not provided, the item is moved within the same drive. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated driveItem data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 | |
get_drive_item_fields
¶
Get the custom column (field) values of a drive item.
Each drive item in an SPE container has a listItem facet that
stores custom metadata defined by the container's columns. This
method retrieves those field values.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary of field name/value pairs or None if the request fails. |
Example
{ 'Color': 'Fuchsia', 'Quantity': 934, 'Status': 'Active', '@odata.etag': '"abc123"' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
add_drive_item_permission
¶
add_drive_item_permission(
drive_id: str,
item_id: str,
recipient_emails: list[str],
role: Literal["read", "write"] = "write",
require_user_token: bool = True,
) -> dict | None
Grant an additive permission on a drive item.
Uses POST /drives/{drive-id}/items/{item-id}/invite with
sendInvitation forced to False as required for SharePoint
Embedded additive permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item (file or folder). |
required |
recipient_emails
|
list[str]
|
Recipient e-mail addresses to grant access to. |
required |
role
|
Literal['read', 'write']
|
The role to grant. Defaults to "write". |
'write'
|
require_user_token
|
bool
|
If True (default), uses delegated user token via
|
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Invite operation response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 | |
get_drive_item_permissions
¶
get_drive_item_permissions(
drive_id: str,
item_id: str,
require_user_token: bool = True,
) -> dict | None
List permissions on a drive item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item. |
required |
require_user_token
|
bool
|
If True (default), uses delegated user token via
|
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Permission collection response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_drive_item_permission
¶
get_drive_item_permission(
drive_id: str,
item_id: str,
permission_id: str,
require_user_token: bool = True,
) -> dict | None
Get a specific permission on a drive item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item. |
required |
permission_id
|
str
|
The ID of the permission. |
required |
require_user_token
|
bool
|
If True (default), uses delegated user token via
|
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Permission response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
delete_drive_item_permission
¶
delete_drive_item_permission(
drive_id: str,
item_id: str,
permission_id: str,
require_user_token: bool = True,
) -> dict | None
Delete an additive permission from a drive item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item. |
required |
permission_id
|
str
|
The ID of the permission to delete. |
required |
require_user_token
|
bool
|
If True (default), uses delegated user token via
|
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Delete response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
update_drive_item_fields
¶
Update the custom column (field) values of a drive item.
Use this method to set or update custom metadata on a file or
folder within an SPE container. The field names must correspond
to columns defined on the container (see add_container_column()).
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item. |
required |
fields
|
dict
|
A dictionary of field name/value pairs to set. Keys must match column names defined on the container. To clear a field, set its value to None. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated field values or None if the request fails. |
Example
::
m365.update_drive_item_fields(
drive_id="b!abc123",
item_id="01ABCDEF",
fields={
"Status": "Approved",
"ReviewDate": "2025-06-01",
"Priority": 1,
},
)
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 | |
search_drive_items
¶
Search for drive items within a drive.
Searches the full text of items (file names, content, and metadata) in the specified drive. The search uses the Microsoft Search index and results may be slightly delayed for newly uploaded content.
To get the drive ID for an SPE container, use get_container_drive():
response = m365.get_container_drive(container_id="...")
drive_id = response["id"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive to search. |
required |
query
|
str
|
The search query string. Supports KQL (Keyword Query Language) syntax for advanced queries. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Search results containing matching drive items or None if the request fails. |
Example
{ 'value': [ { 'hitsContainers': [ { 'hits': [ { 'hitId': '01ABCDEF', 'resource': { 'id': '01ABCDEF', 'name': 'Report.docx', ... } } ], 'total': 1, 'moreResultsAvailable': False } ] } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 | |
search_containers
¶
search_containers(
container_type_id: str,
title: str | None = None,
description: str | None = None,
custom_property_name: str | None = None,
custom_property_value: str | None = None,
include_hidden_content: bool = True,
) -> dict | None
Search SharePoint Embedded containers with Microsoft Search.
This method uses the Graph Search API endpoint /beta/search/query
and scopes searches to a specific container type via ContainerTypeId.
The Graph Search API for SharePoint Embedded is in preview and supports delegated permissions only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The SPE container type ID to scope the search. |
required |
title
|
str | None
|
Optional container title filter. Mapped to |
None
|
description
|
str | None
|
Optional container description filter. Mapped to
|
None
|
custom_property_name
|
str | None
|
Optional custom property name for search.
Per Microsoft documentation this is queried as
|
None
|
custom_property_value
|
str | None
|
Optional value for |
None
|
include_hidden_content
|
bool
|
Sets |
True
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Graph Search response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 | |
search_container_content
¶
search_container_content(
query_text: str,
container_type_id: str | None = None,
container_id: str | None = None,
include_hidden_content: bool = True,
fields: list[str] | None = None,
sort_properties: list[dict] | None = None,
) -> dict | None
Search content in SharePoint Embedded containers.
This method uses /beta/search/query with entityTypes=['driveItem'].
Scope the query with container_type_id and/or container_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_text
|
str
|
Full-text query string to search in content. |
required |
container_type_id
|
str | None
|
Optional container type scope. Recommended to avoid cross-container-type leakage. |
None
|
container_id
|
str | None
|
Optional single-container scope. |
None
|
include_hidden_content
|
bool
|
Sets |
True
|
fields
|
list[str] | None
|
Optional list of fields to include in the response. |
None
|
sort_properties
|
list[dict] | None
|
Optional Graph search sort properties, e.g.
|
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: Graph Search response or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 | |
update_container_sensitivity_label
¶
Assign or update the sensitivity label on a file storage container.
Sensitivity labels (from Microsoft Purview Information Protection) allow you to classify containers for data governance and compliance. Once assigned, the label's policies (encryption, access restrictions, visual markings) apply to the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
sensitivity_label_id
|
str
|
The GUID of the sensitivity label to assign. Use Microsoft Purview or the Graph Security API to retrieve available label IDs. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The updated container data or None if the request fails. |
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
get_deleted_containers
¶
List deleted (soft-deleted) file storage containers.
Returns containers that have been deleted but not yet permanently
removed. Deleted containers are retained for a limited period and
can be restored using restore_container().
This is an admin-level method that requires
FileStorageContainer.Selected or
FileStorageContainer.Manage.All permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_type_id
|
str
|
The GUID of the container type to filter by. Required by the Graph API — you can only list deleted containers for a specific container type. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A collection of deleted container objects or None if the request fails. |
Example
{ 'value': [ { 'id': 'b!ISJs1WRro0y0...', 'displayName': 'My Container', 'createdDateTime': '2021-11-24T15:41:52.347Z' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
upsert_container_permissions
¶
upsert_container_permissions(
container_id: str,
permissions: list[dict],
conflict_behavior: str = "fail",
) -> dict | None
Upsert (create or update) multiple permissions on a container in one request.
This delta-patch operation allows you to create new permissions and update existing ones in a single API call (up to 40 permissions).
- To create a permission: omit
id, providerolesandgrantedToV2. - To update a permission: include the existing
idand newroles. Do not includegrantedToV2for updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the container. |
required |
permissions
|
list[dict]
|
A list of permission objects (up to 40). Each dict should contain:
|
required |
conflict_behavior
|
str
|
Controls behavior when a create target already has a
different role. |
'fail'
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A collection of processed permission results (including per-item errors for failed entries) or None if the entire request fails. |
Example
::
m365.upsert_container_permissions(
container_id="b!abc123",
permissions=[
{
"roles": ["reader"],
"grantedToV2": {
"user": {"userPrincipalName": "alex@contoso.com"}
},
},
{
"id": "existing-permission-id",
"roles": ["manager"],
},
],
conflict_behavior="replace",
)
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 | |
provision_migration_containers
¶
Provision temporary Azure blob containers for content migration.
This provisions SharePoint-managed Azure blob containers that serve as temporary staging storage for migration content and metadata. The returned URIs (with SAS tokens) can be used to upload content and metadata packages before triggering a migration job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the target SPE container that will receive the migrated content. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The provisioned migration container info or None if the request fails. |
Example
{ 'dataContainerUri': 'https://spoxxx.blob.core.windows.net/data?sp=rw&sig=...', 'metadataContainerUri': 'https://spoxxx.blob.core.windows.net/metadata?sp=rw&sig=...', 'encryptionKey': 'AES-256-CBC encryption key' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
create_container_migration_job
¶
create_container_migration_job(
container_id: str,
data_container_uri: str,
metadata_container_uri: str,
encryption_key: str,
) -> dict | None
Create a migration job to import content into an SPE container.
Schedules a migration job that imports content from temporary Azure
blob storage (previously provisioned via
provision_migration_containers()) into the target container.
The migration process
- Call
provision_migration_containers()to get staging URIs. - Upload content packages to
dataContainerUriand metadata tometadataContainerUriusing the Azure Blob API. - Call this method to trigger the actual migration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_id
|
str
|
The ID of the target SPE container. |
required |
data_container_uri
|
str
|
The Azure blob container URI (with SAS token) where the migration content data is staged. |
required |
metadata_container_uri
|
str
|
The Azure blob container URI (with SAS token) where the migration metadata is staged. |
required |
encryption_key
|
str
|
The base64-encoded AES-256-CBC encryption key used to encrypt the migration packages. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The created migration job object (containing the job ID) or None if the request fails. |
Example
{ 'id': '31090ce2-3b99-fa40-7ec5-46ebeeb5900b' }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 | |
get_drive_item_activities
¶
Get the activity history (audit trail) of a single drive item.
Returns the recent actions performed on a drive item (file or
folder) such as create, edit, delete, rename, move, comment and
access. This works with any drive, including SPE container drives.
To get the drive ID for an SPE container, use get_container_drive().
Note: This uses the Microsoft Graph beta drive activities endpoint
and provides per-item, short-retention activity. For a complete,
compliance-grade record of every access event across all users and
containers, use get_audit_events() (Office 365 unified audit
log) instead. Requires the Sites.Read.All application permission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_id
|
str
|
The ID of the drive containing the item. |
required |
item_id
|
str
|
The ID of the drive item. |
required |
limit
|
int | None
|
Maximum number of activity entries to return ($top). |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of item activities, or None if the request fails. |
Example
{ 'value': [ { 'id': 'ZjU4MjA2...', 'action': {'edit': {}}, 'actor': { 'user': { 'displayName': 'John Doe', 'email': 'jdoe@contoso.com' } }, 'times': { 'recordedDateTime': '2024-03-15T10:30:00Z' } } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 | |
get_audit_events
¶
get_audit_events(
content_type: str = "Audit.SharePoint",
start_time: str | None = None,
end_time: str | None = None,
access_token: str | None = None,
) -> dict | None
Get tenant-wide audit events from the Office 365 unified audit log.
This is the authoritative "who accessed which file in which way" record. SharePoint Embedded containers emit standard SharePoint file-operation events (FileAccessed, FileModified, FileDeleted, FileMoved, FileRenamed, ...) into the unified audit log, queryable via the Office 365 Management Activity API.
This API runs on a separate host (manage.office.com) and requires
its own ActivityFeed.Read application permission and an access token
whose scope is the Management Activity API resource. Pass that token
via access_token; the default Graph token does not work here.
A subscription for the given content type must already exist
(created once via the subscriptions/start endpoint).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_type
|
str
|
The audit content type to query. For SPE/SharePoint use "Audit.SharePoint". Other values: "Audit.General", "Audit.AzureActiveDirectory", "Audit.Exchange", "DLP.All". Defaults to "Audit.SharePoint". |
'Audit.SharePoint'
|
start_time
|
str | None
|
ISO8601 start of the time window (e.g. "2026-06-28T00:00:00"). Window cannot exceed 24 hours. Defaults to None. |
None
|
end_time
|
str | None
|
ISO8601 end of the time window. Defaults to None. |
None
|
access_token
|
str | None
|
A bearer token scoped to the Management Activity API. If not provided the standard Graph token is used (which will fail for this host) — provide a dedicated token. |
None
|
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: A dictionary with a "value" key containing the list of available content blobs, or None if the request fails. Each blob URI must be fetched separately to read the actual events. |
Example
{ 'value': [ { 'contentType': 'Audit.SharePoint', 'contentId': '20260629...', 'contentUri': 'https://manage.office.com/api/v1.0/.../content/20260629...', 'contentCreated': '2026-06-29T10:00:00Z', 'contentExpiration': '2026-07-06T10:00:00Z' } ] }
Source code in packages/pyxecm/src/pyxecm_customizer/m365.py
10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 | |