Skip to content

Commit 4b62b64

Browse files
committed
typings improvements for Outlook and OneDrive APIs, examples updates
1 parent 476b170 commit 4b62b64

File tree

38 files changed

+202
-95
lines changed

38 files changed

+202
-95
lines changed

examples/onedrive/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def ensure_workbook_sample(graph_client):
2121
except ClientRequestException as e:
2222
if e.response.status_code == 404:
2323
local_path = "../../data/Financial Sample.xlsx"
24-
target_file = graph_client.me.drive.root.upload(local_path).execute_query()
25-
print(f"File {target_file.web_url} has been uploaded")
24+
target_file = graph_client.me.drive.root.upload_file(
25+
local_path
26+
).execute_query()
27+
print("File {0} has been uploaded".format(target_file.web_url))
2628
return target_file.workbook
2729
else:
2830
raise ValueError(e.response.text)

examples/onedrive/columns/create_lookup.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,11 @@
88
from tests import create_unique_name
99
from tests.graph_case import acquire_token_by_username_password
1010

11-
12-
def clean_up(columns):
13-
"""
14-
:type columns: list[office365.onedrive.columns.definition.ColumnDefinition]
15-
"""
16-
[column.delete_object().execute_query() for column in columns]
17-
18-
1911
client = GraphClient(acquire_token_by_username_password)
20-
lib = client.sites.root.lists["Docs"]
12+
lib = client.sites.root.lists["Documents"]
2113

2214
column_name = create_unique_name("LookupColumn")
2315
lookup_column = lib.columns.add_lookup(column_name, lib).execute_query()
2416
print(lookup_column.display_name)
2517

26-
clean_up([lookup_column])
18+
lookup_column.delete_object().execute_query() # clean up

examples/onedrive/files/list_shared_with_me.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""
22
Retrieves a collection of DriveItem resources that have been shared with the current user
3+
4+
https://learn.microsoft.com/en-us/graph/api/drive-sharedwithme?view=graph-rest-1.0
35
"""
46
from office365.graph_client import GraphClient
57
from tests.graph_case import acquire_token_by_username_password

examples/onedrive/files/share_invitation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
https://learn.microsoft.com/en-us/graph/api/driveitem-invite?view=graph-rest-1.0
88
"""
9-
import json
109
from datetime import datetime, timedelta
1110

11+
from examples import upload_sample_files
1212
from office365.graph_client import GraphClient
1313
from tests.graph_case import acquire_token_by_username_password
1414

@@ -24,4 +24,5 @@
2424
expiration_datetime=None,
2525
password="password123",
2626
).execute_query()
27-
print(json.dumps(permissions.to_json(), indent=4))
27+
for perm in permissions:
28+
print(perm.granted_to_identities)

examples/onedrive/sites/get_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
List root sites across geographies in an organization.
33
4-
https://learn.microsoft.com/en-us/graph/api/site-getallsites?view=graph-rest-1.0&tabs=http
4+
https://learn.microsoft.com/en-us/graph/api/site-getallsites?view=graph-rest-1.0
55
"""
66
from office365.graph_client import GraphClient
77
from tests.graph_case import acquire_token_by_client_credentials

examples/onedrive/sites/grant_permission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Grant permissions on a site.
33
4-
https://learn.microsoft.com/en-us/graph/api/site-post-permissions?view=graph-rest-1.0&tabs=http
4+
https://learn.microsoft.com/en-us/graph/api/site-post-permissions?view=graph-rest-1.0
55
"""
66
import json
77

