Skip to content

Commit

Permalink
Outlook API new types & model updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Aug 26, 2023
1 parent 4a768e0 commit 343a0a4
Show file tree
Hide file tree
Showing 38 changed files with 506 additions and 43 deletions.
15 changes: 15 additions & 0 deletions examples/outlook/calendars/share_with.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Create calendarPermission
Demonstrates how to share my calendar with another user
https://learn.microsoft.com/en-us/graph/api/calendar-post-calendarpermissions?view=graph-rest-1.0
"""
from office365.graph_client import GraphClient
from office365.outlook.calendar.role_type import CalendarRoleType
from tests.graph_case import acquire_token_by_username_password

client = GraphClient(acquire_token_by_username_password)
my_cal = client.me.calendar
cal_perm = my_cal.calendar_permissions.add("[email protected]", CalendarRoleType.read).execute_query()
print(cal_perm)
Empty file.
4 changes: 2 additions & 2 deletions generator/import_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def export_to_file(path, content):

parser = ArgumentParser()
parser.add_argument("-e", "--endpoint", dest="endpoint",
help="Import metadata endpoint", default="sharepoint")
help="Import metadata endpoint", default="microsoftgraph")
parser.add_argument("-p", "--path",
dest="path", default="./metadata/SharePoint.xml",
dest="path", default="./metadata/MicrosoftGraph.xml",
help="Import metadata endpoint")

args = parser.parse_args()
Expand Down
37 changes: 37 additions & 0 deletions generator/metadata/MicrosoftGraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20090,6 +20090,7 @@
<Property Name="requiredResourceAccess" Type="Collection(graph.requiredResourceAccess)" Nullable="false"/>
<Property Name="samlMetadataUrl" Type="Edm.String"/>
<Property Name="serviceManagementReference" Type="Edm.String"/>
<Property Name="servicePrincipalLockConfiguration" Type="graph.servicePrincipalLockConfiguration"/>
<Property Name="signInAudience" Type="Edm.String"/>
<Property Name="spa" Type="graph.spaApplication"/>
<Property Name="tags" Type="Collection(Edm.String)" Nullable="false"/>
Expand Down Expand Up @@ -20194,6 +20195,13 @@
<Property Name="resourceAccess" Type="Collection(graph.resourceAccess)" Nullable="false"/>
<Property Name="resourceAppId" Type="Edm.String" Nullable="false"/>
</ComplexType>
<ComplexType Name="servicePrincipalLockConfiguration">
<Property Name="allProperties" Type="Edm.Boolean"/>
<Property Name="credentialsWithUsageSign" Type="Edm.Boolean"/>
<Property Name="credentialsWithUsageVerify" Type="Edm.Boolean"/>
<Property Name="isEnabled" Type="Edm.Boolean" Nullable="false"/>
<Property Name="tokenEncryptionKeyId" Type="Edm.Boolean"/>
</ComplexType>
<ComplexType Name="spaApplication">
<Property Name="redirectUris" Type="Collection(Edm.String)" Nullable="false"/>
</ComplexType>
Expand Down Expand Up @@ -24548,6 +24556,11 @@
<Property Name="displayName" Type="Edm.String"/>
<Property Name="languageTag" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="commentAction">
<Property Name="isReply" Type="Edm.Boolean"/>
<Property Name="parentAuthor" Type="graph.identitySet"/>
<Property Name="participants" Type="Collection(graph.identitySet)"/>
</ComplexType>
<ComplexType Name="contentApprovalStatusColumn"/>
<ComplexType Name="contentTypeInfo">
<Property Name="id" Type="Edm.String"/>
Expand All @@ -24557,6 +24570,7 @@
<Property Name="default" Type="Edm.Boolean"/>
<Property Name="position" Type="Edm.Int32"/>
</ComplexType>
<ComplexType Name="createAction"/>
<ComplexType Name="currencyColumn">
<Property Name="locale" Type="Edm.String"/>
</ComplexType>
Expand All @@ -24568,6 +24582,10 @@
<Property Name="formula" Type="Edm.String"/>
<Property Name="value" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="deleteAction">
<Property Name="name" Type="Edm.String"/>
<Property Name="objectType" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="documentSet">
<Property Name="allowedContentTypes" Type="Collection(graph.contentTypeInfo)"/>
<Property Name="defaultContents" Type="Collection(graph.documentSetContent)"/>
Expand Down Expand Up @@ -24598,6 +24616,7 @@
<Property Name="email" Type="Edm.String"/>
<Property Name="objectId" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="editAction"/>
<ComplexType Name="extractSensitivityLabelsResult">
<Property Name="labels" Type="Collection(graph.sensitivityLabelAssignment)"/>
</ComplexType>
Expand Down Expand Up @@ -24651,6 +24670,13 @@
<Property Name="listId" Type="Edm.String"/>
<Property Name="primaryLookupColumnId" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="mentionAction">
<Property Name="mentionees" Type="Collection(graph.identitySet)"/>
</ComplexType>
<ComplexType Name="moveAction">
<Property Name="from" Type="Edm.String"/>
<Property Name="to" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="numberColumn">
<Property Name="decimalPlaces" Type="Edm.String"/>
<Property Name="displayAs" Type="Edm.String"/>
Expand All @@ -24668,6 +24694,14 @@
<ComplexType Name="storagePlanInformation">
<Property Name="upgradeAvailable" Type="Edm.Boolean"/>
</ComplexType>
<ComplexType Name="renameAction">
<Property Name="newName" Type="Edm.String"/>
<Property Name="oldName" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="restoreAction"/>
<ComplexType Name="shareAction">
<Property Name="recipients" Type="Collection(graph.identitySet)"/>
</ComplexType>
<ComplexType Name="sharePointIdentity" BaseType="graph.identity" OpenType="true">
<Property Name="loginName" Type="Edm.String"/>
</ComplexType>
Expand Down Expand Up @@ -24711,6 +24745,9 @@
<Property Name="width" Type="Edm.Int32"/>
</ComplexType>
<ComplexType Name="thumbnailColumn"/>
<ComplexType Name="versionAction">
<Property Name="newVersion" Type="Edm.String"/>
</ComplexType>
<EntityType Name="columnLink" BaseType="graph.entity">
<Property Name="name" Type="Edm.String"/>
</EntityType>
Expand Down
3 changes: 3 additions & 0 deletions office365/communications/onlinemeetings/provider_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ def __init__(self):
pass

unknown = 0

skypeForBusiness = 1

skypeForConsumer = 2

teamsForBusiness = 3
16 changes: 16 additions & 0 deletions office365/directory/insights/usage_details.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from datetime import datetime

from office365.runtime.client_value import ClientValue


class UsageDetails(ClientValue):
"""Complex type containing properties of Used items. Information on when the resource was last accessed (viewed)
or modified (edited) by the user."""

def __init__(self, last_accessed_datetime=None, last_modified_datetime=None):
"""
:param datetime.datetime last_accessed_datetime: The date and time the resource was last accessed by the user.
:param datetime.datetime last_modified_datetime: The date and time the resource was last modified by the user.
"""
self.lastAccessedDateTime = last_accessed_datetime
self.lastModifiedDateTime = last_modified_datetime
7 changes: 7 additions & 0 deletions office365/directory/insights/used.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from office365.directory.insights.resource_reference import ResourceReference
from office365.directory.insights.usage_details import UsageDetails
from office365.entity import Entity
from office365.runtime.paths.resource_path import ResourcePath

Expand All @@ -11,6 +12,11 @@ class UsedInsight(Entity):
SharePoint
"""

