Skip to content

Commit

Permalink
sites & folders namespaces updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Aug 10, 2023
1 parent dcc741d commit 9bcd332
Show file tree
Hide file tree
Showing 14 changed files with 573 additions and 376 deletions.
39 changes: 39 additions & 0 deletions examples/sharepoint/folders/coloring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.base_entity import BaseEntity
from office365.sharepoint.folders.folder import Folder


class FolderColoring(BaseEntity):
""""""

def create_folder(self, decoded_url, ensure_unique_file_name, overwrite, coloring_information):
"""
:param str decoded_url:
:param bool ensure_unique_file_name:
:param bool overwrite:
:param FolderColoringInformation coloring_information:
"""
return_type = Folder(self.context)

payload = {
"DecodedUrl": decoded_url,
"EnsureUniqueFileName": ensure_unique_file_name,
"Overwrite": overwrite,
"coloringInformation": coloring_information
}
qry = ServiceOperationQuery(self, "CreateFolder", parameters_type=payload, return_type=return_type)
self.context.add_query(qry)
return return_type

def stamp_color(self, decoded_url, coloring_information):
"""
:param str decoded_url:
:param FolderColoringInformation coloring_information:
"""
payload = {
"DecodedUrl": decoded_url,
"coloringInformation": coloring_information
}
qry = ServiceOperationQuery(self, "StampColor", parameters_type=payload)
self.context.add_query(qry)
return self
5 changes: 5 additions & 0 deletions examples/sharepoint/folders/coloring_information.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class ColoringInformation(ClientValue):
""""""
6 changes: 5 additions & 1 deletion examples/sharepoint/sharing/share_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
print(json.dumps(result.value.to_json(), indent=4))
link_url = result.value.sharingLinkInfo.Url

# Verify a link
print("Verifyng sharing link ...")
result = Web.get_sharing_link_kind(ctx, link_url).execute_query()
print(sharing_messages.get(result.value, "Unknown sharing link"))

print("Retrieving sharing link data ...")
result = ctx.web.get_sharing_link_data(link_url).execute_query()
print(json.dumps(result.value.to_json(), indent=4))

print("Unsharing a file link...")
remote_file.unshare_link(SharingLinkKind.AnonymousView).execute_query()

