Office365-REST-Python-Client 2.5.1__py3-none-any.whl → 2.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/METADATA +6 -6
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/RECORD +265 -259
- office365/base_item.py +12 -20
- office365/communications/onlinemeetings/collection.py +1 -1
- office365/communications/onlinemeetings/online_meeting.py +20 -35
- office365/communications/presences/presence.py +18 -7
- office365/delta_collection.py +10 -1
- office365/delta_path.py +1 -1
- office365/directory/administrative_unit.py +6 -7
- office365/directory/applications/application.py +24 -18
- office365/directory/applications/roles/assignment.py +13 -1
- office365/directory/applications/roles/collection.py +13 -0
- office365/directory/applications/roles/role.py +6 -1
- office365/directory/audit/directory.py +8 -7
- office365/directory/audit/log_root.py +3 -0
- office365/directory/audit/signins/signin.py +19 -29
- office365/directory/authentication/authentication.py +1 -0
- office365/directory/authentication/methods/details.py +8 -6
- office365/directory/authentication/methods/phone.py +3 -1
- office365/directory/extensions/extension_property.py +7 -9
- office365/directory/groups/collection.py +10 -3
- office365/directory/groups/group.py +19 -19
- office365/directory/groups/lifecycle_policy.py +8 -7
- office365/directory/identities/provider.py +5 -6
- office365/directory/insights/usage_details.py +8 -3
- office365/directory/internal/paths/me.py +1 -1
- office365/directory/invitations/collection.py +1 -1
- office365/directory/invitations/invitation.py +6 -6
- office365/directory/object_collection.py +2 -3
- office365/directory/permissions/email_identity.py +7 -0
- office365/directory/permissions/grants/resource_specific.py +10 -9
- office365/directory/permissions/identity.py +3 -0
- office365/directory/permissions/identity_set.py +3 -0
- office365/directory/policies/base.py +4 -4
- office365/directory/policies/root.py +6 -4
- office365/directory/protection/information.py +3 -3
- office365/directory/rolemanagement/application.py +2 -0
- office365/directory/rolemanagement/role.py +11 -10
- office365/directory/rolemanagement/template.py +9 -8
- office365/directory/rolemanagement/unified_role_assignment.py +5 -4
- office365/directory/rolemanagement/unified_role_definition.py +6 -4
- office365/directory/security/security.py +3 -0
- office365/directory/serviceprincipals/collection.py +20 -4
- office365/directory/serviceprincipals/service_principal.py +79 -12
- office365/directory/users/activities/activity.py +5 -4
- office365/directory/users/user.py +29 -34
- office365/entity.py +2 -2
- office365/entity_collection.py +12 -5
- office365/graph_client.py +90 -8
- office365/intune/audit/event.py +4 -3
- office365/intune/devices/enrollment/configuration.py +6 -4
- office365/intune/devices/managed.py +9 -12
- office365/onedrive/analytics/item_activity_stat.py +4 -3
- office365/onedrive/columns/column_link.py +4 -4
- office365/onedrive/columns/definition.py +29 -32
- office365/onedrive/columns/definition_collection.py +1 -1
- office365/onedrive/contenttypes/content_type.py +16 -18
- office365/onedrive/documentsets/version.py +7 -3
- office365/onedrive/driveitems/driveItem.py +48 -49
- office365/onedrive/drives/drive.py +7 -2
- office365/onedrive/internal/paths/children.py +2 -2
- office365/onedrive/internal/paths/root.py +1 -1
- office365/onedrive/internal/paths/shared.py +1 -1
- office365/onedrive/internal/paths/site.py +3 -3
- office365/onedrive/internal/paths/url.py +2 -2
- office365/onedrive/listitems/list_item.py +2 -0
- office365/onedrive/lists/list.py +7 -4
- office365/onedrive/permissions/collection.py +28 -7
- office365/onedrive/permissions/permission.py +5 -7
- office365/onedrive/permissions/sharing_link.py +1 -1
- office365/onedrive/sharepoint.py +1 -0
- office365/onedrive/shares/collection.py +2 -5
- office365/onedrive/shares/drive_item.py +4 -0
- office365/onedrive/sites/site.py +6 -0
- office365/onedrive/termstore/groups/collection.py +3 -8
- office365/onedrive/termstore/groups/group.py +8 -0
- office365/onedrive/termstore/sets/collection.py +2 -6
- office365/onedrive/termstore/sets/name.py +5 -0
- office365/onedrive/termstore/sets/set.py +7 -0
- office365/onedrive/termstore/store.py +10 -13
- office365/onedrive/versions/drive_item.py +3 -1
- office365/onedrive/workbooks/ranges/range.py +9 -13
- office365/onedrive/workbooks/ranges/view.py +1 -0
- office365/onedrive/workbooks/tables/rows/row.py +3 -0
- office365/onedrive/workbooks/tables/table.py +7 -4
- office365/onedrive/workbooks/worksheets/worksheet.py +12 -4
- office365/onenote/entity_hierarchy_model.py +4 -0
- office365/onenote/internal/multipart_page_query.py +4 -5
- office365/onenote/notebooks/notebook.py +4 -0
- office365/onenote/pages/collection.py +3 -2
- office365/onenote/resources/resource.py +5 -4
- office365/onenote/sectiongroups/section_group.py +10 -7
- office365/onenote/sections/section.py +1 -1
- office365/outlook/calendar/attendees/base.py +2 -1
- office365/outlook/calendar/calendar.py +18 -10
- office365/outlook/calendar/events/collection.py +0 -2
- office365/outlook/calendar/group.py +7 -8
- office365/outlook/calendar/meetingtimes/suggestion.py +8 -4
- office365/outlook/calendar/meetingtimes/time_slot.py +3 -0
- office365/outlook/calendar/permissions/collection.py +1 -1
- office365/outlook/calendar/rooms/__init__.py +0 -0
- office365/outlook/calendar/rooms/list.py +27 -0
- office365/outlook/calendar/rooms/room.py +8 -0
- office365/outlook/calendar/schedule/information.py +0 -1
- office365/outlook/contacts/collection.py +0 -8
- office365/outlook/contacts/contact.py +14 -14
- office365/outlook/contacts/folder.py +3 -0
- office365/outlook/mail/attachments/attachment.py +31 -31
- office365/outlook/mail/attachments/collection.py +34 -6
- office365/outlook/mail/conversation.py +6 -4
- office365/outlook/mail/folders/collection.py +0 -7
- office365/outlook/mail/folders/folder.py +50 -18
- office365/outlook/mail/messages/collection.py +0 -1
- office365/outlook/mail/messages/message.py +58 -68
- office365/outlook/mail/physical_address.py +11 -5
- office365/outlook/mail/recipient.py +3 -1
- office365/outlook/mail/recurrence_range.py +14 -6
- office365/outlook/user.py +1 -0
- office365/planner/planner.py +9 -12
- office365/planner/plans/collection.py +17 -18
- office365/planner/plans/container.py +11 -0
- office365/planner/plans/plan.py +21 -10
- office365/runtime/auth/authentication_context.py +3 -3
- office365/runtime/auth/providers/acs_token_provider.py +7 -9
- office365/runtime/auth/providers/saml_token_provider.py +5 -2
- office365/runtime/client_object.py +6 -15
- office365/runtime/client_object_collection.py +36 -35
- office365/runtime/client_result.py +6 -7
- office365/runtime/client_runtime_context.py +10 -16
- office365/runtime/client_value_collection.py +3 -10
- office365/runtime/compat.py +2 -0
- office365/runtime/odata/query_options.py +1 -3
- office365/runtime/odata/reader.py +1 -1
- office365/runtime/odata/request.py +2 -4
- office365/runtime/odata/type.py +17 -0
- office365/runtime/odata/v4/upload_session_request.py +27 -30
- office365/runtime/paths/appid.py +1 -1
- office365/runtime/{odata/url_builder.py → paths/builder.py} +24 -9
- office365/runtime/paths/item.py +3 -1
- office365/runtime/paths/resource_path.py +12 -16
- office365/runtime/paths/service_operation.py +8 -7
- office365/runtime/paths/v3/__init__.py +0 -0
- office365/runtime/paths/{key.py → v3/entity.py} +5 -5
- office365/runtime/paths/v4/__init__.py +0 -0
- office365/runtime/paths/{entity.py → v4/entity.py} +13 -11
- office365/runtime/queries/function.py +1 -1
- office365/runtime/types/event_handler.py +1 -3
- office365/search/entity.py +15 -8
- office365/search/external/external.py +1 -0
- office365/search/sort_property.py +3 -0
- office365/sharepoint/attachments/attachment.py +3 -1
- office365/sharepoint/attachments/collection.py +3 -0
- office365/sharepoint/changes/change.py +12 -1
- office365/sharepoint/changes/collection.py +1 -1
- office365/sharepoint/changes/list.py +3 -0
- office365/sharepoint/changes/token.py +4 -0
- office365/sharepoint/changes/type.py +23 -23
- office365/sharepoint/changes/web.py +7 -3
- office365/sharepoint/client_context.py +21 -18
- office365/sharepoint/clientsidecomponent/hostedapps/manager.py +3 -3
- office365/sharepoint/contenttypes/content_type.py +47 -56
- office365/sharepoint/contenttypes/content_type_id.py +1 -1
- office365/sharepoint/documentmanagement/document_id.py +2 -2
- office365/sharepoint/documentmanagement/document_set.py +6 -7
- office365/sharepoint/entity_collection.py +9 -0
- office365/sharepoint/features/feature.py +6 -8
- office365/sharepoint/fields/collection.py +6 -5
- office365/sharepoint/fields/field.py +28 -46
- office365/sharepoint/fields/related_field_collection.py +1 -1
- office365/sharepoint/fields/user_value.py +3 -3
- office365/sharepoint/files/checked_out_file.py +4 -2
- office365/sharepoint/files/checked_out_file_collection.py +1 -1
- office365/sharepoint/files/collection.py +84 -14
- office365/sharepoint/files/file.py +118 -110
- office365/sharepoint/files/versions/collection.py +5 -3
- office365/sharepoint/files/versions/event.py +6 -3
- office365/sharepoint/files/versions/version.py +31 -18
- office365/sharepoint/folders/collection.py +5 -10
- office365/sharepoint/folders/folder.py +41 -24
- office365/sharepoint/forms/collection.py +1 -1
- office365/sharepoint/forms/form.py +4 -4
- office365/sharepoint/internal/paths/static_operation.py +9 -0
- office365/sharepoint/internal/paths/web.py +20 -0
- office365/sharepoint/listitems/collection.py +4 -0
- office365/sharepoint/listitems/listitem.py +37 -38
- office365/sharepoint/listitems/versions/collection.py +1 -1
- office365/sharepoint/listitems/versions/version.py +18 -11
- office365/sharepoint/lists/collection.py +1 -2
- office365/sharepoint/lists/list.py +106 -153
- office365/sharepoint/marketplace/app_metadata_collection.py +3 -1
- office365/sharepoint/navigation/node.py +16 -15
- office365/sharepoint/navigation/node_collection.py +9 -3
- office365/sharepoint/permissions/base_permissions.py +11 -6
- office365/sharepoint/permissions/roles/assignments/collection.py +8 -12
- office365/sharepoint/permissions/roles/definitions/definition.py +3 -1
- office365/sharepoint/permissions/securable_object.py +38 -31
- office365/sharepoint/portal/groups/service.py +12 -16
- office365/sharepoint/portal/groups/site_manager.py +0 -1
- office365/sharepoint/principal/groups/group.py +24 -30
- office365/sharepoint/principal/principal.py +21 -19
- office365/sharepoint/principal/users/collection.py +5 -0
- office365/sharepoint/principal/users/user.py +20 -26
- office365/sharepoint/publishing/pages/collection.py +1 -4
- office365/sharepoint/publishing/pages/metadata.py +38 -51
- office365/sharepoint/publishing/pages/metadata_collection.py +5 -2
- office365/sharepoint/publishing/pages/page.py +12 -21
- office365/sharepoint/publishing/pages/reposts/repost.py +5 -9
- office365/sharepoint/publishing/pages/service.py +36 -49
- office365/sharepoint/pushnotifications/collection.py +3 -1
- office365/sharepoint/recyclebin/item.py +11 -9
- office365/sharepoint/recyclebin/item_collection.py +1 -1
- office365/sharepoint/search/service.py +8 -6
- office365/sharepoint/sharing/links/info.py +5 -2
- office365/sharepoint/sharing/links/share_response.py +3 -0
- office365/sharepoint/sharing/links/share_settings.py +3 -0
- office365/sharepoint/sharing/object_sharing_information.py +25 -19
- office365/sharepoint/sharing/object_sharing_information_user.py +10 -19
- office365/sharepoint/sharing/result.py +18 -41
- office365/sharepoint/sharing/role.py +20 -0
- office365/sharepoint/sharing/role_type.py +1 -0
- office365/sharepoint/sharing/user_sharing_result.py +12 -0
- office365/sharepoint/sites/language.py +6 -0
- office365/sharepoint/sites/language_collection.py +3 -0
- office365/sharepoint/sites/site.py +65 -86
- office365/sharepoint/storagemetrics/storage_metrics.py +5 -6
- office365/sharepoint/taxonomy/item.py +11 -10
- office365/sharepoint/taxonomy/stores/store.py +8 -8
- office365/sharepoint/taxonomy/terms/label.py +3 -0
- office365/sharepoint/taxonomy/terms/term.py +31 -0
- office365/sharepoint/tenant/administration/collaboration/insights_overview.py +10 -0
- office365/sharepoint/tenant/administration/hubsites/collection.py +1 -2
- office365/sharepoint/tenant/administration/hubsites/hub_site.py +20 -24
- office365/sharepoint/tenant/administration/internal/permission_grant.py +7 -0
- office365/sharepoint/tenant/administration/sites/properties.py +55 -44
- office365/sharepoint/tenant/administration/tenant.py +69 -69
- office365/sharepoint/types/resource_path.py +2 -2
- office365/sharepoint/ui/applicationpages/peoplepicker/query_parameters.py +1 -1
- office365/sharepoint/usercustomactions/collection.py +1 -2
- office365/sharepoint/userprofiles/my_site_links.py +4 -4
- office365/sharepoint/userprofiles/people_manager.py +1 -3
- office365/sharepoint/userprofiles/user_profile.py +9 -11
- office365/sharepoint/utilities/principal_info.py +12 -0
- office365/sharepoint/viva/employee_engagement.py +1 -1
- office365/sharepoint/webparts/definition_collection.py +1 -1
- office365/sharepoint/webs/collection.py +8 -0
- office365/sharepoint/webs/template_collection.py +3 -5
- office365/sharepoint/webs/web.py +75 -95
- office365/subscriptions/collection.py +1 -1
- office365/subscriptions/subscription.py +13 -11
- office365/teams/apps/app.py +1 -0
- office365/teams/channels/channel.py +1 -3
- office365/teams/collection.py +12 -16
- office365/teams/info.py +7 -4
- office365/teams/members/conversation_collection.py +1 -3
- office365/teams/operations/async_operation.py +3 -5
- office365/teams/schedule/groups/group.py +3 -0
- office365/teams/team.py +18 -20
- office365/todo/attachments/base.py +7 -9
- office365/todo/linked_resource.py +6 -6
- office365/todo/tasks/list.py +1 -0
- office365/todo/tasks/task.py +3 -0
- office365/onedrive/internal/queries/resumable_file_upload.py +0 -36
- office365/outlook/internal/queries/attachment_upload.py +0 -53
- office365/runtime/odata/path_builder.py +0 -23
- office365/sharepoint/internal/key_value.py +0 -28
- office365/sharepoint/internal/queries/create_file.py +0 -20
- office365/sharepoint/internal/queries/upload_session.py +0 -103
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/LICENSE +0 -0
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/WHEEL +0 -0
- {Office365_REST_Python_Client-2.5.1.dist-info → Office365_REST_Python_Client-2.5.3.dist-info}/top_level.txt +0 -0
- /office365/planner/plans/{plan_details.py → details.py} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import datetime
|
|
2
|
-
from typing import AnyStr
|
|
2
|
+
from typing import TYPE_CHECKING, AnyStr
|
|
3
|
+
|
|
4
|
+
import requests
|
|
3
5
|
|
|
4
6
|
from office365.runtime.client_result import ClientResult
|
|
5
7
|
from office365.runtime.http.http_method import HttpMethod
|
|
@@ -23,12 +25,16 @@ from office365.sharepoint.permissions.irm.file_settings import (
|
|
|
23
25
|
InformationRightsManagementFileSettings,
|
|
24
26
|
)
|
|
25
27
|
from office365.sharepoint.principal.users.user import User
|
|
28
|
+
from office365.sharepoint.sharing.links.share_response import ShareLinkResponse
|
|
26
29
|
from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
|
|
27
30
|
from office365.sharepoint.utilities.upload_status import UploadStatus
|
|
28
31
|
from office365.sharepoint.utilities.wopi_frame_action import SPWOPIFrameAction
|
|
29
32
|
from office365.sharepoint.webparts.limited_manager import LimitedWebPartManager
|
|
30
33
|
from office365.sharepoint.webparts.personalization_scope import PersonalizationScope
|
|
31
34
|
|
|
35
|
+
if TYPE_CHECKING:
|
|
36
|
+
from typing import Optional
|
|
37
|
+
|
|
32
38
|
|
|
33
39
|
class AbstractFile(Entity):
|
|
34
40
|
def read(self):
|
|
@@ -52,11 +58,19 @@ class File(AbstractFile):
|
|
|
52
58
|
"""Represents a file in a SharePoint Web site that can be a Web Part Page, an item in a document library,
|
|
53
59
|
or a file in a folder."""
|
|
54
60
|
|
|
61
|
+
def __repr__(self):
|
|
62
|
+
if self.server_relative_path:
|
|
63
|
+
return repr(self.server_relative_path)
|
|
64
|
+
else:
|
|
65
|
+
return self.serverRelativeUrl or self.unique_id or self.entity_type_name
|
|
66
|
+
|
|
67
|
+
def __str__(self):
|
|
68
|
+
return self.name or self.entity_type_name
|
|
69
|
+
|
|
55
70
|
@staticmethod
|
|
56
71
|
def from_url(abs_url):
|
|
57
72
|
"""
|
|
58
73
|
Retrieves a File from absolute url
|
|
59
|
-
|
|
60
74
|
:type abs_url: str
|
|
61
75
|
"""
|
|
62
76
|
from office365.sharepoint.client_context import ClientContext
|
|
@@ -84,11 +98,12 @@ class File(AbstractFile):
|
|
|
84
98
|
return return_type
|
|
85
99
|
|
|
86
100
|
def create_anonymous_link_with_expiration(self, expiration, is_edit_link=False):
|
|
101
|
+
# type: (datetime.datetime, bool) -> ClientResult[str]
|
|
87
102
|
"""Creates and returns an anonymous link that can be used to access a document without needing to authenticate.
|
|
88
103
|
|
|
89
|
-
:param
|
|
104
|
+
:param is_edit_link: If true, the link will allow the guest user edit privileges on the item.
|
|
90
105
|
string parameters
|
|
91
|
-
:param
|
|
106
|
+
:param expiration: A date/time string for which the format conforms to the ISO 8601:2004(E) complete
|
|
92
107
|
representation for calendar date and time of day, and which represents the time and date of expiry for the
|
|
93
108
|
anonymous link. Both the minutes and hour value MUST be specified for the difference between the local and
|
|
94
109
|
UTC time. Midnight is represented as 00:00:00.
|
|
@@ -151,18 +166,19 @@ class File(AbstractFile):
|
|
|
151
166
|
return return_type
|
|
152
167
|
|
|
153
168
|
def share_link(self, link_kind, expiration=None, role=None, password=None):
|
|
169
|
+
# type: (int, Optional[datetime.datetime], Optional[int], Optional[str]) -> ClientResult[ShareLinkResponse]
|
|
154
170
|
"""Creates a tokenized sharing link for a file based on the specified parameters and optionally
|
|
155
171
|
sends an email to the people that are listed in the specified parameters.
|
|
156
172
|
|
|
157
|
-
:param
|
|
158
|
-
:param
|
|
173
|
+
:param link_kind: The kind of the tokenized sharing link to be created/updated or retrieved.
|
|
174
|
+
:param expiration: A date/time string for which the format conforms to the ISO 8601:2004(E)
|
|
159
175
|
complete representation for calendar date and time of day and which represents the time and date of expiry
|
|
160
176
|
for the tokenized sharing link. Both the minutes and hour value MUST be specified for the difference
|
|
161
177
|
between the local and UTC time. Midnight is represented as 00:00:00. A null value indicates no expiry.
|
|
162
178
|
This value is only applicable to tokenized sharing links that are anonymous access links.
|
|
163
|
-
:param
|
|
179
|
+
:param role: The role to be used for the tokenized sharing link. This is required for Flexible links
|
|
164
180
|
and ignored for all other kinds.
|
|
165
|
-
:param
|
|
181
|
+
:param password: Optional password value to apply to the tokenized sharing link,
|
|
166
182
|
if it can support password protection.
|
|
167
183
|
"""
|
|
168
184
|
return self.listItemAllFields.share_link(link_kind, expiration, role, password)
|
|
@@ -238,21 +254,23 @@ class File(AbstractFile):
|
|
|
238
254
|
self.context.add_query(qry)
|
|
239
255
|
return self
|
|
240
256
|
|
|
241
|
-
def copyto(self, destination, overwrite=False):
|
|
257
|
+
def copyto(self, destination, overwrite=False, file_name=None):
|
|
258
|
+
# type: (Folder|str, bool, str) -> "File"
|
|
242
259
|
"""Copies the file to the destination URL.
|
|
243
260
|
|
|
244
261
|
:param office365.sharepoint.folders.folder.Folder or str destination: Specifies the destination folder or
|
|
245
262
|
folder server relative url where to copy a file.
|
|
246
263
|
:param bool overwrite: Specifies whether a file with the same name is overwritten.
|
|
264
|
+
:param str file_name: A new file name
|
|
247
265
|
"""
|
|
248
266
|
return_type = File(self.context)
|
|
249
267
|
self.parent_collection.add_child(return_type)
|
|
250
268
|
|
|
251
269
|
def _copyto(destination_folder):
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
# type: (Folder) -> None
|
|
271
|
+
file_path = "/".join(
|
|
272
|
+
[str(destination_folder.serverRelativeUrl), file_name or self.name]
|
|
273
|
+
)
|
|
256
274
|
return_type.set_property("ServerRelativeUrl", file_path)
|
|
257
275
|
|
|
258
276
|
params = {"strNewUrl": file_path, "boverwrite": overwrite}
|
|
@@ -263,14 +281,12 @@ class File(AbstractFile):
|
|
|
263
281
|
if isinstance(destination, Folder):
|
|
264
282
|
destination.ensure_property("ServerRelativeUrl", _copyto, destination)
|
|
265
283
|
else:
|
|
266
|
-
self.context.web.ensure_folder_path(destination).
|
|
267
|
-
_copyto
|
|
268
|
-
)
|
|
284
|
+
self.context.web.ensure_folder_path(destination).after_execute(_copyto)
|
|
269
285
|
|
|
270
|
-
self.
|
|
286
|
+
self.ensure_properties(["ServerRelativeUrl", "Name"], _source_file_resolved)
|
|
271
287
|
return return_type
|
|
272
288
|
|
|
273
|
-
def copyto_using_path(self, destination, overwrite=False):
|
|
289
|
+
def copyto_using_path(self, destination, overwrite=False, file_name=None):
|
|
274
290
|
"""
|
|
275
291
|
Copies the file to the destination path. Server MUST overwrite an existing file of the same name
|
|
276
292
|
if overwrite is true.
|
|
@@ -278,17 +294,16 @@ class File(AbstractFile):
|
|
|
278
294
|
:param bool overwrite: Specifies whether a file with the same name is overwritten.
|
|
279
295
|
:param office365.sharepoint.folders.folder.Folder or str destination: Specifies the destination folder or
|
|
280
296
|
folder server relative url where to copy a file.
|
|
297
|
+
:param str file_name: New file name
|
|
281
298
|
"""
|
|
282
299
|
|
|
283
300
|
return_type = File(self.context)
|
|
284
301
|
self.parent_collection.add_child(return_type)
|
|
285
302
|
|
|
286
303
|
def _copyto_using_path(destination_folder):
|
|
287
|
-
|
|
288
|
-
:type destination_folder: Folder
|
|
289
|
-
"""
|
|
304
|
+
# type: (Folder) -> None
|
|
290
305
|
file_path = "/".join(
|
|
291
|
-
[str(destination_folder.server_relative_path), self.name]
|
|
306
|
+
[str(destination_folder.server_relative_path), file_name or self.name]
|
|
292
307
|
)
|
|
293
308
|
return_type.set_property("ServerRelativePath", file_path)
|
|
294
309
|
|
|
@@ -352,16 +367,19 @@ class File(AbstractFile):
|
|
|
352
367
|
"""
|
|
353
368
|
|
|
354
369
|
def _update_file(return_type, new_file_url):
|
|
370
|
+
# type: (File, str) -> None
|
|
355
371
|
return_type.set_property("ServerRelativePath", new_file_url)
|
|
356
372
|
|
|
357
373
|
def _move_to_using_path(destination_folder):
|
|
374
|
+
# type: (Folder) -> None
|
|
358
375
|
file_path = "/".join(
|
|
359
376
|
[str(destination_folder.server_relative_path), self.name]
|
|
360
377
|
)
|
|
361
378
|
params = {"DecodedUrl": file_path, "moveOperations": flag}
|
|
362
379
|
qry = ServiceOperationQuery(self, "MoveToUsingPath", params)
|
|
363
|
-
self.context.add_query(qry)
|
|
364
|
-
|
|
380
|
+
self.context.add_query(qry).after_query_execute(
|
|
381
|
+
_update_file, self, file_path
|
|
382
|
+
)
|
|
365
383
|
|
|
366
384
|
def _source_file_resolved():
|
|
367
385
|
if isinstance(destination, Folder):
|
|
@@ -378,7 +396,6 @@ class File(AbstractFile):
|
|
|
378
396
|
|
|
379
397
|
def publish(self, comment):
|
|
380
398
|
"""Submits the file for content approval with the specified comment.
|
|
381
|
-
|
|
382
399
|
:param str comment: Specifies the comment.
|
|
383
400
|
"""
|
|
384
401
|
qry = ServiceOperationQuery(self, "Publish", {"comment": comment})
|
|
@@ -387,7 +404,6 @@ class File(AbstractFile):
|
|
|
387
404
|
|
|
388
405
|
def unpublish(self, comment):
|
|
389
406
|
"""Removes the file from content approval or unpublishes a major version.
|
|
390
|
-
|
|
391
407
|
:param str comment: Specifies the comment for UnPublish. Its length MUST be equal to or less than 1023.
|
|
392
408
|
"""
|
|
393
409
|
qry = ServiceOperationQuery(self, "unpublish", {"comment": comment})
|
|
@@ -464,7 +480,6 @@ class File(AbstractFile):
|
|
|
464
480
|
|
|
465
481
|
def get_upload_status(self, upload_id):
|
|
466
482
|
"""Gets the status of a chunk upload session.
|
|
467
|
-
|
|
468
483
|
:param str upload_id: The upload session ID.
|
|
469
484
|
"""
|
|
470
485
|
payload = {
|
|
@@ -484,9 +499,9 @@ class File(AbstractFile):
|
|
|
484
499
|
:param bytes stream:
|
|
485
500
|
"""
|
|
486
501
|
return_type = File(self.context)
|
|
487
|
-
|
|
502
|
+
params = {"uploadId": upload_id, "checksum": checksum}
|
|
488
503
|
qry = ServiceOperationQuery(
|
|
489
|
-
self, "UploadWithChecksum",
|
|
504
|
+
self, "UploadWithChecksum", params, stream, None, return_type
|
|
490
505
|
)
|
|
491
506
|
self.context.add_query(qry)
|
|
492
507
|
return return_type
|
|
@@ -555,6 +570,26 @@ class File(AbstractFile):
|
|
|
555
570
|
self.context.add_query(qry)
|
|
556
571
|
return self
|
|
557
572
|
|
|
573
|
+
def finish_upload_with_checksum(self, upload_id, file_offset, checksum, stream):
|
|
574
|
+
"""Uploads the last file fragment and commits the file. The current file content is changed when this method
|
|
575
|
+
completes.
|
|
576
|
+
|
|
577
|
+
:param str upload_id: Upload session id
|
|
578
|
+
:param int file_offset: File offset
|
|
579
|
+
:param str checksum: File checksum
|
|
580
|
+
:param bytes stream: File content
|
|
581
|
+
"""
|
|
582
|
+
payload = {
|
|
583
|
+
"uploadID": upload_id,
|
|
584
|
+
"fileOffset": file_offset,
|
|
585
|
+
"checksum": checksum,
|
|
586
|
+
}
|
|
587
|
+
qry = ServiceOperationQuery(
|
|
588
|
+
self, "FinishUploadWithChecksum", payload, stream, None, self
|
|
589
|
+
)
|
|
590
|
+
self.context.add_query(qry)
|
|
591
|
+
return self
|
|
592
|
+
|
|
558
593
|
@staticmethod
|
|
559
594
|
def save_binary(context, server_relative_url, content):
|
|
560
595
|
"""Uploads a file
|
|
@@ -599,15 +634,13 @@ class File(AbstractFile):
|
|
|
599
634
|
"""
|
|
600
635
|
|
|
601
636
|
def _save_content(return_type):
|
|
602
|
-
|
|
603
|
-
:type return_type: ClientResult
|
|
604
|
-
"""
|
|
637
|
+
# type: (ClientResult[AnyStr]) -> None
|
|
605
638
|
file_object.write(return_type.value)
|
|
606
639
|
if callable(after_downloaded):
|
|
607
640
|
after_downloaded(self)
|
|
608
641
|
|
|
609
642
|
def _download_inner():
|
|
610
|
-
|
|
643
|
+
self.get_content().after_execute(_save_content)
|
|
611
644
|
|
|
612
645
|
self.ensure_property("ServerRelativePath", _download_inner)
|
|
613
646
|
return self
|
|
@@ -627,19 +660,15 @@ class File(AbstractFile):
|
|
|
627
660
|
def _download_as_stream():
|
|
628
661
|
qry = ServiceOperationQuery(self, "$value")
|
|
629
662
|
|
|
630
|
-
def
|
|
631
|
-
|
|
632
|
-
:type request: office365.runtime.http.request_options.RequestOptions
|
|
633
|
-
"""
|
|
663
|
+
def _construct_request(request):
|
|
664
|
+
# type: (RequestOptions) -> None
|
|
634
665
|
request.stream = True
|
|
635
666
|
request.method = HttpMethod.Get
|
|
636
667
|
|
|
637
|
-
self.context.before_execute(
|
|
668
|
+
self.context.before_execute(_construct_request)
|
|
638
669
|
|
|
639
|
-
def
|
|
640
|
-
|
|
641
|
-
:type response: requests.Response
|
|
642
|
-
"""
|
|
670
|
+
def _process_response(response):
|
|
671
|
+
# type: (requests.Response) -> None
|
|
643
672
|
response.raise_for_status()
|
|
644
673
|
bytes_read = 0
|
|
645
674
|
for chunk in response.iter_content(chunk_size=chunk_size):
|
|
@@ -648,7 +677,7 @@ class File(AbstractFile):
|
|
|
648
677
|
chunk_downloaded(bytes_read)
|
|
649
678
|
file_object.write(chunk)
|
|
650
679
|
|
|
651
|
-
self.context.after_execute(
|
|
680
|
+
self.context.after_execute(_process_response)
|
|
652
681
|
self.context.add_query(qry)
|
|
653
682
|
|
|
654
683
|
if use_path:
|
|
@@ -660,7 +689,6 @@ class File(AbstractFile):
|
|
|
660
689
|
def rename(self, new_file_name):
|
|
661
690
|
"""
|
|
662
691
|
Rename a file
|
|
663
|
-
|
|
664
692
|
:param str new_file_name: A new file name
|
|
665
693
|
"""
|
|
666
694
|
item = self.listItemAllFields
|
|
@@ -689,15 +717,20 @@ class File(AbstractFile):
|
|
|
689
717
|
User(self.context, ResourcePath("CheckedOutByUser", self.resource_path)),
|
|
690
718
|
)
|
|
691
719
|
|
|
720
|
+
@property
|
|
721
|
+
def check_out_type(self):
|
|
722
|
+
# type: () -> Optional[int]
|
|
723
|
+
return self.properties.get("CheckOutType", None)
|
|
724
|
+
|
|
692
725
|
@property
|
|
693
726
|
def expiration_date(self):
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
"""
|
|
727
|
+
# type: () -> Optional[datetime.datetime]
|
|
728
|
+
"""Specifies the date and time when the file expires."""
|
|
697
729
|
return self.properties.get("ExpirationDate", datetime.datetime.min)
|
|
698
730
|
|
|
699
731
|
@property
|
|
700
732
|
def version_events(self):
|
|
733
|
+
# type: () -> EntityCollection[FileVersionEvent]
|
|
701
734
|
"""Gets the history of events on this version object."""
|
|
702
735
|
return self.properties.get(
|
|
703
736
|
"VersionEvents",
|
|
@@ -727,9 +760,7 @@ class File(AbstractFile):
|
|
|
727
760
|
|
|
728
761
|
@property
|
|
729
762
|
def information_rights_management_settings(self):
|
|
730
|
-
"""
|
|
731
|
-
Returns the Information Rights Management (IRM) settings for the file.
|
|
732
|
-
"""
|
|
763
|
+
"""Returns the Information Rights Management (IRM) settings for the file."""
|
|
733
764
|
return self.properties.get(
|
|
734
765
|
"InformationRightsManagementSettings",
|
|
735
766
|
InformationRightsManagementFileSettings(
|
|
@@ -762,6 +793,7 @@ class File(AbstractFile):
|
|
|
762
793
|
|
|
763
794
|
@property
|
|
764
795
|
def versions(self):
|
|
796
|
+
# type: () -> FileVersionCollection
|
|
765
797
|
"""Gets a value that returns a collection of file version objects that represent the versions of the file."""
|
|
766
798
|
return self.properties.get(
|
|
767
799
|
"Versions",
|
|
@@ -772,9 +804,7 @@ class File(AbstractFile):
|
|
|
772
804
|
|
|
773
805
|
@property
|
|
774
806
|
def modified_by(self):
|
|
775
|
-
"""
|
|
776
|
-
Gets a value that returns the user who last modified the file.
|
|
777
|
-
"""
|
|
807
|
+
"""Gets a value that returns the user who last modified the file."""
|
|
778
808
|
return self.properties.get(
|
|
779
809
|
"ModifiedBy",
|
|
780
810
|
User(self.context, ResourcePath("ModifiedBy", self.resource_path)),
|
|
@@ -782,9 +812,7 @@ class File(AbstractFile):
|
|
|
782
812
|
|
|
783
813
|
@property
|
|
784
814
|
def locked_by_user(self):
|
|
785
|
-
"""
|
|
786
|
-
Gets a value that returns the user that owns the current lock on the file.
|
|
787
|
-
"""
|
|
815
|
+
"""Gets a value that returns the user that owns the current lock on the file."""
|
|
788
816
|
return self.properties.get(
|
|
789
817
|
"LockedByUser",
|
|
790
818
|
User(self.context, ResourcePath("LockedByUser", self.resource_path)),
|
|
@@ -792,127 +820,107 @@ class File(AbstractFile):
|
|
|
792
820
|
|
|
793
821
|
@property
|
|
794
822
|
def serverRelativeUrl(self):
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
:rtype: str or None
|
|
798
|
-
"""
|
|
823
|
+
# type: () -> Optional[str]
|
|
824
|
+
"""Gets the relative URL of the file based on the URL for the server."""
|
|
799
825
|
return self.properties.get("ServerRelativeUrl", None)
|
|
800
826
|
|
|
801
827
|
@property
|
|
802
828
|
def server_relative_path(self):
|
|
803
|
-
"""Gets the server-relative Path of the list folder.
|
|
804
|
-
|
|
805
|
-
:rtype: SPResPath or None
|
|
806
|
-
"""
|
|
829
|
+
"""Gets the server-relative Path of the list folder."""
|
|
807
830
|
return self.properties.get("ServerRelativePath", SPResPath())
|
|
808
831
|
|
|
809
832
|
@property
|
|
810
833
|
def length(self):
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
"""
|
|
815
|
-
return int(self.properties.get("Length", -1))
|
|
834
|
+
# type: () -> Optional[int]
|
|
835
|
+
"""Gets the file size."""
|
|
836
|
+
return int(self.properties.get("Length", 0))
|
|
816
837
|
|
|
817
838
|
@property
|
|
818
839
|
def exists(self):
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
"""
|
|
840
|
+
# type: () -> Optional[bool]
|
|
841
|
+
"""Specifies whether the file exists."""
|
|
822
842
|
return self.properties.get("Exists", None)
|
|
823
843
|
|
|
824
844
|
@property
|
|
825
845
|
def irm_enabled(self):
|
|
846
|
+
# type: () -> Optional[bool]
|
|
826
847
|
"""Specifies whether or not Information Rights Management (IRM) is enabled at the file level.
|
|
827
848
|
A value of true indicates IRM is enabled; a value of false indicates IRM is disabled.
|
|
828
|
-
:rtype: bool or None
|
|
829
849
|
"""
|
|
830
850
|
return self.properties.get("IrmEnabled", None)
|
|
831
851
|
|
|
832
852
|
@property
|
|
833
853
|
def level(self):
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
"""
|
|
854
|
+
# type: () -> Optional[str]
|
|
855
|
+
"""Specifies the publishing level of the file."""
|
|
837
856
|
return self.properties.get("Level", None)
|
|
838
857
|
|
|
839
858
|
@property
|
|
840
859
|
def linking_uri(self):
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
"""
|
|
860
|
+
# type: () -> Optional[str]
|
|
861
|
+
"""Specifies the URL that is suitable for durable linking to the file."""
|
|
844
862
|
return self.properties.get("LinkingUri", None)
|
|
845
863
|
|
|
846
864
|
@property
|
|
847
865
|
def name(self):
|
|
866
|
+
# type: () -> Optional[str]
|
|
848
867
|
"""Specifies the file name including the extension.
|
|
849
|
-
|
|
850
|
-
:rtype: str or None
|
|
868
|
+
It MUST NOT be NULL. Its length MUST be equal to or less than 260.
|
|
851
869
|
"""
|
|
852
870
|
return self.properties.get("Name", None)
|
|
853
871
|
|
|
854
872
|
@property
|
|
855
873
|
def list_id(self):
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
"""
|
|
874
|
+
# type: () -> Optional[str]
|
|
875
|
+
"""Gets the GUID that identifies the List containing the file."""
|
|
859
876
|
return self.properties.get("ListId", None)
|
|
860
877
|
|
|
861
878
|
@property
|
|
862
879
|
def site_id(self):
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
"""
|
|
880
|
+
# type: () -> Optional[str]
|
|
881
|
+
"""Gets the GUID that identifies the site collection containing the file."""
|
|
866
882
|
return self.properties.get("SiteId", None)
|
|
867
883
|
|
|
868
884
|
@property
|
|
869
885
|
def web_id(self):
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
:rtype: str or None
|
|
873
|
-
"""
|
|
886
|
+
# type: () -> Optional[str]
|
|
887
|
+
"""Gets the GUID for the site containing the file."""
|
|
874
888
|
return self.properties.get("WebId", None)
|
|
875
889
|
|
|
876
890
|
@property
|
|
877
891
|
def time_created(self):
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
"""
|
|
892
|
+
# type: () -> Optional[datetime.datetime]
|
|
893
|
+
"""Gets a value that specifies when the file was created."""
|
|
881
894
|
return self.properties.get("TimeCreated", datetime.datetime.min)
|
|
882
895
|
|
|
883
896
|
@property
|
|
884
897
|
def time_last_modified(self):
|
|
898
|
+
# type: () -> Optional[datetime.datetime]
|
|
885
899
|
"""Specifies when the file was last modified."""
|
|
886
900
|
return self.properties.get("TimeLastModified", datetime.datetime.min)
|
|
887
901
|
|
|
888
902
|
@property
|
|
889
903
|
def minor_version(self):
|
|
890
|
-
|
|
891
|
-
Gets a value that specifies the minor version of the file.
|
|
892
|
-
""
|
|
893
|
-
return int(self.properties.get("MinorVersion", -1))
|
|
904
|
+
# type: () -> Optional[int]
|
|
905
|
+
"""Gets a value that specifies the minor version of the file."""
|
|
906
|
+
return self.properties.get("MinorVersion", None)
|
|
894
907
|
|
|
895
908
|
@property
|
|
896
909
|
def major_version(self):
|
|
897
|
-
|
|
898
|
-
Gets a value that specifies the major version of the file.
|
|
899
|
-
|
|
900
|
-
"""
|
|
901
|
-
return int(self.properties.get("MajorVersion", -1))
|
|
910
|
+
# type: () -> Optional[int]
|
|
911
|
+
"""Gets a value that specifies the major version of the file."""
|
|
912
|
+
return self.properties.get("MajorVersion", None)
|
|
902
913
|
|
|
903
914
|
@property
|
|
904
915
|
def unique_id(self):
|
|
905
|
-
|
|
906
|
-
Gets a value that specifies the a file unique identifier
|
|
907
|
-
:rtype: str or None
|
|
908
|
-
"""
|
|
916
|
+
# type: () -> Optional[str]
|
|
917
|
+
"""Gets a value that specifies the a file unique identifier"""
|
|
909
918
|
return self.properties.get("UniqueId", None)
|
|
910
919
|
|
|
911
920
|
@property
|
|
912
921
|
def customized_page_status(self):
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
"""
|
|
922
|
+
# type: () -> Optional[int]
|
|
923
|
+
"""Specifies the customization status of the file."""
|
|
916
924
|
return self.properties.get("CustomizedPageStatus", None)
|
|
917
925
|
|
|
918
926
|
@property
|
|
@@ -4,7 +4,7 @@ from office365.sharepoint.entity_collection import EntityCollection
|
|
|
4
4
|
from office365.sharepoint.files.versions.version import FileVersion
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class FileVersionCollection(EntityCollection):
|
|
7
|
+
class FileVersionCollection(EntityCollection[FileVersion]):
|
|
8
8
|
"""Represents a collection of FileVersion."""
|
|
9
9
|
|
|
10
10
|
def __init__(self, context, resource_path=None):
|
|
@@ -17,6 +17,10 @@ class FileVersionCollection(EntityCollection):
|
|
|
17
17
|
ServiceOperationPath("getById", [version_id], self.resource_path),
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
+
def get_by_label(self, label):
|
|
21
|
+
"""Gets the file version with the specified Label."""
|
|
22
|
+
return self.single("VersionLabel eq '{0}'".format(label))
|
|
23
|
+
|
|
20
24
|
def delete_all(self):
|
|
21
25
|
"""Deletes all the file version objects in the collection."""
|
|
22
26
|
qry = ServiceOperationQuery(self, "DeleteAll")
|
|
@@ -25,7 +29,6 @@ class FileVersionCollection(EntityCollection):
|
|
|
25
29
|
|
|
26
30
|
def delete_by_id(self, vid):
|
|
27
31
|
"""Removes the file version object with the specified integer ID from the collection.
|
|
28
|
-
|
|
29
32
|
:param int vid: The file version to remove.
|
|
30
33
|
"""
|
|
31
34
|
qry = ServiceOperationQuery(self, "DeleteByID", {"vid": vid})
|
|
@@ -35,7 +38,6 @@ class FileVersionCollection(EntityCollection):
|
|
|
35
38
|
def delete_by_label(self, label):
|
|
36
39
|
"""
|
|
37
40
|
Deletes the file version object with the specified version label.
|
|
38
|
-
|
|
39
41
|
:param str label: The file version to remove.
|
|
40
42
|
"""
|
|
41
43
|
qry = ServiceOperationQuery(self, "DeleteByLabel", {"versionlabel": label})
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
1
3
|
from office365.runtime.client_value_collection import ClientValueCollection
|
|
2
4
|
from office365.sharepoint.entity import Entity
|
|
3
5
|
from office365.sharepoint.sharing.shared_with_user import SharedWithUser
|
|
@@ -8,14 +10,14 @@ class FileVersionEvent(Entity):
|
|
|
8
10
|
|
|
9
11
|
@property
|
|
10
12
|
def event_type(self):
|
|
13
|
+
# type: () -> Optional[str]
|
|
11
14
|
"""Returns the type of the event."""
|
|
12
15
|
return self.properties.get("EventType", None)
|
|
13
16
|
|
|
14
17
|
@property
|
|
15
18
|
def editor(self):
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"""
|
|
19
|
+
# type: () -> Optional[str]
|
|
20
|
+
"""Returns the name of the user who initiated the event."""
|
|
19
21
|
return self.properties.get("Editor", None)
|
|
20
22
|
|
|
21
23
|
@property
|
|
@@ -25,6 +27,7 @@ class FileVersionEvent(Entity):
|
|
|
25
27
|
|
|
26
28
|
@property
|
|
27
29
|
def shared_with_users(self):
|
|
30
|
+
# type: () -> ClientValueCollection[SharedWithUser]
|
|
28
31
|
"""Returns the array of users that have been shared in sharing action for the change log."""
|
|
29
32
|
return self.properties.get(
|
|
30
33
|
"SharedWithUsers", ClientValueCollection(SharedWithUser)
|