examples/onedrive/sites/list_permissions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
List site permissions
3-
https://learn.microsoft.com/en-us/graph/api/site-list-permissions?view=graph-rest-1.0&tabs=http
3+
https://learn.microsoft.com/en-us/graph/api/site-list-permissions?view=graph-rest-1.0
44
"""
55

66
from office365.graph_client import GraphClient
@@ -12,4 +12,4 @@
1212
client.sites.get_by_url(test_team_site_url).permissions.get().execute_query()
1313
)
1414
for perm in permissions:
15-
print(perm)
15+
print(perm.granted_to)

examples/outlook/calendars/list_my.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
client = GraphClient(acquire_token_by_username_password)
1010
calendars = client.me.calendars.top(10).get().execute_query()
1111
for cal in calendars:
12-
print(cal.name)
12+
print(cal)

examples/outlook/events/list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
https://learn.microsoft.com/en-us/graph/api/calendar-list-events?view=graph-rest-1.0
55
"""
66
from office365.graph_client import GraphClient
7-
from office365.outlook.calendar.events.event import Event
87
from tests.graph_case import acquire_token_by_username_password
98

109
client = GraphClient(acquire_token_by_username_password)
11-
events = client.me.calendar.events.get_all().select(["subject", "body"]).execute_query()
10+
events = (
11+
client.me.calendar.events.get().top(100).select(["subject", "body"]).execute_query()
12+
)
1213
for event in events:
1314
print(event.subject)

generator/metadata/MicrosoftGraph.xml