Expand Down
5 changes: 5 additions & 0 deletions examples/sharepoint/sites/get_site.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
Gets site properties
"""
from office365.sharepoint.client_context import ClientContext
from tests import test_site_url, test_client_credentials

Expand Down
757 changes: 395 additions & 362 deletions generator/metadata/SharePoint.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions office365/directory/audit/signins/activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from office365.runtime.client_value import ClientValue


class SignInActivity(ClientValue):
"""Provides the last interactive or non-interactive sign-in time for a specific user. Since signInActivity
describes a property of the user object, Azure AD stores sign in activity for your users for as long as the
user object exists."""
17 changes: 16 additions & 1 deletion office365/directory/users/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from office365.communications.presences.presence import Presence
from office365.delta_collection import DeltaCollection
from office365.directory.applications.roles.assignment_collection import AppRoleAssignmentCollection
from office365.directory.audit.signins.activity import SignInActivity
from office365.directory.authentication.authentication import Authentication
from office365.directory.extensions.extension import Extension
from office365.directory.identities.object_identity import ObjectIdentity
Expand Down Expand Up @@ -352,11 +353,24 @@ def translate_exchange_ids(self, input_ids, source_id_type=None, target_id_type=
self.context.add_query(qry)
return return_type

@property
def sign_in_activity(self):
"""Get the last signed-in date and request ID of the sign-in for a given user. Read-only."""
return self.properties.get('signInActivity', SignInActivity())

@property
def account_enabled(self):
"""True if the account is enabled; otherwise, false. This property is required when a user is created."""
return self.properties.get('accountEnabled', None)

@property
def age_group(self):
"""
Gets the age group of the user.
:rtype: str or None
"""
return self.properties.get('ageGroup', None)

@property
def app_role_assignments(self):
"""Get the apps and app roles which this user has been assigned."""
Expand Down Expand Up @@ -725,7 +739,8 @@ def get_property(self, name, default_value=None):
"oauth2PermissionGrants": self.oauth2_permission_grants,
"ownedDevices": self.owned_devices,
"ownedObjects": self.owned_objects,
"registeredDevices": self.registered_devices
"registeredDevices": self.registered_devices,
"signInActivity": self.sign_in_activity
}
default_value = property_mapping.get(name, None)
return super(User, self).get_property(name, default_value)
Expand Down
6 changes: 6 additions & 0 deletions office365/sharepoint/client_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ def models(self):
from office365.sharepoint.contentcenter.machinelearning.models.collection import SPMachineLearningModelCollection
return SPMachineLearningModelCollection(self, ResourcePath("models"))

@property
def folder_coloring(self):
"""Alias to FolderColoring"""
from examples.sharepoint.folders.coloring import FolderColoring
return FolderColoring(self, ResourcePath("foldercoloring"))

@property
def group_site_manager(self):
"""Alias to GroupSiteManager"""
Expand Down
22 changes: 18 additions & 4 deletions office365/sharepoint/lists/creation_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,33 @@
class ListCreationInformation(ClientValue):
"""Represents metadata about list creation."""

def __init__(self, title=None, description=None, base_template=None, allow_content_types=False):
def __init__(self, title=None, description=None, base_template=None, allow_content_types=False,
custom_schema_xml=None, document_template_type=None, quick_launch_option=None,
template_feature_id=None, template_type=None):
"""
:type base_template: int or None
:type allow_content_types: bool
:param int or None base_template:
:param bool allow_content_types:
:poram str or None description: Specifies the description of the new list.
:param str title: Specifies the display name of the new list.
:param str custom_schema_xml: Specifies the list schema of the new list.
:param str document_template_type: Specifies the identifier of the document template for the new list.
:param int quick_launch_option: Specifies whether the new list is displayed on the Quick Launch of the site
:param int template_feature_id: Specifies the feature identifier of the feature that contains the list schema
for the new list. It MUST be empty GUID if the list schema for the new list is not contained within
a feature.
:param int template_type: Specifies the list server template of the new list.
"""
super(ListCreationInformation, self).__init__()
self.Title = title
self.Description = description
self.BaseTemplate = base_template
self.AllowContentTypes = allow_content_types
self.CustomSchemaXml = custom_schema_xml
self.DataSourceProperties = None
self.DocumentTemplateType = document_template_type
self.QuickLaunchOption = quick_launch_option
self.TemplateFeatureId = template_feature_id
self.TemplateType = template_type

@property
def entity_type_name(self):
Expand Down
22 changes: 21 additions & 1 deletion office365/sharepoint/lists/render_data_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,33 @@
class RenderListDataParameters(ClientValue):
"""Specifies the parameters to be used to render list data as a JSON string"""

def __init__(self, add_all_fields=None, add_required_fields=None):
def __init__(self, add_all_fields=None, add_all_view_fields=None, add_regional_settings=None,
add_required_fields=None, allow_multiple_value_filter_for_taxonomy_fields=None,
audience_target=None, dates_in_utc=None, expand_groups=None, expand_user_field=None,
filter_out_channel_folders_in_default_doc_lib=None):
"""
:param bool add_all_fields:
:param bool add_all_view_fields:
:param bool add_regional_settings:
:param bool add_required_fields: This parameter indicates if we return required fields.
:param bool allow_multiple_value_filter_for_taxonomy_fields: This parameter indicates whether multi value
filtering is allowed for taxonomy fields.
:param bool audience_target:
:param bool dates_in_utc: Specifies if the DateTime field is returned in UTC or local time.
:param bool expand_groups: Specifies whether to expand the grouping or not.
:param bool expand_user_field:
:param bool filter_out_channel_folders_in_default_doc_lib:
"""
self.AddAllFields = add_all_fields
self.AddAllViewFields = add_all_view_fields
self.AddRegionalSettings = add_regional_settings
self.AddRequiredFields = add_required_fields
self.AllowMultipleValueFilterForTaxonomyFields = allow_multiple_value_filter_for_taxonomy_fields
self.AudienceTarget = audience_target
self.DatesInUtc = dates_in_utc
self.ExpandGroups = expand_groups
self.ExpandUserField = expand_user_field
self.FilterOutChannelFoldersInDefaultDocLib = filter_out_channel_folders_in_default_doc_lib

@property
def entity_type_name(self):
Expand Down
12 changes: 11 additions & 1 deletion office365/sharepoint/sites/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@


class Language(ClientValue):
pass
"""Represents a natural language."""

def __init__(self, display_name=None, language_tag=None, lcid=None):
"""
:param str display_name: Specifies the name of the language as displayed in the user interface.
:param str language_tag: Specifies the corresponding culture name for the language.
:param int lcid: Specifies the language code identifier (LCID) for the language.
"""
self.DisplayName = display_name
self.LanguageTag = language_tag
self.Lcid = lcid
1 change: 1 addition & 0 deletions office365/sharepoint/sites/language_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class LanguageCollection(BaseEntity):
"""Represents a collection of SPLanguage objects"""

def __init__(self, context, resource_path=None):
"""Represents a collection of SPLanguage objects."""
Expand Down
40 changes: 34 additions & 6 deletions office365/sharepoint/sites/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ def update_client_object_model_use_remote_apis_permission_setting(self, require_
self.context.add_query(qry)
return self

@property
def allow_create_declarative_workflow(self):
"""
Specifies whether a designer can be used to create declarative workflows on this site collection
:rtype: bool or None
"""
return self.properties.get("AllowCreateDeclarativeWorkflow", None)

@property
def allow_designer(self):
"""
Expand Down Expand Up @@ -485,7 +494,6 @@ def group_id(self):
def lock_issue(self):
"""
Specifies the comment that is used when a site collection is locked
:rtype: str or None
"""
return self.properties.get("LockIssue", None)
Expand Down Expand Up @@ -533,7 +541,6 @@ def url(self):
def server_relative_url(self):
"""
Specifies the server-relative URL of the top-level site in the site collection.
:rtype: str
"""
return self.properties.get("ServerRelativeUrl", None)
Expand All @@ -542,16 +549,22 @@ def server_relative_url(self):
def share_by_email_enabled(self):
"""
When true, users will be able to grant permissions to guests for resources within the site collection.
:rtype: bool or none
"""
return self.properties.get('ShareByEmailEnabled', None)

