Skip to content

Commit 2a5050f

Browse files
committed
More formatting
1 parent e5483db commit 2a5050f

9 files changed

+217
-275
lines changed

samples/use_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
from ms_graph.client import MicrosoftGraphClient
44

55
scopes = [
6-
'Calendars.ReadWrite',
7-
'Files.ReadWrite.All',
8-
'User.ReadWrite.All',
9-
'Notes.ReadWrite.All',
10-
'Directory.ReadWrite.All',
11-
'User.Read.All',
12-
'Directory.Read.All',
13-
'Directory.ReadWrite.All'
6+
"Calendars.ReadWrite",
7+
"Files.ReadWrite.All",
8+
"User.ReadWrite.All",
9+
"Notes.ReadWrite.All",
10+
"Directory.ReadWrite.All",
11+
"User.Read.All",
12+
"Directory.Read.All",
13+
"Directory.ReadWrite.All",
1414
]
1515

1616
# Initialize the Parser.
1717
config = ConfigParser()
1818

1919
# Read the file.
20-
config.read('config/config.ini')
20+
config.read("config/config.ini")
2121

2222
# Get the specified credentials.
23-
client_id = config.get('graph_api', 'client_id')
24-
client_secret = config.get('graph_api', 'client_secret')
25-
redirect_uri = config.get('graph_api', 'redirect_uri')
23+
client_id = config.get("graph_api", "client_id")
24+
client_secret = config.get("graph_api", "client_secret")
25+
redirect_uri = config.get("graph_api", "redirect_uri")
2626

2727
# Initialize the Client.
2828
graph_client = MicrosoftGraphClient(
2929
client_id=client_id,
3030
client_secret=client_secret,
3131
redirect_uri=redirect_uri,
3232
scope=scopes,
33-
credentials='configs/ms_graph_state.jsonc'
33+
credentials="configs/ms_graph_state.jsonc",
3434
)
3535

3636
# Login to the Client.

samples/use_drive_services.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
from ms_graph.client import MicrosoftGraphClient
44

55
scopes = [
6-
'Calendars.ReadWrite',
7-
'Files.ReadWrite.All',
8-
'User.ReadWrite.All',
9-
'Notes.ReadWrite.All',
10-
'Directory.ReadWrite.All',
11-
'User.Read.All',
12-
'Directory.Read.All',
13-
'Directory.ReadWrite.All'
6+
"Calendars.ReadWrite",
7+
"Files.ReadWrite.All",
8+
"User.ReadWrite.All",
9+
"Notes.ReadWrite.All",
10+
"Directory.ReadWrite.All",
11+
"User.Read.All",
12+
"Directory.Read.All",
13+
"Directory.ReadWrite.All"
1414
]
1515

1616
# Initialize the Parser.
1717
config = ConfigParser()
1818

1919
# Read the file.
20-
config.read('config/config.ini')
20+
config.read("config/config.ini")
2121

2222
# Get the specified credentials.
23-
client_id = config.get('graph_api', 'client_id')
24-
client_secret = config.get('graph_api', 'client_secret')
25-
redirect_uri = config.get('graph_api', 'redirect_uri')
23+
client_id = config.get("graph_api", "client_id")
24+
client_secret = config.get("graph_api", "client_secret")
25+
redirect_uri = config.get("graph_api", "redirect_uri")
2626

2727
# Initialize the Client.
2828
graph_client = MicrosoftGraphClient(
2929
client_id=client_id,
3030
client_secret=client_secret,
3131
redirect_uri=redirect_uri,
3232
scope=scopes,
33-
credentials='config/ms_graph_state.jsonc'
33+
credentials="config/ms_graph_state.jsonc"
3434
)
3535

3636
# Login to the Client.
@@ -52,13 +52,13 @@
5252
pprint(drive_services.get_root_drive_followed())
5353

5454
# Grab a Drive by id.
55-
pprint(drive_services.get_drive_by_id(drive_id='8bc640c57cda25b6'))
55+
pprint(drive_services.get_drive_by_id(drive_id="8bc640c57cda25b6"))
5656

5757
# Grab MY Drives.
5858
pprint(drive_services.get_my_drives())
5959

6060
# Grab User Drives.
61-
pprint(drive_services.get_user_drives(user_id='8bc640c57cda25b6'))
61+
pprint(drive_services.get_user_drives(user_id="8bc640c57cda25b6"))
6262

6363
# Grab Group Drives.
64-
pprint(drive_services.get_user_drives(user_id='8bc640c57cda25b6'))
64+
pprint(drive_services.get_user_drives(user_id="8bc640c57cda25b6"))

samples/use_group_services.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44