@property
def last_used(self):
"""Information about when the item was last viewed or modified by the user."""
return self.properties.get("lastUsed", UsageDetails())

@property
def resource_reference(self):
"""Reference properties of the used document, such as the url and type of the document. Read-only"""
Expand All @@ -26,6 +32,7 @@ def resource(self):
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"lastUsed": self.last_used,
"resourceReference": self.resource_reference
}
default_value = property_mapping.get(name, None)
Expand Down
38 changes: 37 additions & 1 deletion office365/directory/security/incidents/incident.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from datetime import datetime

from office365.directory.security.alerts.alert import Alert
from office365.directory.security.alerts.comment import AlertComment
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.runtime.client_value_collection import ClientValueCollection
from office365.runtime.paths.resource_path import ResourcePath


Expand All @@ -19,13 +23,45 @@ class Incident(Entity):

@property
def assigned_to(self):
"""Owner of the incident, or null if no owner is assigned. Free editable text.
"""
Owner of the incident, or null if no owner is assigned. Free editable text.
:rtype: str or None
"""
return self.properties.get("assignedTo", None)

@property
def classification(self):
"""
The specification for the incident.
Possible values are: unknown, falsePositive, truePositive, informationalExpectedActivity, unknownFutureValue.
:rtype: str or None
"""
return self.properties.get("classification", None)

@property
def comments(self):
"""
Array of comments created by the Security Operations (SecOps) team when the incident is managed.
"""
return self.properties.get("comments", ClientValueCollection(AlertComment))

@property
def created_datetime(self):
"""
Time when the incident was first created.
"""
return self.properties("createdDateTime", datetime.min)

@property
def alerts(self):
"""The list of related alerts. Supports $expand."""
return self.properties.get('alerts',
EntityCollection(self.context, Alert, ResourcePath("alerts", self.resource_path)))

def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"createdDateTime": self.created_datetime
}
default_value = property_mapping.get(name, None)
return super(Incident, self).get_property(name, default_value)
Empty file.
6 changes: 6 additions & 0 deletions office365/intune/devices/compliance/policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from office365.entity import Entity


class DeviceCompliancePolicy(Entity):
"""This is the base class for Compliance policy. Compliance policies are platform specific and individual
per-platform compliance policies inherit from here"""
5 changes: 5 additions & 0 deletions office365/intune/devices/compliance/policy_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.entity import Entity


class DeviceCompliancePolicyState(Entity):
"""Device Compliance Policy State for a given device"""
31 changes: 28 additions & 3 deletions office365/intune/devices/managed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.intune.devices.category import DeviceCategory
from office365.intune.devices.compliance.policy_state import DeviceCompliancePolicyState
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery

Expand All @@ -13,11 +15,23 @@ def locate_device(self):
self.context.add_query(qry)
return self

@property
def activation_lock_bypass_code(self):
"""
The code that allows the Activation Lock on managed device to be bypassed. Default,
is Null (Non-Default property) for this property when returned as part of managedDevice entity in LIST call.
To retrieve actual values GET call needs to be made, with device id and included in select parameter.
Supports: $select. $Search is not supported. Read-only. This property is read-only.
:rtype: str
"""
return self.properties.get("activationLockBypassCode", None)

@property
def device_category(self):
""" Device category"""
return self.properties.get('deviceCategory', DeviceCategory(self.context,
ResourcePath("deviceCategory", self.resource_path)))
return self.properties.get('deviceCategory',
DeviceCategory(self.context,
ResourcePath("deviceCategory", self.resource_path)))

@property
def manufacturer(self):
Expand All @@ -35,6 +49,16 @@ def operating_system(self):
"""
return self.properties.get("operatingSystem", None)

