diff --git a/examples/sharepoint/lists/clear.py b/examples/sharepoint/lists/clear.py index 26d1a121..044d483b 100644 --- a/examples/sharepoint/lists/clear.py +++ b/examples/sharepoint/lists/clear.py @@ -11,6 +11,6 @@ def print_progress(items_count): ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials) -target_list = ctx.web.lists.get_by_title("Contacts_Large") +target_list = ctx.web.lists.get_by_title("Company Tasks") target_list.clear().get().execute_batch() print("List items count: {0}".format(target_list.item_count)) diff --git a/examples/sharepoint/lists/export_view.py b/examples/sharepoint/lists/export_view.py index 004b5fa4..cb99950a 100644 --- a/examples/sharepoint/lists/export_view.py +++ b/examples/sharepoint/lists/export_view.py @@ -1,3 +1,6 @@ +""" + +""" import json from office365.sharepoint.client_context import ClientContext diff --git a/examples/sharepoint/userprofile/export.py b/examples/sharepoint/userprofile/export.py new file mode 100644 index 00000000..9763cd75 --- /dev/null +++ b/examples/sharepoint/userprofile/export.py @@ -0,0 +1,21 @@ +""" +Exports user profile data. +""" +from office365.sharepoint.client_context import ClientContext +from tests import test_client_credentials, test_site_url + +client = ClientContext(test_site_url).with_credentials(test_client_credentials) +users = ( + client.site.root_web.site_users.filter("IsHiddenInUI eq false") + .get() + .top(10) + .execute_query() +) + +exported_data = {} +for user in users: + exported_data[user.login_name] = client.people_manager.get_properties_for( + user.login_name + ) +client.execute_batch() +print(exported_data) diff --git a/examples/sharepoint/userprofile/get_properties.py b/examples/sharepoint/userprofile/get_properties.py new file mode 100644 index 00000000..e69de29b diff --git a/generator/import_metadata.py b/generator/import_metadata.py index 0bb39167..093a0ba2 100644 --- a/generator/import_metadata.py +++ b/generator/import_metadata.py @@ -26,13 +26,13 @@ def export_to_file(path, content): "--endpoint", dest="endpoint", help="Import metadata endpoint", - default="sharepoint", + default="microsoftgraph", ) parser.add_argument( "-p", "--path", dest="path", - default="./metadata/SharePoint.xml", + default="./metadata/MicrosoftGraph.xml", help="Import metadata endpoint", ) diff --git a/generator/metadata/MicrosoftGraph.xml b/generator/metadata/MicrosoftGraph.xml index 569c19bf..ba247865 100644 --- a/generator/metadata/MicrosoftGraph.xml +++ b/generator/metadata/MicrosoftGraph.xml @@ -4867,6 +4867,11 @@ + + + + + @@ -16248,6 +16253,12 @@ + + + + + + @@ -22887,6 +22898,10 @@ + + + + @@ -22974,6 +22989,7 @@ + diff --git a/office365/sharepoint/activities/action_facet.py b/office365/sharepoint/activities/action_facet.py index 0e7fe5cd..f53df8c8 100644 --- a/office365/sharepoint/activities/action_facet.py +++ b/office365/sharepoint/activities/action_facet.py @@ -9,8 +9,13 @@ from office365.sharepoint.activities.facets.get_comment import GetCommentFacet from office365.sharepoint.activities.facets.get_mention import GetMentionFacet from office365.sharepoint.activities.facets.move import MoveFacet +from office365.sharepoint.activities.facets.point_in_time_restore import ( + PointInTimeRestoreFacet, +) from office365.sharepoint.activities.facets.rename import RenameFacet from office365.sharepoint.activities.facets.sharing import SharingFacet +from office365.sharepoint.activities.facets.task_completed import TaskCompletedFacet +from office365.sharepoint.activities.facets.version import VersionFacet class ActionFacet(ClientValue): @@ -26,8 +31,11 @@ def __init__( edit=EditFacet(), mention=GetMentionFacet(), move=MoveFacet(), + pointInTimeRestore=PointInTimeRestoreFacet(), rename=RenameFacet(), share=SharingFacet(), + taskCompleted=TaskCompletedFacet(), + version=VersionFacet(), ): """ :param AddToOneDriveFacet add_to_one_drive: @@ -48,8 +56,11 @@ def __init__( self.edit = edit self.mention = mention self.move = move + self.pointInTimeRestore = pointInTimeRestore self.rename = rename self.share = share + self.taskCompleted = taskCompleted + self.version = version def __repr__(self): return self.facet_type diff --git a/office365/sharepoint/activities/client_request.py b/office365/sharepoint/activities/client_request.py index 812e2084..5da02376 100644 --- a/office365/sharepoint/activities/client_request.py +++ b/office365/sharepoint/activities/client_request.py @@ -1,7 +1,11 @@ from office365.runtime.client_value import ClientValue +from office365.sharepoint.activities.facets.revision_set import RevisionSetFacet class ActivityClientRequest(ClientValue): + def __init__(self, revisionSet=RevisionSetFacet()): + self.revisionSet = revisionSet + @property def entity_type_name(self): return "Microsoft.SharePoint.Activities.ActivityClientRequest" diff --git a/office365/sharepoint/activities/client_response.py b/office365/sharepoint/activities/client_response.py index 7f6b1bc6..c70b1f02 100644 --- a/office365/sharepoint/activities/client_response.py +++ b/office365/sharepoint/activities/client_response.py @@ -4,6 +4,14 @@ class ActivityClientResponse(ClientValue): """""" + def __init__(self, id_, message=None, serverId=None, status=None): + # type: (str, str, str, int) -> None + """ """ + self.id = id_ + self.message = message + self.serverId = serverId + self.status = status + @property def entity_type_name(self): return "Microsoft.SharePoint.Activities.ActivityClientResponse" diff --git a/office365/sharepoint/activities/facets/delete.py b/office365/sharepoint/activities/facets/delete.py index 4795ffa5..0e64d22b 100644 --- a/office365/sharepoint/activities/facets/delete.py +++ b/office365/sharepoint/activities/facets/delete.py @@ -5,6 +5,7 @@ class DeleteFacet(ClientValue): """""" def __init__(self, name=None): + # type: (str) -> None self.name = name @property diff --git a/office365/sharepoint/activities/facets/in_doc.py b/office365/sharepoint/activities/facets/in_doc.py index 74a868c4..73c4aaa7 100644 --- a/office365/sharepoint/activities/facets/in_doc.py +++ b/office365/sharepoint/activities/facets/in_doc.py @@ -4,6 +4,10 @@ class InDocFacet(ClientValue): """""" + def __init__(self, contentId=None, navigationId=None): + self.contentId = contentId + self.navigationId = navigationId + @property def entity_type_name(self): return "Microsoft.SharePoint.Activities.InDocFacet" diff --git a/office365/sharepoint/activities/facets/point_in_time_restore.py b/office365/sharepoint/activities/facets/point_in_time_restore.py new file mode 100644 index 00000000..ec23457f --- /dev/null +++ b/office365/sharepoint/activities/facets/point_in_time_restore.py @@ -0,0 +1,9 @@ +from office365.runtime.client_value import ClientValue + + +class PointInTimeRestoreFacet(ClientValue): + """""" + + @property + def entity_type_name(self): + return "Microsoft.SharePoint.Activities.PointInTimeRestoreFacet" diff --git a/office365/sharepoint/activities/facets/revision_set.py b/office365/sharepoint/activities/facets/revision_set.py new file mode 100644 index 00000000..d7e4397b --- /dev/null +++ b/office365/sharepoint/activities/facets/revision_set.py @@ -0,0 +1,9 @@ +from office365.runtime.client_value import ClientValue + + +class RevisionSetFacet(ClientValue): + """ """ + + @property + def entity_type_name(self): + return "Microsoft.SharePoint.Activities.RevisionSetFacet" diff --git a/office365/sharepoint/activities/facets/task_completed.py b/office365/sharepoint/activities/facets/task_completed.py new file mode 100644 index 00000000..338c1155 --- /dev/null +++ b/office365/sharepoint/activities/facets/task_completed.py @@ -0,0 +1,9 @@ +from office365.runtime.client_value import ClientValue + + +class TaskCompletedFacet(ClientValue): + """ """ + + @property + def entity_type_name(self): + return "Microsoft.SharePoint.Activities.TaskCompletedFacet" diff --git a/office365/sharepoint/activities/facets/version.py b/office365/sharepoint/activities/facets/version.py new file mode 100644 index 00000000..a9f60c71 --- /dev/null +++ b/office365/sharepoint/activities/facets/version.py @@ -0,0 +1,12 @@ +from office365.runtime.client_value import ClientValue + + +class VersionFacet(ClientValue): + """""" + + def __init__(self, fromVersion=None): + self.fromVersion = fromVersion + + @property + def entity_type_name(self): + return "Microsoft.SharePoint.Activities.VersionFacet" diff --git a/office365/sharepoint/entity.py b/office365/sharepoint/entity.py index a5e5d987..0db1f7db 100644 --- a/office365/sharepoint/entity.py +++ b/office365/sharepoint/entity.py @@ -5,6 +5,7 @@ from office365.runtime.auth.client_credential import ClientCredential from office365.runtime.auth.user_credential import UserCredential from office365.runtime.client_object import ClientObject +from office365.runtime.paths.v3.entity import EntityPath from office365.runtime.queries.delete_entity import DeleteEntityQuery from office365.runtime.queries.update_entity import UpdateEntityQuery @@ -53,3 +54,17 @@ def entity_type_name(self): @property def property_ref_name(self): return "Id" + + def set_property(self, name, value, persist_changes=True): + super(Entity, self).set_property(name, value, persist_changes) + if name == self.property_ref_name: + if self.resource_path is None: + if self.parent_collection: + self._resource_path = EntityPath( + value, self.parent_collection.resource_path + ) + else: + pass + else: + self._resource_path.patch(value) + return self diff --git a/office365/sharepoint/folders/folder.py b/office365/sharepoint/folders/folder.py index 95a92daa..2780c0b2 100644 --- a/office365/sharepoint/folders/folder.py +++ b/office365/sharepoint/folders/folder.py @@ -571,8 +571,8 @@ def server_relative_path(self): @property def property_ref_name(self): - # type: () -> str - return "ServerRelativeUrl" + # type: () -> Optional[str] + return None def get_property(self, name, default_value=None): if default_value is None: diff --git a/office365/sharepoint/sites/version_policy_manager.py b/office365/sharepoint/sites/version_policy_manager.py index c18d64dd..c74f5bed 100644 --- a/office365/sharepoint/sites/version_policy_manager.py +++ b/office365/sharepoint/sites/version_policy_manager.py @@ -1,5 +1,12 @@ +from office365.runtime.queries.service_operation import ServiceOperationQuery from office365.sharepoint.entity import Entity class SiteVersionPolicyManager(Entity): """""" + + def set_auto_expiration(self): + """""" + qry = ServiceOperationQuery(self, "SetAutoExpiration") + self.context.add_query(qry) + return self diff --git a/office365/sharepoint/tenant/management/externalusers/results/get.py b/office365/sharepoint/tenant/management/externalusers/results/get.py index 7b6632aa..891458f9 100644 --- a/office365/sharepoint/tenant/management/externalusers/results/get.py +++ b/office365/sharepoint/tenant/management/externalusers/results/get.py @@ -1,3 +1,5 @@ +from typing import Optional + from office365.runtime.paths.resource_path import ResourcePath from office365.sharepoint.entity import Entity from office365.sharepoint.tenant.management.externalusers.collection import ( @@ -8,10 +10,12 @@ class GetExternalUsersResults(Entity): @property def total_user_count(self): + # type: () -> Optional[int] return self.properties.get("TotalUserCount", None) @property def user_collection_position(self): + # type: () -> Optional[int] return self.properties.get("UserCollectionPosition", None) @property diff --git a/office365/sharepoint/tenant/management/office365_tenant.py b/office365/sharepoint/tenant/management/office365_tenant.py index 84b09765..406de59a 100644 --- a/office365/sharepoint/tenant/management/office365_tenant.py +++ b/office365/sharepoint/tenant/management/office365_tenant.py @@ -1,3 +1,5 @@ +from typing import Optional + from office365.runtime.client_object_collection import ClientObjectCollection from office365.runtime.client_result import ClientResult from office365.runtime.client_value_collection import ClientValueCollection @@ -29,8 +31,19 @@ def __init__(self, context): ) super(Office365Tenant, self).__init__(context, static_path) + @property + def addressbar_link_permission(self): + # type: () -> Optional[int] + return self.properties.get("AddressbarLinkPermission", None) + + @property + def allow_comments_text_on_email_enabled(self): + # type: () -> Optional[bool] + return self.properties.get("AllowCommentsTextOnEmailEnabled", None) + @property def allow_editing(self): + # type: () -> Optional[bool] return self.properties.get("AllowEditing", None) @property @@ -62,6 +75,7 @@ def add_tenant_cdn_origin(self, cdn_type, origin_url): def disable_sharing_for_non_owners_of_site(self, site_url): """ + Disables Sharing For Non Owners :param str site_url: """ payload = {"siteUrl": site_url} diff --git a/office365/sharepoint/userprofiles/people_manager.py b/office365/sharepoint/userprofiles/people_manager.py index 0dd21a7d..af0d7c39 100644 --- a/office365/sharepoint/userprofiles/people_manager.py +++ b/office365/sharepoint/userprofiles/people_manager.py @@ -173,6 +173,7 @@ def get_properties_for(self, user_or_name): return_type = PersonProperties(self.context) def _get_properties_for_inner(account_name): + # type: (str) -> None params = {"accountName": account_name} qry = ServiceOperationQuery( self, "GetPropertiesFor", params, None, None, return_type