55
# Define the Scopes needed to Login.
66
scopes = [
7-
'Calendars.ReadWrite',
8-
'Files.ReadWrite.All',
9-
'User.ReadWrite.All',
10-
'Notes.ReadWrite.All',
11-
'Directory.ReadWrite.All',
12-
'User.Read.All',
13-
'Directory.Read.All',
14-
'Directory.ReadWrite.All',
15-
'Group.Read.All',
16-
'Group.ReadWrite.All'
7+
"Calendars.ReadWrite",
8+
"Files.ReadWrite.All",
9+
"User.ReadWrite.All",
10+
"Notes.ReadWrite.All",
11+
"Directory.ReadWrite.All",
12+
"User.Read.All",
13+
"Directory.Read.All",
14+
"Directory.ReadWrite.All",
15+
"Group.Read.All",
16+
"Group.ReadWrite.All",
1717
]
1818

1919
# Initialize the Parser.
2020
config = ConfigParser()
2121

2222
# Read the file.
23-
config.read('configs/config.ini')
23+
config.read("configs/config.ini")
2424

2525
# Get the specified credentials.
26-
client_id = config.get('graph_api', 'client_id')
27-
client_secret = config.get('graph_api', 'client_secret')
28-
redirect_uri = config.get('graph_api', 'redirect_uri')
26+
client_id = config.get("graph_api", "client_id")
27+
client_secret = config.get("graph_api", "client_secret")
28+
redirect_uri = config.get("graph_api", "redirect_uri")
2929

3030
# Initialize the Client.
3131
graph_client = MicrosoftGraphClient(
3232
client_id=client_id,
3333
client_secret=client_secret,
3434
redirect_uri=redirect_uri,
3535
scope=scopes,
36-
credentials='configs/ms_graph_state.jsonc'
36+
credentials="configs/ms_graph_state.jsonc",
3737
)
3838

3939
# Login to the Client.

samples/use_mail_services.py

Lines changed: 54 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4,170 +4,138 @@
44

55
# SCOPES NEEDED:
66
# ---------------
7-
# 'Mail.Send',
8-
# 'MailboxSettings.Read',
9-
# 'MailboxSettings.ReadWrite'
7+
# "Mail.Send",
8+
# "MailboxSettings.Read",
9+
# "MailboxSettings.ReadWrite"
1010

1111
# Define the Scopes needed to Login.
1212
scopes = [
13-
'Calendars.ReadWrite',
14-
'Files.ReadWrite.All',
15-
'User.ReadWrite.All',
16-
'Notes.ReadWrite.All',
17-
'Directory.ReadWrite.All',
18-
'User.Read.All',
19-
'Directory.Read.All',
20-
'Directory.ReadWrite.All',
21-
'Group.Read.All',
22-
'Group.ReadWrite.All',
23-
'Notes.Create',
24-
'Notes.Read',
25-
'Notes.ReadWrite',
26-
'Notes.Read.All',
27-
'Notes.ReadWrite.All',
28-
'Mail.Send',
29-
'MailboxSettings.Read',
30-
'MailboxSettings.ReadWrite'
13+
"Calendars.ReadWrite",
14+
"Files.ReadWrite.All",
15+
"User.ReadWrite.All",
16+
"Notes.ReadWrite.All",
17+
"Directory.ReadWrite.All",
18+
"User.Read.All",
19+
"Directory.Read.All",
20+
"Directory.ReadWrite.All",
21+
"Group.Read.All",
22+
"Group.ReadWrite.All",
23+
"Notes.Create",
24+
"Notes.Read",
25+
"Notes.ReadWrite",
26+
"Notes.Read.All",
27+
"Notes.ReadWrite.All",
28+
"Mail.Send",
29+
"MailboxSettings.Read",
30+
"MailboxSettings.ReadWrite",
3131
]
3232

3333
# Initialize the Parser.
3434
config = ConfigParser()
3535

3636
# Read the file.
37-
config.read('configs/config.ini')
37+
config.read("configs/config.ini")
3838

3939
# Get the specified credentials.
40-
client_id = config.get('graph_api', 'client_id')
41-
client_secret = config.get('graph_api', 'client_secret')
42-
redirect_uri = config.get('graph_api', 'redirect_uri')
40+
client_id = config.get("graph_api", "client_id")
41+
client_secret = config.get("graph_api", "client_secret")
42+
redirect_uri = config.get("graph_api", "redirect_uri")
4343

4444
# Initialize the Client.
4545
graph_client = MicrosoftGraphClient(
4646
client_id=client_id,
4747
client_secret=client_secret,
4848
redirect_uri=redirect_uri,
4949
scope=scopes,
50-
credentials='configs/ms_graph_state.jsonc'
50+
credentials="configs/ms_graph_state.jsonc",
5151
)
5252

5353
# Login to the Client.
5454
graph_client.login()
5555

5656
# Define a valid User ID.
57-
USER_ID = '8bc640c57cda25b6'
57+
USER_ID = "8bc640c57cda25b6"
5858

5959
# Define a mail Item ID.
60-
MAIL_ID = 'AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgBGAAADpjqwNb_dak68rN7703u' + \
61-
'ffQcAFNKsLOjbGUuHHmYnyKdJiAAAAgEhAAAAFNKsLOjbGUuHHmYnyKdJiAAFBMTneQ' + \
62-
'AAAA=='
60+
MAIL_ID = (
61+
"AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgBGAAADpjqwNb_dak68rN7703u"
62+
+ "ffQcAFNKsLOjbGUuHHmYnyKdJiAAAAgEhAAAAFNKsLOjbGUuHHmYnyKdJiAAFBMTneQ"
63+
+ "AAAA=="
64+
)
6365