@property
def status_bar_text(self):
"""
Gets or sets the status bar message text for this site.
:rtype: str or none
"""
return self.properties.get('StatusBarText', None)

@property
def trim_audit_log(self):
"""
When this flag is set for the site, the audit events are trimmed periodically.
:rtype: bool or none
"""
return self.properties.get('TrimAuditLog', None)
Expand Down Expand Up @@ -583,15 +596,13 @@ def hub_site_id(self):
def is_hub_site(self):
"""
Returns whether the specified site is a hub site
:rtype: bool
"""
return self.properties.get("IsHubSite", None)

@property
def server_relative_path(self):
"""Gets the server-relative Path of the Site.
:rtype: SPResPath or None
"""
return self.properties.get("ServerRelativePath", SPResPath())
Expand Down Expand Up @@ -625,6 +636,23 @@ def features(self):
FeatureCollection(self.context,
ResourcePath("Features", self.resource_path), self))

@property
def max_items_per_throttled_operation(self):
"""
Specifies the maximum number of list items allowed to be returned for each retrieve request before throttling
occurs. If throttling occurs, list items MUST NOT be returned.
:rtype: int or None
"""
return self.properties.get("MaxItemsPerThrottledOperation", None)

@property
def needs_b2b_upgrade(self):
"""
Specifies whether the site needs a Build-to-Build upgrade.
:rtype: bool or None
"""
return self.properties.get("NeedsB2BUpgrade", None)

@property
def event_receivers(self):
"""
Expand Down
10 changes: 10 additions & 0 deletions office365/sharepoint/tenant/administration/hubsites/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

class HubSitePermission(ClientValue):

def __init__(self, display_name=None, principal_name=None, rights=None):
"""
:param str display_name:
:param str principal_name:
:param int rights:
"""
self.DisplayName = display_name
self.PrincipalName = principal_name
self.Rights = rights

@property
def entity_type_name(self):
return "Microsoft.Online.SharePoint.TenantAdministration.HubSitePermission"

0 comments on commit 9bcd332

Please sign in to comment.