Skip to content

Commit

Permalink
OneDrive: introduced support for recyclebin types, workbooks namespac…
Browse files Browse the repository at this point in the history
…e types update
  • Loading branch information
vgrem committed Dec 14, 2024
1 parent 84e7292 commit 0ef1afb
Show file tree
Hide file tree
Showing 23 changed files with 200 additions and 21 deletions.
12 changes: 6 additions & 6 deletions examples/directory/applications/grant_application_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
from tests import (
test_client_id,
test_client_secret,
test_tenant,
test_tenant, test_admin_principal_name,
)

# client = GraphClient.with_token_interactive(
# test_tenant, test_client_id, test_admin_principal_name
# )
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
client = GraphClient.with_token_interactive(
test_tenant, test_client_id, test_admin_principal_name
)
#client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)

# Step 1: Get the resource service principal
resource = client.service_principals.get_by_name("Microsoft Graph")

# Step 2: Grant an app role to a client app
app = client.applications.get_by_app_id(test_client_id)
resource.grant_application_permissions(app, "Bookings.Read.All").execute_query()
resource.grant_application_permissions(app, "ThreatAssessment.Read.All").execute_query()


# Step 3 (optional). Print app role assignments
Expand Down
2 changes: 1 addition & 1 deletion examples/directory/applications/has_application_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