6466
# Define a mail item ID with Attachments.
65-
MAIL_ID_ATTACHMENTS = 'AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgBGAAADpjqwNb+' + \
66-
'dak68rN7703uffQcAFNKsLOjbGUuHHmYnyKdJiAAAAgEMAAAAFNKsLO' + \
67-
'jbGUuHHmYnyKdJiAAE9ucV+AAAAA=='
67+
MAIL_ID_ATTACHMENTS = (
68+
"AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgBGAAADpjqwNb+"
69+
+ "dak68rN7703uffQcAFNKsLOjbGUuHHmYnyKdJiAAAAgEMAAAAFNKsLO"
70+
+ "jbGUuHHmYnyKdJiAAE9ucV+AAAAA=="
71+
)
6872

6973
# Grab the Notes Services.
7074
mail_services = graph_client.mail()
7175

7276
# Grab all my Messages.
73-
pprint(
74-
mail_services.list_my_messages()
75-
)
77+
pprint(mail_services.list_my_messages())
7678

7779
# Grab a specific message for the default user.
78-
pprint(
79-
mail_services.get_my_messages(
80-
message_id=MAIL_ID
81-
)
82-
)
80+
pprint(mail_services.get_my_messages(message_id=MAIL_ID))
8381

84-
# Get a Specific User's Message.
85-
pprint(
86-
mail_services.get_user_messages(
87-
user_id=USER_ID,
88-
message_id=MAIL_ID
89-
)
90-
)
82+
# Get a Specific User"s Message.
83+
pprint(mail_services.get_user_messages(user_id=USER_ID, message_id=MAIL_ID))
9184

9285
# List the rules for a specific user..
93-
pprint(
94-
mail_services.list_rules(user_id=USER_ID)
95-
)
86+
pprint(mail_services.list_rules(user_id=USER_ID))
9687

9788
# List the rules for the default user.
98-
pprint(
99-
mail_services.list_my_rules()
100-
)
89+
pprint(mail_services.list_my_rules())
10190

10291
# List the overrides for a specific user.
103-
pprint(
104-
mail_services.list_overrides(user_id=USER_ID)
105-
)
92+
pprint(mail_services.list_overrides(user_id=USER_ID))
10693

10794
# List the overrides for the default user.
108-
pprint(
109-
mail_services.list_my_overrides()
110-
)
95+
pprint(mail_services.list_my_overrides())
11196

11297
# List the attachments for a specific message.
113-
pprint(
114-
mail_services.list_my_attachements(
115-
message_id=MAIL_ID_ATTACHMENTS
116-
)
117-
)
98+
pprint(mail_services.list_my_attachements(message_id=MAIL_ID_ATTACHMENTS))
11899

119100

120101
# Create a new message for the default user. Keep in mind this does not send the mail.
121102
new_message_draft = mail_services.create_my_message(
122103
message={
123104
"subject": "Did you see last night's game?",
124105
"importance": "Low",
125-
"body": {
126-
"contentType": "HTML",
127-
"content": "They were <b>awesome</b>!"
128-
},
129-
"toRecipients": [
130-
{
131-
"emailAddress": {
132-
"address": "[email protected]"
133-
}
134-
}
135-
]
106+
"body": {"contentType": "HTML", "content": "They were <b>awesome</b>!"},
107+
"toRecipients": [{"emailAddress": {"address": "[email protected]"}}],
136108
}
137109
)
138110

139111
# Check it out.
140112
pprint(new_message_draft)
141113

142114
# grab the ID.
143-
new_message_id = new_message_draft['id']
115+
new_message_id = new_message_draft["id"]
144116

145117
# Send the newly created message.
146118
mail_services.send_my_message(message_id=new_message_id)
147119

148-
# Let's create a new message rule, this will help with things like incoming mail. We can
120+
# Let"s create a new message rule, this will help with things like incoming mail. We can
149121
# control what happens to mail that meets certain conditions.
150122
my_new_message_rule = mail_services.create_my_message_rule(
151123
rule={
152124
"displayName": "From partner",
153125
"sequence": 2,
154126
"isEnabled": True,
155-
"conditions": {
156-
"senderContains": [
157-
"youtube"
158-
]
159-
},
127+
"conditions": {"senderContains": ["youtube"]},
160128
"actions": {
161129
"forwardTo": [
162130
{
163131
"emailAddress": {
164132
"name": "Alex Reed",
165-
"address": "[email protected]"
133+
"address": "[email protected]",
166134
}
167135
}
168136
],
169-
"stopProcessingRules": True
170-
}
137+
"stopProcessingRules": True,
138+
},
171139
}
172140
)
173141

0 commit comments

Comments
 (0)