@property
def device_compliance_policy_states(self):
"""
Device compliance policy states for this device
"""
return self.properties.get('deviceCompliancePolicyStates',
EntityCollection(self.context, DeviceCompliancePolicyState,
ResourcePath("deviceCompliancePolicyStates",
self.resource_path)))

@property
def users(self):
"""The primary users associated with the managed device."""
Expand All @@ -44,7 +68,8 @@ def users(self):
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"deviceCategory": self.device_category
"deviceCategory": self.device_category,
"deviceCompliancePolicyStates": self.device_compliance_policy_states
}
default_value = property_mapping.get(name, None)
return super(ManagedDevice, self).get_property(name, default_value)
8 changes: 8 additions & 0 deletions office365/intune/devices/management/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from office365.intune.devices.category import DeviceCategory
from office365.intune.devices.enrollment.configuration import DeviceEnrollmentConfiguration
from office365.intune.devices.managed import ManagedDevice
from office365.intune.devices.management.reports.reports import DeviceManagementReports
from office365.runtime.paths.resource_path import ResourcePath


Expand Down Expand Up @@ -43,6 +44,13 @@ def managed_devices(self):
EntityCollection(self.context, ManagedDevice,
ResourcePath("managedDevices", self.resource_path)))

@property
def reports(self):
""""""
return self.properties.get("reports",
DeviceManagementReports(self.context,
ResourcePath("reports", self.resource_path)))

def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions office365/intune/devices/management/reports/reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.entity import Entity


class DeviceManagementReports(Entity):
"""Device management reports entity"""
13 changes: 13 additions & 0 deletions office365/intune/devices/management/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@

class DeviceManagementSettings(ClientValue):
""""""

def __init__(self, device_compliance_checkin_threshold_days=None, is_scheduled_action_enabled=None,
secure_by_default=None):
"""
:param int device_compliance_checkin_threshold_days: The number of days a device is allowed to go without
checking in to remain compliant.
:param bool is_scheduled_action_enabled: Is feature enabled or not for scheduled action for rule.
:param bool secure_by_default: Device should be noncompliant when there is no compliance policy targeted when
this is true
"""
self.deviceComplianceCheckinThresholdDays = device_compliance_checkin_threshold_days
self.isScheduledActionEnabled = is_scheduled_action_enabled
self.secureByDefault = secure_by_default
Loading

0 comments on commit 343a0a4

Please sign in to comment.