resource = client.service_principals.get_by_name("Microsoft Graph")
app_role = "Bookings.Read.All"
app_role = "ThreatAssessment.Read.All" # "Bookings.Read.All"
result = resource.get_application_permissions(test_client_id).execute_query()
if (
len([cur_app_role for cur_app_role in result.value if cur_app_role == app_role])
Expand Down
66 changes: 66 additions & 0 deletions generator/metadata/Graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17290,6 +17290,11 @@ within the time frame of their original request."/>
<Member Name="x509CertificateMultiFactor" Value="1"/>
<Member Name="unknownFutureValue" Value="2"/>
</EnumType>
<EnumType Name="x509CertificateCRLValidationConfigurationState">
<Member Name="disabled" Value="0"/>
<Member Name="enabled" Value="1"/>
<Member Name="unknownFutureValue" Value="2"/>
</EnumType>
<EnumType Name="x509CertificateRuleType">
<Member Name="issuerSubject" Value="0"/>
<Member Name="policyOID" Value="1"/>
Expand Down Expand Up @@ -18407,6 +18412,13 @@ within the time frame of their original request."/>
<Member Name="reactivating" Value="2"/>
<Member Name="unknownFutureValue" Value="3"/>
</EnumType>
<EnumType Name="siteLockState">
<Member Name="unlocked" Value="0"/>
<Member Name="lockedReadOnly" Value="1"/>
<Member Name="lockedNoAccess" Value="2"/>
<Member Name="lockedNoAdditions" Value="3"/>
<Member Name="unknownFutureValue" Value="4"/>
</EnumType>
<EnumType Name="titleAreaLayoutType">
<Member Name="imageAndTitle" Value="0"/>
<Member Name="plain" Value="1"/>
Expand Down Expand Up @@ -22245,6 +22257,13 @@ within the time frame of their original request."/>
<Member Name="unknownFutureValue" Value="7"/>
<Member Name="emailUser" Value="8"/>
</EnumType>
<EnumType Name="eligibilityFilteringEnabledEntities" IsFlags="true">
<Member Name="none" Value="0"/>
<Member Name="swapRequest" Value="1"/>
<Member Name="offerShiftRequest" Value="2"/>
<Member Name="unknownFutureValue" Value="4"/>
<Member Name="timeOffReason" Value="8"/>
</EnumType>
<EnumType Name="scheduleChangeRequestActor">
<Member Name="sender" Value="0"/>
<Member Name="recipient" Value="1"/>
Expand Down Expand Up @@ -22310,6 +22329,9 @@ within the time frame of their original request."/>
<Member Name="openShiftRequest" Value="32"/>
<Member Name="offerShiftRequest" Value="64"/>
<Member Name="unknownFutureValue" Value="1024"/>
<Member Name="timeOffReason" Value="4096"/>
<Member Name="timeOff" Value="8192"/>
<Member Name="timeOffRequest" Value="16384"/>
</EnumType>
<EnumType Name="mailDestinationRoutingReason">
<Member Name="none" Value="0"/>
Expand Down Expand Up @@ -24062,6 +24084,10 @@ within the time frame of their original request."/>
<Property Name="x509CertificateRequiredAffinityLevel" Type="graph.x509CertificateAffinityLevel"/>
<Property Name="x509CertificateRuleType" Type="graph.x509CertificateRuleType"/>
</ComplexType>
<ComplexType Name="x509CertificateCRLValidationConfiguration">
<Property Name="exemptedCertificateAuthoritiesSubjectKeyIdentifiers" Type="Collection(Edm.String)"/>
<Property Name="state" Type="graph.x509CertificateCRLValidationConfigurationState" Nullable="false"/>
</ComplexType>
<ComplexType Name="x509CertificateUserBinding">
<Property Name="priority" Type="Edm.Int32" Nullable="false"/>
<Property Name="trustAffinityLevel" Type="graph.x509CertificateAffinityLevel"/>
Expand Down Expand Up @@ -24286,6 +24312,7 @@ within the time frame of their original request."/>
<EntityType Name="x509CertificateAuthenticationMethodConfiguration" BaseType="graph.authenticationMethodConfiguration">
<Property Name="authenticationModeConfiguration" Type="graph.x509CertificateAuthenticationModeConfiguration"/>
<Property Name="certificateUserBindings" Type="Collection(graph.x509CertificateUserBinding)"/>
<Property Name="crlValidationConfiguration" Type="graph.x509CertificateCRLValidationConfiguration" Nullable="false"/>
<NavigationProperty Name="includeTargets" Type="Collection(graph.authenticationMethodTarget)" ContainsTarget="true"/>
</EntityType>
<EntityType Name="x509CertificateCombinationConfiguration" BaseType="graph.authenticationCombinationConfiguration">
Expand Down Expand Up @@ -26544,6 +26571,7 @@ within the time frame of their original request."/>
<Property Name="federatedIdpMfaBehavior" Type="graph.federatedIdpMfaBehavior"/>
<Property Name="isSignedAuthenticationRequestRequired" Type="Edm.Boolean"/>
<Property Name="nextSigningCertificate" Type="Edm.String"/>
<Property Name="passwordResetUri" Type="Edm.String"/>
<Property Name="promptLoginBehavior" Type="graph.promptLoginBehavior"/>
<Property Name="signingCertificateUpdateStatus" Type="graph.signingCertificateUpdateStatus"/>
<Property Name="signOutUri" Type="Edm.String"/>
Expand Down Expand Up @@ -28428,18 +28456,25 @@ within the time frame of their original request."/>
</ComplexType>
<EntityType Name="fileStorage" BaseType="graph.entity">
<NavigationProperty Name="containers" Type="Collection(graph.fileStorageContainer)" ContainsTarget="true"/>
<NavigationProperty Name="deletedContainers" Type="Collection(graph.fileStorageContainer)" ContainsTarget="true"/>
</EntityType>
<EntityType Name="fileStorageContainer" BaseType="graph.entity">
<Property Name="containerTypeId" Type="Edm.Guid" Nullable="false"/>
<Property Name="createdDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
<Property Name="customProperties" Type="graph.fileStorageContainerCustomPropertyDictionary"/>
<Property Name="description" Type="Edm.String"/>
<Property Name="displayName" Type="Edm.String" Nullable="false"/>
<Property Name="lockState" Type="graph.siteLockState"/>
<Property Name="settings" Type="graph.fileStorageContainerSettings" Nullable="false"/>
<Property Name="status" Type="graph.fileStorageContainerStatus"/>
<Property Name="viewpoint" Type="graph.fileStorageContainerViewpoint"/>
<NavigationProperty Name="drive" Type="graph.drive" ContainsTarget="true"/>
<NavigationProperty Name="permissions" Type="Collection(graph.permission)" ContainsTarget="true"/>
<NavigationProperty Name="recycleBin" Type="graph.recycleBin" ContainsTarget="true"/>
</EntityType>
<EntityType Name="recycleBin" BaseType="graph.baseItem" OpenType="true">
<Property Name="settings" Type="graph.recycleBinSettings"/>
<NavigationProperty Name="items" Type="Collection(graph.recycleBinItem)" ContainsTarget="true"/>
</EntityType>
<EntityType Name="sharepointSettings" BaseType="graph.entity">
<Property Name="allowedDomainGuidsForSyncApp" Type="Collection(Edm.Guid)"/>
Expand Down Expand Up @@ -28663,6 +28698,9 @@ within the time frame of their original request."/>
<Property Name="likeCount" Type="Edm.Int32"/>
<Property Name="shareCount" Type="Edm.Int32"/>
</ComplexType>
<ComplexType Name="recycleBinSettings">
<Property Name="retentionPeriodOverrideDays" Type="Edm.Int32"/>
</ComplexType>
<ComplexType Name="renameAction">
<Property Name="newName" Type="Edm.String"/>
<Property Name="oldName" Type="Edm.String"/>
Expand Down Expand Up @@ -28809,6 +28847,11 @@ within the time frame of their original request."/>
<Property Name="startDateTime" Type="Edm.DateTimeOffset"/>
<NavigationProperty Name="activities" Type="Collection(graph.itemActivity)"/>
</EntityType>
<EntityType Name="recycleBinItem" BaseType="graph.baseItem" OpenType="true">
<Property Name="deletedDateTime" Type="Edm.DateTimeOffset"/>
<Property Name="deletedFromLocation" Type="Edm.String"/>
<Property Name="size" Type="Edm.Int64"/>
</EntityType>
<EntityType Name="sharedDriveItem" BaseType="graph.baseItem">
<Property Name="owner" Type="graph.identitySet"/>
<NavigationProperty Name="driveItem" Type="graph.driveItem" ContainsTarget="true"/>
Expand Down Expand Up @@ -34641,6 +34684,7 @@ within the time frame of their original request."/>
<EntityType Name="workforceIntegration" BaseType="graph.changeTrackedEntity">
<Property Name="apiVersion" Type="Edm.Int32"/>
<Property Name="displayName" Type="Edm.String"/>
<Property Name="eligibilityFilteringEnabledEntities" Type="graph.eligibilityFilteringEnabledEntities"/>
<Property Name="encryption" Type="graph.workforceIntegrationEncryption"/>
<Property Name="isActive" Type="Edm.Boolean"/>
<Property Name="supportedEntities" Type="graph.workforceIntegrationSupportedEntities"/>
Expand Down Expand Up @@ -34709,6 +34753,7 @@ within the time frame of their original request."/>
</EntityType>
<EntityType Name="openShift" BaseType="graph.changeTrackedEntity">
<Property Name="draftOpenShift" Type="graph.openShiftItem"/>
<Property Name="isStagedForDeletion" Type="Edm.Boolean"/>
<Property Name="schedulingGroupId" Type="Edm.String"/>
<Property Name="sharedOpenShift" Type="graph.openShiftItem"/>
</EntityType>
Expand All @@ -34722,6 +34767,7 @@ within the time frame of their original request."/>
</EntityType>
<EntityType Name="shift" BaseType="graph.changeTrackedEntity">
<Property Name="draftShift" Type="graph.shiftItem"/>
<Property Name="isStagedForDeletion" Type="Edm.Boolean"/>
<Property Name="schedulingGroupId" Type="Edm.String"/>
<Property Name="sharedShift" Type="graph.shiftItem"/>
<Property Name="userId" Type="Edm.String"/>
Expand All @@ -34741,6 +34787,7 @@ within the time frame of their original request."/>
</EntityType>
<EntityType Name="timeOff" BaseType="graph.changeTrackedEntity">
<Property Name="draftTimeOff" Type="graph.timeOffItem"/>
<Property Name="isStagedForDeletion" Type="Edm.Boolean"/>
<Property Name="sharedTimeOff" Type="graph.timeOffItem"/>
<Property Name="userId" Type="Edm.String"/>
</EntityType>
Expand Down Expand Up @@ -35687,6 +35734,10 @@ within the time frame of their original request."/>
</Parameter>
<ReturnType Type="graph.directoryObject"/>
</Action>
<Action Name="restore" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.fileStorageContainer"/>
<ReturnType Type="graph.fileStorageContainer"/>
</Action>
<Action Name="restore" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.driveItem"/>
<Parameter Name="parentReference" Type="graph.itemReference"/>
Expand Down Expand Up @@ -39126,12 +39177,21 @@ within the time frame of their original request."/>
<Parameter Name="TimeZoneStandard" Type="graph.timeZoneStandard" Nullable="false"/>
<ReturnType Type="Collection(graph.timeZoneInformation)" Nullable="false"/>
</Function>
<Action Name="lock" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.fileStorageContainer"/>
<Parameter Name="lockState" Type="graph.siteLockState">
<Annotation Term="Org.OData.Core.V1.OptionalParameter"/>
</Parameter>
</Action>
<Action Name="permanentDelete" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.fileStorageContainer"/>
</Action>
<Action Name="permanentDelete" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.driveItem"/>
</Action>
<Action Name="unlock" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.fileStorageContainer"/>
</Action>
<Action Name="remove" IsBound="true">
<Parameter Name="bindingParameter" Type="Collection(graph.site)"/>
<Parameter Name="value" Type="Collection(graph.site)"/>
Expand Down Expand Up @@ -39197,6 +39257,9 @@ within the time frame of their original request."/>
</Parameter>
<ReturnType Type="graph.permission"/>
</Action>
<Action Name="discardCheckout" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.driveItem"/>
</Action>
<Action Name="extractSensitivityLabels" IsBound="true">
<Parameter Name="bindparameter" Type="graph.driveItem"/>
<ReturnType Type="graph.extractSensitivityLabelsResult"/>
Expand Down Expand Up @@ -40799,6 +40862,9 @@ within the time frame of their original request."/>
<Parameter Name="startDateTime" Type="Edm.DateTimeOffset"/>
<Parameter Name="endDateTime" Type="Edm.DateTimeOffset"/>
</Action>
<Action Name="stageForDeletion" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.changeTrackedEntity"/>
</Action>
<Action Name="endWorkingTime" IsBound="true">
<Parameter Name="bindparameter" Type="graph.workingTimeSchedule" Nullable="false"/>
</Action>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Optional

from office365.directory.protection.threatassessment.request import ThreatAssessmentRequest


class EmailFileAssessmentRequest(ThreatAssessmentRequest):
"""
Represents a resource that creates and retrieves an email file threat assessment.
The email file can be an .eml file type.
"""

@property
def content_data(self):
# type: () -> Optional[str]
"""
Base64 encoded .eml email file content. The file content can't fetch back because it isn't stored.
"""
return self.properties.get("contentData", None)
1 change: 1 addition & 0 deletions office365/directory/protection/threatassessment/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

class ThreatAssessmentRequest(Entity):
"""An abstract resource type used to represent a threat assessment request item."""

File renamed without changes.
2 changes: 1 addition & 1 deletion office365/onedrive/columns/definition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.onedrive.columns.boolean import BooleanColumn
from office365.onedrive.columns.calculated import CalculatedColumn
from office365.onedrive.columns.choice import ChoiceColumn
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/contenttypes/content_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.entity_collection import EntityCollection
from office365.onedrive.columns.column_link import ColumnLink
from office365.onedrive.columns.definition import ColumnDefinition
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/driveitems/driveItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests
from typing_extensions import Self

from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.delta_path import DeltaPath
from office365.entity_collection import EntityCollection
from office365.onedrive.analytics.item_activity_stat import ItemActivityStat
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/drives/drive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.directory.permissions.identity_set import IdentitySet
from office365.entity_collection import EntityCollection
from office365.onedrive.driveitems.conflict_behavior import ConflictBehavior
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/listitems/field_value_set.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem


class FieldValueSet(BaseItem):
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/listitems/list_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.entity_collection import EntityCollection
from office365.onedrive.analytics.item_analytics import ItemAnalytics
from office365.onedrive.contenttypes.info import ContentTypeInfo
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/lists/list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.entity_collection import EntityCollection
from office365.onedrive.columns.definition_collection import ColumnDefinitionCollection
from office365.onedrive.contenttypes.collection import ContentTypeCollection
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions office365/onedrive/recyclebin/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from office365.onedrive.base_item import BaseItem


class RecycleBinItem(BaseItem):
"""Represents information about a deleted item in a recycleBin of a SharePoint site or a SharePoint
Embedded fileStorageContainer."""




26 changes: 26 additions & 0 deletions office365/onedrive/recyclebin/recyclebin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from office365.entity_collection import EntityCollection
from office365.onedrive.base_item import BaseItem
from office365.onedrive.recyclebin.item import RecycleBinItem
from office365.onedrive.recyclebin.settings import RecycleBinSettings
from office365.runtime.paths.resource_path import ResourcePath


class RecycleBin(BaseItem):
"""Represents a container for a collection of recycleBinItem resources in a SharePoint site or a
SharePoint Embedded fileStorageContainer."""

@property
def items(self):
# type: () -> EntityCollection[RecycleBinItem]
"""List of the recycleBinItems deleted by a user."""
return self.properties.setdefault(
"items",
EntityCollection(
self.context, RecycleBinItem, ResourcePath("items", self.resource_path), self
),
)

@property
def settings(self):
"""Settings for the recycleBin"""
return self.properties.get("settings", RecycleBinSettings())
13 changes: 13 additions & 0 deletions office365/onedrive/recyclebin/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from office365.runtime.client_value import ClientValue


class RecycleBinSettings(ClientValue):
"""Represents settings for the recycleBin resource type."""

def __init__(self, retention_period_override_days=None):
"""
:param int retention_period_override_days: Recycle bin retention period override in days for deleted content.
The default value is 93; the value range is 7 to 180. The setting applies to newly deleted content only.
Setting this property to null reverts to its default value.
"""
self.retentionPeriodOverrideDays = retention_period_override_days
2 changes: 1 addition & 1 deletion office365/onedrive/shares/drive_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.directory.permissions.identity_set import IdentitySet
from office365.entity_collection import EntityCollection
from office365.onedrive.driveitems.driveItem import DriveItem
Expand Down
2 changes: 1 addition & 1 deletion office365/onedrive/sitepages/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from office365.base_item import BaseItem
from office365.onedrive.base_item import BaseItem
from office365.onedrive.driveitems.publication_facet import PublicationFacet


Expand Down
Loading

0 comments on commit 0ef1afb

Please sign in to comment.