Skip to content

Commit

Permalink
SharePoint model updates, improvements for addressing sharepoint reso…
Browse files Browse the repository at this point in the history
…urces
  • Loading branch information
vgrem committed Apr 14, 2024
1 parent a255892 commit de6254c
Show file tree
Hide file tree
Showing 21 changed files with 153 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/sharepoint/lists/clear.py
Expand Up @@ -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))
3 changes: 3 additions & 0 deletions examples/sharepoint/lists/export_view.py
@@ -1,3 +1,6 @@
"""
"""
import json

from office365.sharepoint.client_context import ClientContext
Expand Down
21 changes: 21 additions & 0 deletions 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)
Empty file.
4 changes: 2 additions & 2 deletions generator/import_metadata.py
Expand Up @@ -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",
)

Expand Down
16 changes: 16 additions & 0 deletions generator/metadata/MicrosoftGraph.xml
Expand Up @@ -4867,6 +4867,11 @@
<Annotations Target="microsoft.graph.bookingAppointment/anonymousJoinWebUrl">
<Annotation Term="Org.OData.Core.V1.IsURL" Bool="true"/>
</Annotations>
<Annotations Target="microsoft.graph.bookingAppointment/customerNotes">
<Annotation Term="Org.OData.Core.V1.Description" String="Notes from the customer associated with this appointment."/>
<Annotation Term="Org.OData.Core.V1.Immutable" Bool="true"/>
<Annotation Term="Org.OData.Core.V1.LongDescription" String="The value of this property is only available when reading an individual booking appointment by id. Its value can only be set when creating a new appointment with a new customer, ie, without specifying a CustomerId. After that, the property is computed from the customer represented by CustomerId."/>
</Annotations>
<Annotations Target="microsoft.graph.bookingAppointment/duration">
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
</Annotations>
Expand Down Expand Up @@ -16248,6 +16253,12 @@
<Member Name="outOfOffice" Value="3"/>
<Member Name="unknownFutureValue" Value="4"/>
</EnumType>
<EnumType Name="bookingStaffMembershipStatus">
<Member Name="active" Value="0"/>
<Member Name="pendingAcceptance" Value="1"/>
<Member Name="rejectedByStaff" Value="2"/>
<Member Name="unknownFutureValue" Value="3"/>
</EnumType>
<EnumType Name="bookingStaffRole">
<Member Name="guest" Value="0"/>
<Member Name="administrator" Value="1"/>
Expand Down Expand Up @@ -22887,6 +22898,10 @@
<EntityType Name="bookingAppointment" BaseType="graph.entity">
<Property Name="additionalInformation" Type="Edm.String"/>
<Property Name="anonymousJoinWebUrl" Type="Edm.String"/>
<Property Name="customerEmailAddress" Type="Edm.String"/>
<Property Name="customerName" Type="Edm.String"/>
<Property Name="customerNotes" Type="Edm.String"/>
<Property Name="customerPhone" Type="Edm.String"/>
<Property Name="customers" Type="Collection(graph.bookingCustomerInformationBase)" Nullable="false"/>
<Property Name="customerTimeZone" Type="Edm.String"/>
<Property Name="duration" Type="Edm.Duration" Nullable="false"/>
Expand Down Expand Up @@ -22974,6 +22989,7 @@
<Property Name="displayName" Type="Edm.String" Nullable="false"/>
<Property Name="emailAddress" Type="Edm.String"/>
<Property Name="isEmailNotificationEnabled" Type="Edm.Boolean" Nullable="false"/>
<Property Name="membershipStatus" Type="graph.bookingStaffMembershipStatus" Nullable="false"/>
<Property Name="role" Type="graph.bookingStaffRole" Nullable="false"/>
<Property Name="timeZone" Type="Edm.String"/>
<Property Name="useBusinessHours" Type="Edm.Boolean" Nullable="false"/>
Expand Down
11 changes: 11 additions & 0 deletions office365/sharepoint/activities/action_facet.py
Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions 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"
8 changes: 8 additions & 0 deletions office365/sharepoint/activities/client_response.py
Expand Up @@ -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"
1 change: 1 addition & 0 deletions office365/sharepoint/activities/facets/delete.py
Expand Up @@ -5,6 +5,7 @@ class DeleteFacet(ClientValue):
""""""

def __init__(self, name=None):
# type: (str) -> None
self.name = name

@property
Expand Down
4 changes: 4 additions & 0 deletions office365/sharepoint/activities/facets/in_doc.py
Expand Up @@ -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"
@@ -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"
9 changes: 9 additions & 0 deletions 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"
9 changes: 9 additions & 0 deletions 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"
12 changes: 12 additions & 0 deletions 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"
15 changes: 15 additions & 0 deletions office365/sharepoint/entity.py
Expand Up @@ -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

Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions office365/sharepoint/folders/folder.py
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions 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
@@ -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 (
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions office365/sharepoint/userprofiles/people_manager.py
Expand Up @@ -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
Expand Down

0 comments on commit de6254c

Please sign in to comment.