Skip to content

Commit

Permalink
refactorings and type hints for collection types
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Oct 8, 2023
1 parent 582ab2b commit 949f683
Show file tree
Hide file tree
Showing 348 changed files with 742 additions and 746 deletions.
7 changes: 3 additions & 4 deletions examples/sharepoint/fields/get_from_list.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""
This example retrieves all of the fields in a SharePoint list.
This example retrieves all fields in a SharePoint list.
"""

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.fields.field import Field
from tests import test_client_credentials, test_team_site_url

client = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
target_list = client.web.lists.get_by_title("Site Pages")
fields = target_list.fields.get().execute_query()
for f in fields: # type: Field
print(f"Field name {f.internal_name}")
for field in fields:
print("Field name {0}".format(field.internal_name))
7 changes: 3 additions & 4 deletions examples/sharepoint/fields/get_from_web.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
This example retrieves all of the fields in a SharePoint site.
This example retrieves all fields in a SharePoint site.
"""
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.fields.field import Field
from tests import test_client_credentials, test_team_site_url

client = ClientContext(test_team_site_url).with_credentials(test_client_credentials)

web_fields = client.web.fields.get().execute_query()
for f in web_fields: # type: Field
print(f"Field name {f.internal_name}")
for f in web_fields:
print("Field name {0}".format(f.internal_name))
9 changes: 5 additions & 4 deletions examples/sharepoint/permissions/get_for_site.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
Demonstrates how to retrieve site groups along with users
"""
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.principal.groups.group import Group
from office365.sharepoint.principal.users.user import User
from tests import test_client_credentials, test_team_site_url

ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)

site_groups = ctx.web.site_groups.expand(["Users"]).get().execute_query()
for g in site_groups: # type: Group
for g in site_groups:
print("Group name: {0}".format(g.login_name))
for u in g.users: # type: User
for u in g.users:
print("User name: {0}".format(u.login_name))
2 changes: 1 addition & 1 deletion generator/metadata/SharePoint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38679,6 +38679,7 @@
<Property Name="MediaServiceGenerationTime" Type="Edm.String"/>
<Property Name="MediaServiceEventHashCode" Type="Edm.String"/>
<Property Name="MediaLengthInSeconds" Type="Edm.Int32"/>
<Property Name="OData__EffectiveIpLabelDisplayName" Type="Edm.String"/>
<Property Name="ID" Type="Edm.Int32"/>
<Property Name="Created" Type="Edm.DateTime"/>
<Property Name="AuthorId" Type="Edm.Int32"/>
Expand Down Expand Up @@ -38729,7 +38730,6 @@
<Property Name="Combine" Type="Edm.String"/>
<Property Name="RepairDocument" Type="Edm.String"/>
<Property Name="PolicyDisabledUICapabilities" Type="Edm.String"/>
<Property Name="OData__EffectiveIpLabelDisplayName" Type="Edm.String"/>
<NavigationProperty Name="Author" Relationship="SP.Data.SP_Data_DocumentsItem_Author_SP_Data_UserInfoItem_AuthorPartner" ToRole="Author" FromRole="AuthorPartner"/>
<NavigationProperty Name="Editor" Relationship="SP.Data.SP_Data_DocumentsItem_Editor_SP_Data_UserInfoItem_EditorPartner" ToRole="Editor" FromRole="EditorPartner"/>
<NavigationProperty Name="CheckoutUser" Relationship="SP.Data.SP_Data_DocumentsItem_CheckoutUser_SP_Data_UserInfoItem_CheckoutUserPartner" ToRole="CheckoutUser" FromRole="CheckoutUserPartner"/>
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/activities/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from office365.sharepoint.activities.facets.coalesced import CoalescedFacet
from office365.sharepoint.activities.facets.in_doc import InDocFacet
from office365.sharepoint.activities.facets.resource import ResourceFacet
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity
from office365.sharepoint.sharing.principal import Principal


class SPActivityEntity(BaseEntity):
class SPActivityEntity(Entity):
""""""

@property
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/activities/logger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class ActivityLogger(BaseEntity):
class ActivityLogger(Entity):
def log_activity(
self,
operation,
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/activities/tracked_item_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from office365.sharepoint.activities.tracked_item_updates_request import (
TrackedItemUpdatesRequest,
)
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class TrackedItemService(BaseEntity):
class TrackedItemService(Entity):
@staticmethod
def get_tracked_item_updates_for_user(context):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class SPAnalyticsUsageService(BaseEntity):
class SPAnalyticsUsageService(Entity):
"""Represents the entry point for the Event REST service exposed through CSOM"""

def __init__(self, context):
Expand Down
8 changes: 4 additions & 4 deletions office365/sharepoint/administration/web_application.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.base_entity_collection import BaseEntityCollection
from office365.sharepoint.entity import Entity
from office365.sharepoint.entity_collection import EntityCollection
from office365.sharepoint.sites.site import Site


class WebApplication(BaseEntity):
class WebApplication(Entity):
@staticmethod
def lookup(context, request_uri):
"""
Expand All @@ -31,7 +31,7 @@ def outbound_mail_sender_address(self):
def sites(self):
return self.properties.get(
"Sites",
BaseEntityCollection(
EntityCollection(
self.context, Site, ResourcePath("Sites", self.resource_path)
),
)
Expand Down
8 changes: 4 additions & 4 deletions office365/sharepoint/administration/web_service.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.administration.web_application import WebApplication
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.base_entity_collection import BaseEntityCollection
from office365.sharepoint.entity import Entity
from office365.sharepoint.entity_collection import EntityCollection


class SPWebService(BaseEntity):
class SPWebService(Entity):
@staticmethod
def content_service(context):
"""
Expand All @@ -23,7 +23,7 @@ def content_service(context):
def web_applications(self):
return self.properties.get(
"WebApplications",
BaseEntityCollection(
EntityCollection(
self.context,
WebApplication,
ResourcePath("WebApplications", self.resource_path),
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/alerts/alert.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.runtime.paths.resource_path import ResourcePath
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class Alert(BaseEntity):
class Alert(Entity):
"""
Represents an alert, which generates periodic e-mail notifications sent to a user about the list, list item,
document, or document library to which the alert applies. SP.Alert provides information about the alert,
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/alerts/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from office365.runtime.paths.service_operation import ServiceOperationPath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.alerts.alert import Alert
from office365.sharepoint.base_entity_collection import BaseEntityCollection
from office365.sharepoint.entity_collection import EntityCollection


class AlertCollection(BaseEntityCollection):
class AlertCollection(EntityCollection):
"""Content Type resource collection"""

def __init__(self, context, resource_path=None):
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/analytics/usage_entry.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AnalyticsUsageEntry(BaseEntity):
class AnalyticsUsageEntry(Entity):
"""Specifies an analytics usage entry to log user or system events"""

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/appprincipal/credential.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AppPrincipalCredential(BaseEntity):
class AppPrincipalCredential(Entity):
"""Represents a credential belonging to an app principal."""

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/appprincipal/identity_provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AppPrincipalIdentityProvider(BaseEntity):
class AppPrincipalIdentityProvider(Entity):
"""Represents an identity provider for app principals."""

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/appprincipal/manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AppPrincipalManager(BaseEntity):
class AppPrincipalManager(Entity):
"""Represents a top level object used to manage app principals."""
4 changes: 2 additions & 2 deletions office365/sharepoint/appprincipal/name.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AppPrincipalName(BaseEntity):
class AppPrincipalName(Entity):
"""Represents the name of an app principal."""
4 changes: 2 additions & 2 deletions office365/sharepoint/apps/app_collection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AppCollection(BaseEntity):
class AppCollection(Entity):
@property
def entity_type_name(self):
return "Microsoft.AppServices.AppCollection"
4 changes: 2 additions & 2 deletions office365/sharepoint/apps/license_manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.apps.license_collection import AppLicenseCollection
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class SPAppLicenseManager(BaseEntity):
class SPAppLicenseManager(Entity):
def check_license(self, product_id):
"""
:param str product_id:
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/apps/solution_exporter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class SolutionExporter(BaseEntity):
class SolutionExporter(Entity):
pass
4 changes: 2 additions & 2 deletions office365/sharepoint/apps/user_solution.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class UserSolution(BaseEntity):
class UserSolution(Entity):
pass
4 changes: 2 additions & 2 deletions office365/sharepoint/attachments/attachment.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity
from office365.sharepoint.internal.queries.upload_file import create_upload_file_query
from office365.sharepoint.types.resource_path import ResourcePath as SPResPath


class Attachment(BaseEntity):
class Attachment(Entity):
"""Represents an attachment file in a SharePoint List Item."""

def download(self, file_object, use_path=True):
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/attachments/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from office365.sharepoint.attachments.creation_information import (
AttachmentCreationInformation,
)
from office365.sharepoint.base_entity_collection import BaseEntityCollection
from office365.sharepoint.entity_collection import EntityCollection


class AttachmentCollection(BaseEntityCollection):
class AttachmentCollection(EntityCollection):
"""Represents a collection of Attachment resources."""

def __init__(self, context, resource_path=None, parent=None):
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/audit/audit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class Audit(BaseEntity):
class Audit(Entity):
"""
Enables auditing of how site collections, sites, lists, folders, and list items are accessed, changed, and used.
"""
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/authpolicy/events/auth_event.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class SPAuthEvent(BaseEntity):
class SPAuthEvent(Entity):
@property
def entity_type_name(self):
return "Microsoft.SharePoint.AuthPolicy.Events.SPAuthEvent"
4 changes: 2 additions & 2 deletions office365/sharepoint/businessdata/app_bdc_catalog.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.runtime.types.collections import StringCollection
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class AppBdcCatalog(BaseEntity):
class AppBdcCatalog(Entity):
"""
Represents the Business Data Connectivity (BDC) MetadataCatalog for an application that contains external content
types provisioned by the application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class ConnectionSettings(BaseEntity):
class ConnectionSettings(Entity):
""""""

@property
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/campaigns/campaigns.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.entity import Entity


class Campaigns(BaseEntity):
class Campaigns(Entity):
@staticmethod
def get_campaign(context, campaign_id):
"""
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/changes/change.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.changes.token import ChangeToken
from office365.sharepoint.entity import Entity


class Change(BaseEntity):
class Change(Entity):
"""Base class for a change. installation."""

@property
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/changes/collection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.sharepoint.base_entity_collection import BaseEntityCollection
from office365.sharepoint.changes.change import Change
from office365.sharepoint.entity_collection import EntityCollection


class ChangeCollection(BaseEntityCollection):
class ChangeCollection(EntityCollection):
"""Represents a collection of Change objects"""

def __init__(self, context, resource_path=None):
Expand Down
4 changes: 2 additions & 2 deletions office365/sharepoint/client_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,12 @@ def home_site(self):

@property
def publications(self):
from office365.sharepoint.base_entity_collection import BaseEntityCollection
from office365.sharepoint.contentcenter.machinelearning.publications.publication import (
SPMachineLearningPublication,
)
from office365.sharepoint.entity_collection import EntityCollection

return BaseEntityCollection(
return EntityCollection(
self, SPMachineLearningPublication, ResourcePath("publications")
)

Expand Down
Loading

0 comments on commit 949f683

Please sign in to comment.