Office365-rest-python-client

Latest version: v2.5.14

Safety actively analyzes 688559 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 9

2.4.1

Changelog

- 672: Error handling for when response is not present by akrymskiy
- 667: add ability to pass b64 formatted string when adding attachments by padamscrestonecapital
- 666: fix for resetting `ClientResult` (return type) between calls when passing to `execute_query` method by vgrem
- 656: upload session query method compatible with memoryfs python library by brunoabreu0
- 655: fix for OneDrive example by GitSumito

2.4.0

Changelog

- 641: add bcc and cc support for users.send_mail by caleb-depotanalytics
- 649: added examples and authentication clarification by rebeccajhampton
- SharePoint API search namespace enhancements


SharePoint API search namespace enhancements

For methods from SharePoint API `search` namespace those return type contains value pf `SimpleDataTable` type, cell values getting addressed like this:

python
for row in results.Table.Rows:
print(row.Cells["Path"]) prints cell value for `Path` property



Here is an complete example

python
ctx = ClientContext(site_url).with_credentials(user_credentials)
result = ctx.search.query("contentclass:STS_Site").execute_query()
results = result.value.PrimaryQueryResult.RelevantResults
for row in results.Table.Rows:
print(row.Cells["Path"]) prints site url

2.3.16

Changelog

- OneDrive enhancements in terms of [Excel support](https://learn.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0)


[Create a new table](https://learn.microsoft.com/en-us/graph/api/tablecollection-add?view=graph-rest-1.0&tabs=http) example


python

from office365.graph_client import GraphClient
from office365.onedrive.workbooks.tables.rows.row import WorkbookTableRow

file_name = "Financial Sample.xlsx"
client = GraphClient(acquire_token)
workbook = client.me.drive.root.get_by_path(file_name).workbook
table = workbook.tables.add("A1:C10", True).execute_query()



[List rows](https://learn.microsoft.com/en-us/graph/api/table-list-rows?view=graph-rest-1.0&tabs=http) example


python
from office365.graph_client import GraphClient
from office365.onedrive.workbooks.tables.rows.row import WorkbookTableRow

file_name = "Financial Sample.xlsx"
client = GraphClient(acquire_token)
workbook = client.me.drive.root.get_by_path(file_name).workbook
table = workbook.worksheets["Sheet1"].tables["financials"].get().execute_query()
print(table.name)

read table content
rows = table.rows.get().execute_query()
for r in rows: type: WorkbookTableRow
print(r.values)

2.3.15

Changelog


- 569: fix for `ClientRuntimeContext.execute_query_retry` method by jneuendorf
- 584: escape password in _acquire_service_token_from_adfs-method by chrisdecker1201
- 568: support for passing private_key into `with_client_certificate` method
- enhancements for SharePoint & OneDrive APIs


Enhancements for SharePoint & OneDrive APIs

Instantiate SharePoint client with certificate credentials

python
cert_path = 'selfsigncert.pem'
with open(cert_path, 'r') as f:
private_key = open(cert_path).read()

cert_credentials = {
'tenant': test_tenant,
'client_id': '--client id--',
'thumbprint': '--thumbprint--',
'private_key': private_key
}
ctx = ClientContext(test_team_site_url).with_client_certificate(**cert_credentials)


Setting image field value
python
field_value = ImageFieldValue(image_url)
list_item.set_property(field_name, field_value).update().execute_query()

2.3.14

Changelog

Paged data retrieval enhancements, namely:

1) introduction of `ClientObjectCollection.get_all` method to retrieve all the items in a collection, regardless of the size, for example:

python

def print_progress(items):
"""
:type items: office365.sharepoint.listitems.collection.ListItemCollection
"""
print("Items read: {0}".format(len(items)))

page_size = 500
ctx = ClientContext(site_url).with_credentials(client_credentials)
large_list = ctx.web.lists.get_by_title(list_title)

all_items = target_list.items.get_all(page_size, print_progress).execute_query()




2) retrieving paged data via `ClientObjectCollection.paged` method


python
page_size = 500

ctx = ClientContext(site_url).with_credentials(client_credentials)
large_list = ctx.web.lists.get_by_title(list_title)
paged_items = large_list.items.paged(page_size, page_loaded=print_progress).get().execute_query()
for index, item in enumerate(paged_items): type: int, ListItem
print("{0}: {1}".format(index, item.id))


Bug fixes:

- 541: client certificate auth fails when non root site is provided
- 529: Python 2.7 compatibility fixes
- 527: fix for `Folder.copy_to_using_path` method

2.3.13

Changelog

Bug fixes:

- 524: determine and construct the list of properties (including navigation) to be retrieved of `QueryOptions.build` method, kudos to jjloneman
- 505: improved file addressing in SharePoint API by fan-e-cae
- better support for `Sharing` namespace in SharePoint API
- introduced support for [`Site Designs and Site Scripts`](https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-overview) in SharePoint API

Example: Share an anonymous access link with view permissions to a file

python
ctx = ClientContext(site_url).with_credentials(credentials)
file = ctx.web.get_file_by_server_relative_url(file_url)
result = target_file.share_link(SharingLinkKind.AnonymousView).execute_query()


Example: create a new site script that apply a custom theme

python
ctx = ClientContext(site_url).with_credentials(credentials)
site_script = {
"$schema": "schema.json",
"actions": [
{
"verb": "applyTheme",
"themeName": "Contoso Theme"
}
],
"bindata": {},
"version": 1
}

result = SiteScriptUtility.create_site_script(ctx, "Contoso theme script", "", site_script).execute_query()

Page 4 of 9

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.