Lines changed: 77 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14985,10 +14985,10 @@
1498514985
<Annotations Target="microsoft.graph.schedulingGroup/isActive">
1498614986
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
1498714987
</Annotations>
14988-
<Annotations Target="microsoft.graph.security.host">
14988+
<Annotations Target="microsoft.graph.security.hostComponent">
1498914989
<Annotation Term="Org.OData.Capabilities.V1.CountRestrictions">
1499014990
<Record>
14991-
<PropertyValue Property="Countable" Bool="false"/>
14991+
<PropertyValue Property="Countable" Bool="true"/>
1499214992
</Record>
1499314993
</Annotation>
1499414994
<Annotation Term="Org.OData.Capabilities.V1.ExpandRestrictions">
@@ -15011,18 +15011,13 @@
1501115011
<PropertyValue Property="Selectable" Bool="true"/>
1501215012
</Record>
1501315013
</Annotation>
15014-
<Annotation Term="Org.OData.Capabilities.V1.SkipSupported" Bool="false"/>
15015-
<Annotation Term="Org.OData.Capabilities.V1.SortRestrictions">
15016-
<Record>
15017-
<PropertyValue Property="Sortable" Bool="false"/>
15018-
</Record>
15019-
</Annotation>
15020-
<Annotation Term="Org.OData.Capabilities.V1.TopSupported" Bool="false"/>
15014+
<Annotation Term="Org.OData.Capabilities.V1.SkipSupported" Bool="true"/>
15015+
<Annotation Term="Org.OData.Capabilities.V1.TopSupported" Bool="true"/>
1502115016
</Annotations>
15022-
<Annotations Target="microsoft.graph.security.article">
15017+
<Annotations Target="microsoft.graph.security.host">
1502315018
<Annotation Term="Org.OData.Capabilities.V1.CountRestrictions">
1502415019
<Record>
15025-
<PropertyValue Property="Countable" Bool="true"/>
15020+
<PropertyValue Property="Countable" Bool="false"/>
1502615021
</Record>
1502715022
</Annotation>
1502815023
<Annotation Term="Org.OData.Capabilities.V1.ExpandRestrictions">
@@ -15037,23 +15032,23 @@
1503715032
</Annotation>
1503815033
<Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions">
1503915034
<Record>
15040-
<PropertyValue Property="Searchable" Bool="true"/>
15035+
<PropertyValue Property="Searchable" Bool="false"/>
1504115036
</Record>
1504215037
</Annotation>
1504315038
<Annotation Term="Org.OData.Capabilities.V1.SelectRestrictions">
1504415039
<Record>
1504515040
<PropertyValue Property="Selectable" Bool="true"/>
1504615041
</Record>
1504715042
</Annotation>
15048-
<Annotation Term="Org.OData.Capabilities.V1.SkipSupported" Bool="true"/>
15043+
<Annotation Term="Org.OData.Capabilities.V1.SkipSupported" Bool="false"/>
1504915044
<Annotation Term="Org.OData.Capabilities.V1.SortRestrictions">
1505015045
<Record>
1505115046
<PropertyValue Property="Sortable" Bool="false"/>
1505215047
</Record>
1505315048
</Annotation>
15054-
<Annotation Term="Org.OData.Capabilities.V1.TopSupported" Bool="true"/>
15049+
<Annotation Term="Org.OData.Capabilities.V1.TopSupported" Bool="false"/>
1505515050
</Annotations>
15056-
<Annotations Target="microsoft.graph.security.articleIndicator">
15051+
<Annotations Target="microsoft.graph.security.article">
1505715052
<Annotation Term="Org.OData.Capabilities.V1.CountRestrictions">
1505815053
<Record>
1505915054
<PropertyValue Property="Countable" Bool="true"/>
@@ -15071,7 +15066,7 @@
1507115066
</Annotation>
1507215067
<Annotation Term="Org.OData.Capabilities.V1.SearchRestrictions">
1507315068
<Record>
15074-
<PropertyValue Property="Searchable" Bool="false"/>
15069+
<PropertyValue Property="Searchable" Bool="true"/>
1507515070
</Record>
1507615071
</Annotation>
1507715072
<Annotation Term="Org.OData.Capabilities.V1.SelectRestrictions">
@@ -15080,9 +15075,14 @@
1508015075
</Record>
1508115076
</Annotation>
1508215077
<Annotation Term="Org.OData.Capabilities.V1.SkipSupported" Bool="true"/>
15078+
<Annotation Term="Org.OData.Capabilities.V1.SortRestrictions">
15079+
<Record>
15080+
<PropertyValue Property="Sortable" Bool="false"/>
15081+
</Record>
15082+
</Annotation>
1508315083
<Annotation Term="Org.OData.Capabilities.V1.TopSupported" Bool="true"/>
1508415084
</Annotations>
15085-
<Annotations Target="microsoft.graph.security.hostComponent">
15085+
<Annotations Target="microsoft.graph.security.articleIndicator">
1508615086
<Annotation Term="Org.OData.Capabilities.V1.CountRestrictions">
1508715087
<Record>
1508815088
<PropertyValue Property="Countable" Bool="true"/>
@@ -37265,6 +37265,17 @@
3726537265
<Member Name="appGovernanceDetection" Value="2097152"/>
3726637266
<Member Name="unknownFutureValue" Value="4194303"/>
3726737267
<Member Name="microsoftDefenderForCloud" Value="4194304"/>
37268+
<Member Name="microsoftDefenderForIoT" Value="1073741833"/>
37269+
<Member Name="microsoftDefenderForServers" Value="1073741834"/>
37270+
<Member Name="microsoftDefenderForStorage" Value="1073741835"/>
37271+
<Member Name="microsoftDefenderForDNS" Value="1073741836"/>
37272+
<Member Name="microsoftDefenderForDatabases" Value="1073741837"/>
37273+
<Member Name="microsoftDefenderForContainers" Value="1073741838"/>
37274+
<Member Name="microsoftDefenderForNetwork" Value="1073741839"/>
37275+
<Member Name="microsoftDefenderForAppService" Value="1073741840"/>
37276+
<Member Name="microsoftDefenderForKeyVault" Value="1073741841"/>
37277+
<Member Name="microsoftDefenderForResourceManager" Value="1073741842"/>
37278+
<Member Name="microsoftDefenderForApiManagement" Value="1073741843"/>
3726837279
<Member Name="nrtAlerts" Value="1073741844"/>
3726937280
<Member Name="scheduledAlerts" Value="1073741845"/>
3727037281
<Member Name="microsoftDefenderThreatIntelligenceAnalytics" Value="1073741846"/>
@@ -37424,6 +37435,17 @@
3742437435
<Member Name="markdown" Value="2"/>
3742537436
<Member Name="unknownFutureValue" Value="3"/>
3742637437
</EnumType>
37438+
<EnumType Name="hostPortProtocol">
37439+
<Member Name="tcp" Value="0"/>
37440+
<Member Name="udp" Value="1"/>
37441+
<Member Name="unknownFutureValue" Value="2"/>
37442+
</EnumType>
37443+
<EnumType Name="hostPortStatus">
37444+
<Member Name="open" Value="0"/>
37445+
<Member Name="filtered" Value="1"/>
37446+
<Member Name="closed" Value="2"/>
37447+
<Member Name="unknownFutureValue" Value="3"/>
37448+
</EnumType>
3742737449
<EnumType Name="hostReputationClassification">
3742837450
<Member Name="unknown" Value="0"/>
3742937451
<Member Name="neutral" Value="1"/>
@@ -37532,6 +37554,7 @@
3753237554
<NavigationProperty Name="hostComponents" Type="Collection(microsoft.graph.security.hostComponent)" ContainsTarget="true"/>
3753337555
<NavigationProperty Name="hostCookies" Type="Collection(microsoft.graph.security.hostCookie)" ContainsTarget="true"/>
3753437556
<NavigationProperty Name="hostPairs" Type="Collection(microsoft.graph.security.hostPair)" ContainsTarget="true"/>
37557+
<NavigationProperty Name="hostPorts" Type="Collection(microsoft.graph.security.hostPort)" ContainsTarget="true"/>
3753537558
<NavigationProperty Name="hosts" Type="Collection(microsoft.graph.security.host)" ContainsTarget="true"/>
3753637559
<NavigationProperty Name="hostSslCertificates" Type="Collection(microsoft.graph.security.hostSslCertificate)" ContainsTarget="true"/>
3753737560
<NavigationProperty Name="hostTrackers" Type="Collection(microsoft.graph.security.hostTracker)" ContainsTarget="true"/>
@@ -38026,6 +38049,28 @@
3802638049
<Property Name="content" Type="Edm.String"/>
3802738050
<Property Name="format" Type="microsoft.graph.security.contentFormat"/>
3802838051
</ComplexType>
38052+
<ComplexType Name="hostPortBanner">
38053+
<Property Name="banner" Type="Edm.String" Nullable="false"/>
38054+
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset"/>
38055+
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset"/>
38056+
<Property Name="scanProtocol" Type="Edm.String"/>
38057+
<Property Name="timesObserved" Type="Edm.Int32"/>
38058+
</ComplexType>
38059+
<ComplexType Name="hostPortComponent">
38060+
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset"/>
38061+
<Property Name="isRecent" Type="Edm.Boolean"/>
38062+
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset"/>
38063+
<NavigationProperty Name="component" Type="microsoft.graph.security.hostComponent"/>
38064+
</ComplexType>
38065+
<EntityType Name="artifact" BaseType="graph.entity" Abstract="true"/>
38066+
<EntityType Name="hostComponent" BaseType="microsoft.graph.security.artifact">
38067+
<Property Name="category" Type="Edm.String"/>
38068+
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
38069+
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
38070+
<Property Name="name" Type="Edm.String" Nullable="false"/>
38071+
<Property Name="version" Type="Edm.String"/>
38072+
<NavigationProperty Name="host" Type="microsoft.graph.security.host" Nullable="false"/>
38073+
</EntityType>
3802938074
<ComplexType Name="hostReputationRule">
3803038075
<Property Name="description" Type="Edm.String" Nullable="false"/>
3803138076
<Property Name="name" Type="Edm.String" Nullable="false"/>
@@ -38069,7 +38114,6 @@
3806938114
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset"/>
3807038115
<NavigationProperty Name="host" Type="microsoft.graph.security.host" Nullable="false"/>
3807138116
</ComplexType>
38072-
<EntityType Name="artifact" BaseType="graph.entity" Abstract="true"/>
3807338117
<EntityType Name="host" BaseType="microsoft.graph.security.artifact" Abstract="true">
3807438118
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset"/>
3807538119
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset"/>
@@ -38080,6 +38124,7 @@
3808038124
<NavigationProperty Name="parentHostPairs" Type="Collection(microsoft.graph.security.hostPair)"/>
3808138125
<NavigationProperty Name="passiveDns" Type="Collection(microsoft.graph.security.passiveDnsRecord)"/>
3808238126
<NavigationProperty Name="passiveDnsReverse" Type="Collection(microsoft.graph.security.passiveDnsRecord)"/>
38127+
<NavigationProperty Name="ports" Type="Collection(microsoft.graph.security.hostPort)"/>
3808338128
<NavigationProperty Name="reputation" Type="microsoft.graph.security.hostReputation" ContainsTarget="true"/>
3808438129
<NavigationProperty Name="sslCertificates" Type="Collection(microsoft.graph.security.hostSslCertificate)"/>
3808538130
<NavigationProperty Name="subdomains" Type="Collection(microsoft.graph.security.subdomain)"/>
@@ -38109,14 +38154,6 @@
3810938154
<NavigationProperty Name="childHost" Type="microsoft.graph.security.host" Nullable="false"/>
3811038155
<NavigationProperty Name="parentHost" Type="microsoft.graph.security.host" Nullable="false"/>
3811138156
</EntityType>
38112-
<EntityType Name="hostComponent" BaseType="microsoft.graph.security.artifact">
38113-
<Property Name="category" Type="Edm.String"/>
38114-
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
38115-
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
38116-
<Property Name="name" Type="Edm.String" Nullable="false"/>
38117-
<Property Name="version" Type="Edm.String"/>
38118-
<NavigationProperty Name="host" Type="microsoft.graph.security.host" Nullable="false"/>
38119-
</EntityType>
3812038157
<EntityType Name="hostCookie" BaseType="microsoft.graph.security.artifact">
3812138158
<Property Name="domain" Type="Edm.String" Nullable="false"/>
3812238159
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
@@ -38132,6 +38169,19 @@
3813238169
<NavigationProperty Name="artifact" Type="microsoft.graph.security.artifact" Nullable="false"/>
3813338170
<NavigationProperty Name="parentHost" Type="microsoft.graph.security.host" Nullable="false"/>
3813438171
</EntityType>
38172+
<EntityType Name="hostPort" BaseType="graph.entity">
38173+
<Property Name="banners" Type="Collection(microsoft.graph.security.hostPortBanner)"/>
38174+
<Property Name="firstSeenDateTime" Type="Edm.DateTimeOffset"/>
38175+
<Property Name="lastScanDateTime" Type="Edm.DateTimeOffset"/>
38176+
<Property Name="lastSeenDateTime" Type="Edm.DateTimeOffset"/>
38177+
<Property Name="port" Type="Edm.Int32" Nullable="false"/>
38178+
<Property Name="protocol" Type="microsoft.graph.security.hostPortProtocol"/>
38179+
<Property Name="services" Type="Collection(microsoft.graph.security.hostPortComponent)"/>
38180+
<Property Name="status" Type="microsoft.graph.security.hostPortStatus"/>
38181+
<Property Name="timesObserved" Type="Edm.Int32"/>
38182+
<NavigationProperty Name="host" Type="microsoft.graph.security.host" Nullable="false"/>
38183+
<NavigationProperty Name="mostRecentSslCertificate" Type="microsoft.graph.security.sslCertificate"/>
38184+
</EntityType>
3813538185
<EntityType Name="hostReputation" BaseType="graph.entity">
3813638186
<Property Name="classification" Type="microsoft.graph.security.hostReputationClassification" Nullable="false"/>
3813738187
<Property Name="rules" Type="Collection(microsoft.graph.security.hostReputationRule)"/>
@@ -38926,6 +38976,7 @@
3892638976
<EntityType Name="externalConnection" BaseType="graph.entity">
3892738977
<Property Name="activitySettings" Type="microsoft.graph.externalConnectors.activitySettings"/>
3892838978
<Property Name="configuration" Type="microsoft.graph.externalConnectors.configuration"/>
38979+
<Property Name="connectorId" Type="Edm.String"/>
3892938980
<Property Name="description" Type="Edm.String"/>
3893038981
<Property Name="name" Type="Edm.String"/>
3893138982
<Property Name="searchSettings" Type="microsoft.graph.externalConnectors.searchSettings"/>

0 commit comments

Comments
 (0)