ms-graph 1.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ms_graph/mail.py ADDED
@@ -0,0 +1,1073 @@
1
+ from ms_graph.session import GraphSession
2
+
3
+
4
+ class Mail:
5
+
6
+ """
7
+ ## Overview:
8
+ ----
9
+ Microsoft Graph lets your app get authorized access to a user"s
10
+ Outlook mail data in a personal or organization account. With the
11
+ appropriate delegated or application mail permissions, your app can
12
+ access the mail data of the signed-in user or any user in a tenant.
13
+ """
14
+
15
+ def __init__(self, session: object) -> None:
16
+ """Initializes the `Mail` service.
17
+
18
+ ### Parameters
19
+ ----
20
+ session : object
21
+ An authenticated session for our Microsoft Graph Client.
22
+ """
23
+
24
+ # Set the session.
25
+ self.graph_session: GraphSession = session
26
+
27
+ # Set the endpoint.
28
+ self.endpoint = "mail"
29
+
30
+ def list_my_messages(self) -> dict:
31
+ """Get the messages in the signed-in user"s mailbox
32
+ (including the Deleted Items and Clutter folders).
33
+
34
+ ### Returns
35
+ ----
36
+ dict
37
+ If successful, this method returns a 200 OK response
38
+ code and collection of `Message` objects in the response
39
+ body.
40
+ """
41
+
42
+ content = self.graph_session.make_request(method="get", endpoint="/me/messages")
43
+
44
+ return content
45
+
46
+ def list_user_messages(self, user_id: str) -> dict:
47
+ """Get the messages in the user"s mailbox
48
+ (including the Deleted Items and Clutter folders).
49
+
50
+ ### Parameters
51
+ ----
52
+ user_id : str
53
+ The user for which to query messages for.
54
+
55
+ ### Returns
56
+ ----
57
+ dict
58
+ If successful, this method returns a 200 OK response
59
+ code and collection of `Message` objects in the response
60
+ body.
61
+ """
62
+
63
+ content = self.graph_session.make_request(
64
+ method="get", endpoint=f"/users/{user_id}/messages"
65
+ )
66
+
67
+ return content
68
+
69
+ def create_my_message(self, message: dict) -> dict:
70
+ """Use this API to create a draft of a new message.
71
+
72
+ ### Overview:
73
+ ----
74
+ Drafts can be created in any folder and optionally
75
+ updated before sending. To save to the Drafts folder,
76
+ use the /messages shortcut.
77
+
78
+ ### Parameters
79
+ ----
80
+ message : dict
81
+ A JSON payload with the required message
82
+ attributes.
83
+
84
+ ### Returns
85
+ ----
86
+ dict
87
+ If successful, this method returns 201 Created
88
+ response code and `message` object in the response
89
+ body.
90
+ """
91
+
92
+ content = self.graph_session.make_request(
93
+ method="post", endpoint="/me/messages", json=message
94
+ )
95
+
96
+ return content
97
+
98
+ def create_user_message(self, user_id: str, message: dict) -> dict:
99
+ """Use this API to create a draft of a new message for the specific
100
+ user ID.
101
+
102
+ ### Overview:
103
+ ----
104
+ Drafts can be created in any folder and optionally
105
+ updated before sending. To save to the Drafts folder,
106
+ use the /messages shortcut.
107
+
108
+ ### Parameters
109
+ ----
110
+ message : dict
111
+ A JSON payload with the required message
112
+ attributes.
113
+
114
+ ### Returns
115
+ ----
116
+ dict
117
+ If successful, this method returns 201 Created
118
+ response code and `message` object in the response
119
+ body.
120
+ """
121
+
122
+ content = self.graph_session.make_request(
123
+ method="post", endpoint=f"/users/{user_id}/messages", json=message
124
+ )
125
+
126
+ return content
127
+
128
+ def get_my_messages(self, message_id: str) -> dict:
129
+ """Retrieve the properties and relationships of a message object for
130
+ the default user.
131
+
132
+ ### Parameters
133
+ ----
134
+ message_id : str
135
+ The message ID you want to query.
136
+
137
+ ### Returns
138
+ ----
139
+ dict
140
+ If successful, this method returns 200 successful
141
+ response code and `message` object in the response
142
+ body.
143
+ """
144
+
145
+ content = self.graph_session.make_request(
146
+ method="get", endpoint=f"/me/messages/{message_id}"
147
+ )
148
+
149
+ return content
150
+
151
+ def get_user_messages(self, user_id: str, message_id: str) -> dict:
152
+ """Retrieve the properties and relationships of a message object for
153
+ a specific user.
154
+
155
+ ### Parameters
156
+ ----
157
+ user_id : str
158
+ The User ID you want to query messages for.
159
+
160
+ message_id : str
161
+ The message ID you want to query.
162
+
163
+ ### Returns
164
+ ----
165
+ dict
166
+ If successful, this method returns 200 successful
167
+ response code and `message` object in the response
168
+ body.
169
+ """
170
+
171
+ content = self.graph_session.make_request(
172
+ method="get", endpoint=f"/users/{user_id}/messages/{message_id}"
173
+ )
174
+
175
+ return content
176
+
177
+ def update_my_message(self, message: dict) -> dict:
178
+ """Update the properties of a message object for the
179
+ default user.
180
+
181
+ ### Parameters
182
+ ----
183
+ message : str
184
+ In the request body, supply the values for relevant
185
+ fields that should be updated.
186
+
187
+ ### Returns
188
+ ----
189
+ dict
190
+ If successful, this method returns a 200 OK response code
191
+ and updated `message` object in the response body.
192
+ """
193
+
194
+ content = self.graph_session.make_request(
195
+ method="patch", endpoint="/me/messages", json=message
196
+ )
197
+
198
+ return content
199
+
200
+ def update_user_message(self, user_id: str, message: dict) -> dict:
201
+ """Update the properties of a message object for the
202
+ specified user.
203
+
204
+ ### Parameters
205
+ ----
206
+ user_id : str
207
+ The user for which to update a message for.
208
+
209
+ message : str
210
+ In the request body, supply the values for relevant
211
+ fields that should be updated.
212
+
213
+ ### Returns
214
+ ----
215
+ dict
216
+ If successful, this method returns a 200 OK response code
217
+ and updated `message` object in the response body.
218
+ """
219
+
220
+ content = self.graph_session.make_request(
221
+ method="patch", endpoint=f"/users/{user_id}/messages", json=message
222
+ )
223
+
224
+ return content
225
+
226
+ def delete_my_message(self, message_id: str) -> dict:
227
+ """Delete a message in the default user"s mailbox,
228
+ or delete a relationship of the message.
229
+
230
+ ### Parameters
231
+ ----
232
+ message_id : str
233
+ The ID of the message you wish to delete.
234
+
235
+ ### Returns
236
+ ----
237
+ dict
238
+ If successful, this method returns a 204 No Content
239
+ response code. It does not return anything in
240
+ the response body..
241
+ """
242
+
243
+ content = self.graph_session.make_request(
244
+ method="get", endpoint=f"me/messages/{message_id}"
245
+ )
246
+
247
+ return content
248
+
249
+ def delete_user_message(self, user_id: str, message_id: str) -> dict:
250
+ """Delete a message in the specified user"s mailbox,
251
+ or delete a relationship of the message.
252
+
253
+ ### Parameters
254
+ ----
255
+ user_id : str
256
+ The user for which to delete a message for.
257
+
258
+ message_id : str
259
+ The ID of the message you wish to delete.
260
+
261
+ ### Returns
262
+ ----
263
+ dict
264
+ If successful, this method returns a 204 No Content
265
+ response code. It does not return anything in
266
+ the response body..
267
+ """
268
+
269
+ content = self.graph_session.make_request(
270
+ method="delete", endpoint=f"/users/{user_id}/messages/{message_id}"
271
+ )
272
+
273
+ return content
274
+
275
+ def send_my_message(self, message_id: str) -> dict:
276
+ """Send a message in the draft folder for the default user.
277
+
278
+ ### Overview:
279
+ ----
280
+ The draft message can be a new message draft,
281
+ reply draft, reply-all draft, or a forward draft.
282
+ The message is then saved in the Sent Items folder.
283
+
284
+ ### Parameters
285
+ ----
286
+ message_id : str
287
+ The ID of the message you wish to send.
288
+
289
+ ### Returns
290
+ ----
291
+ dict
292
+ If successful, this method returns 202 Accepted
293
+ response code. It does not return anything in
294
+ the response body.
295
+ """
296
+
297
+ content = self.graph_session.make_request(
298
+ method="post", endpoint=f"/me/messages/{message_id}/send"
299
+ )
300
+
301
+ return content
302
+
303
+ def send_user_message(self, user_id: str, message_id: str) -> dict:
304
+ """Send a message in the draft folder for the specified user.
305
+
306
+ ### Overview:
307
+ ----
308
+ The draft message can be a new message draft,
309
+ reply draft, reply-all draft, or a forward draft.
310
+ The message is then saved in the Sent Items folder.
311
+
312
+ ### Parameters
313
+ ----
314
+ user_id : str
315
+ The user for which to send a message for.
316
+
317
+ message_id : str
318
+ The ID of the message you wish to send.
319
+
320
+ ### Returns
321
+ ----
322
+ dict
323
+ If successful, this method returns 202 Accepted
324
+ response code. It does not return anything in
325
+ the response body.
326
+ """
327
+
328
+ content = self.graph_session.make_request(
329
+ method="post", endpoint=f"/users/{user_id}/messages/{message_id}/send"
330
+ )
331
+
332
+ return content
333
+
334
+ def copy_my_message(self, message_id: str) -> dict:
335
+ """Send a message in the draft folder for the specified user.
336
+
337
+ ### Overview:
338
+ ----
339
+ The draft message can be a new message draft,
340
+ reply draft, reply-all draft, or a forward draft.
341
+ The message is then saved in the Sent Items folder.
342
+
343
+ ### Parameters
344
+ ----
345
+ message_id : str
346
+ The ID of the message you wish to send.
347
+
348
+ ### Returns
349
+ ----
350
+ dict
351
+ If successful, this method returns 202 Accepted
352
+ response code. It does not return anything in
353
+ the response body.
354
+ """
355
+
356
+ content = self.graph_session.make_request(
357
+ method="post", endpoint=f"/me/messages/{message_id}/copy"
358
+ )
359
+
360
+ return content
361
+
362
+ def copy_user_message(self, user_id: str, message_id: str) -> dict:
363
+ """Send a message in the draft folder for the specified user.
364
+
365
+ ### Overview:
366
+ ----
367
+ The draft message can be a new message draft,
368
+ reply draft, reply-all draft, or a forward draft.
369
+ The message is then saved in the Sent Items folder.
370
+
371
+ ### Parameters
372
+ ----
373
+ user_id : str
374
+ The user for which to send a message for.
375
+
376
+ message_id : str
377
+ The ID of the message you wish to send.
378
+
379
+ ### Returns
380
+ ----
381
+ dict
382
+ If successful, this method returns 202 Accepted
383
+ response code. It does not return anything in
384
+ the response body.
385
+ """
386
+ content = self.graph_session.make_request(
387
+ method="post", endpoint=f"/users/{user_id}/messages/{message_id}/copy"
388
+ )
389
+
390
+ return content
391
+
392
+ def move_my_message(self, message_id: str, destination_id: str) -> dict:
393
+ """Move a message to another folder within the specified user"s mailbox.
394
+ For the default user.
395
+
396
+ ### Overview:
397
+ ----
398
+ This creates a new copy of the message in the destination folder and
399
+ removes the original message.
400
+
401
+ ### Parameters
402
+ ----
403
+ message_id : str
404
+ The ID of the message you wish to move.
405
+
406
+ destination_id : str
407
+ The name of the folder you want to move it to.
408
+
409
+ ### Returns
410
+ ----
411
+ dict
412
+ If successful, this method returns 201 Created response
413
+ code and `Message` object in the response body.
414
+ """
415
+
416
+ content = self.graph_session.make_request(
417
+ method="post",
418
+ endpoint=f"/me/messages/{message_id}/move",
419
+ json={"destinationId": destination_id},
420
+ )
421
+
422
+ return content
423
+
424
+ def move_user_message(
425
+ self, user_id: str, message_id: str, destination_id: str
426
+ ) -> dict:
427
+ """Move a message to another folder within the specified user"s mailbox.
428
+
429
+ ### Overview:
430
+ ----
431
+ This creates a new copy of the message in the destination folder and
432
+ removes the original message.
433
+
434
+ ### Parameters
435
+ ----
436
+ user_id : str
437
+ The user ID of the mailbox that you want to move a
438
+ message for.
439
+
440
+ message_id : str
441
+ The ID of the message you wish to move.
442
+
443
+ destination_id : str
444
+ The name of the folder you want to move it to.
445
+
446
+ ### Returns
447
+ ----
448
+ dict
449
+ If successful, this method returns 201 Created response
450
+ code and `Message` object in the response body.
451
+ """
452
+
453
+ content = self.graph_session.make_request(
454
+ method="post",
455
+ endpoint=f"/users/{user_id}/messages/{message_id}/move",
456
+ json={"destinationId": destination_id},
457
+ )
458
+
459
+ return content
460
+
461
+ def create_reply_my_message(self, message_id: str) -> dict:
462
+ """Create a draft of the reply to the specified message. For
463
+ the default user.
464
+
465
+ ### Overview:
466
+ ----
467
+ You can then update the draft to add reply content to the
468
+ body or change other message properties, or, simply send
469
+ the draft.
470
+
471
+ ### Parameters
472
+ ----
473
+ message_id : str
474
+ The message ID for which you wish to use
475
+ as a reply message.
476
+
477
+ ### Returns
478
+ ----
479
+ dict
480
+ If successful, this method returns 201 Created response
481
+ code and `Message` object in the response body.
482
+ """
483
+ content = self.graph_session.make_request(
484
+ method="post", endpoint=f"/me/messages/{message_id}/createReply"
485
+ )
486
+
487
+ return content
488
+
489
+ def create_reply_user_message(self, user_id: str, message_id: str) -> dict:
490
+ """Create a draft of the reply to the specified message.
491
+
492
+ ### Overview:
493
+ ----
494
+ You can then update the draft to add reply content to the
495
+ body or change other message properties, or, simply send
496
+ the draft.
497
+
498
+ ### Parameters
499
+ ----
500
+ user_id : str
501
+ The user ID of the mailbox that you want to create a
502
+ reply message for.
503
+
504
+ message_id : str
505
+ The message ID for which you wish to use
506
+ as a reply message.
507
+
508
+ ### Returns
509
+ ----
510
+ dict
511
+ If successful, this method returns 201 Created response
512
+ code and `Message` object in the response body.
513
+ """
514
+
515
+ content = self.graph_session.make_request(
516
+ method="post",
517
+ endpoint=f"/users/{user_id}/messages/{message_id}/createReply",
518
+ )
519
+
520
+ return content
521
+
522
+ def reply_to_my_message(self, message_id: str, message: dict) -> dict:
523
+ """Reply to the sender of a message, add a comment or modify any updateable properties
524
+ all in one reply call. The message is then saved in the Sent Items folder. For the
525
+ default user.
526
+
527
+ ### Parameters
528
+ ----
529
+ message_id : str
530
+ The message ID for which you wish to reply to.
531
+
532
+ messgae : dict
533
+ The message you want to reply with.
534
+
535
+ ### Returns
536
+ ----
537
+ dict
538
+ If successful, this method returns 202 Accepted response
539
+ code. It does not return anything in the response body.
540
+ """
541
+
542
+ content = self.graph_session.make_request(
543
+ method="post", endpoint=f"/me/messages/{message_id}/reply", json=message
544
+ )
545
+
546
+ return content
547
+
548
+ def reply_to_user_message(
549
+ self, user_id: str, message_id: str, message: dict
550
+ ) -> dict:
551
+ """Reply to the sender of a message, add a comment or modify any updateable properties
552
+ all in one reply call. The message is then saved in the Sent Items folder.
553
+
554
+
555
+ ### Parameters
556
+ ----
557
+ user_id : str
558
+ The user ID of the mailbox that contains the message
559
+ you want to reply to.
560
+
561
+ message_id : str
562
+ The message ID for which you wish to reply to.
563
+
564
+ messgae : dict
565
+ The message you want to reply with.
566
+
567
+ ### Returns
568
+ ----
569
+ dict
570
+ If successful, this method returns 202 Accepted response
571
+ code. It does not return anything in the response body.
572
+ """
573
+
574
+ content = self.graph_session.make_request(
575
+ method="post",
576
+ endpoint=f"/users/{user_id}/messages/{message_id}/reply",
577
+ json=message,
578
+ )
579
+
580
+ return content
581
+
582
+ def create_reply_all_my_message(self, message_id: str) -> dict:
583
+ """Create a draft to reply to the sender and all the recipients of the specified message.
584
+ For the default user.
585
+
586
+ ### Overview:
587
+ ----
588
+ You can then update the draft to add reply content to the body
589
+ or change other message properties, or, simply send the draft.
590
+
591
+ ### Parameters
592
+ ----
593
+ message_id : str
594
+ The message ID for which you wish to use
595
+ as a repy message
596
+
597
+ ### Returns
598
+ ----
599
+ dict
600
+ If successful, this method returns 201 Created response
601
+ code and `Message` object in the response body.
602
+ """
603
+
604
+ content = self.graph_session.make_request(
605
+ method="post", endpoint=f"/me/messages/{message_id}/createReplyAll"
606
+ )
607
+
608
+ return content
609
+
610
+ def create_reply_all_user_message(self, user_id: str, message_id: str) -> dict:
611
+ """Create a draft to reply to the sender and all the recipients of the specified message.
612
+
613
+ ### Overview:
614
+ ----
615
+ You can then update the draft to add reply content to the body
616
+ or change other message properties, or, simply send the draft.
617
+
618
+ ### Parameters
619
+ ----
620
+ message_id : str
621
+ The message ID for which you wish to reply all
622
+ to.
623
+
624
+ user_id : str
625
+ The User ID you want to reply all messages for.
626
+
627
+ message : dict
628
+ The message you want to respond with.
629
+
630
+ ### Returns
631
+ ----
632
+ dict
633
+ If successful, this method returns 201 Created response
634
+ code and `Message` object in the response body.
635
+ """
636
+
637
+ content = self.graph_session.make_request(
638
+ method="post",
639
+ endpoint=f"/users/{user_id}/messages/{message_id}/createReplyAll",
640
+ )
641
+
642
+ return content
643
+
644
+ def reply_all_my_message(self, message_id: str, message: dict) -> dict:
645
+ """Create a draft to reply to the sender and all the recipients of the
646
+ specified message for the default user.
647
+
648
+ ### Overview:
649
+ ----
650
+ You can then update the draft to add reply content to the body
651
+ or change other message properties, or, simply send the draft.
652
+
653
+ ### Parameters
654
+ ----
655
+ message_id : str
656
+ The message ID for which you wish to reply all
657
+ to.
658
+
659
+ message : dict
660
+ The message you want to respond with.
661
+
662
+ ### Returns
663
+ ----
664
+ dict
665
+ If successful, this method returns 201 Created response
666
+ code and `Message` object in the response body.
667
+ """
668
+
669
+ content = self.graph_session.make_request(
670
+ method="post", endpoint=f"/me/messages/{message_id}/replyAll", json=message
671
+ )
672
+
673
+ return content
674
+
675
+ def reply_all_user_message(
676
+ self, user_id: str, message_id: str, message: dict
677
+ ) -> dict:
678
+ """Create a draft to reply to the sender and all the recipients of the specified message.
679
+
680
+ ### Overview:
681
+ ----
682
+ You can then update the draft to add reply content to the body
683
+ or change other message properties, or, simply send the draft.
684
+
685
+ ### Parameters
686
+ ----
687
+ message_id : str
688
+ The message ID for which you wish to reply all
689
+ to.
690
+
691
+ user_id : str
692
+ The User ID you want to reply all messages for.
693
+
694
+ message : dict
695
+ The message you want to respond with.
696
+
697
+ ### Returns
698
+ ----
699
+ dict
700
+ If successful, this method returns 201 Created response
701
+ code and `Message` object in the response body.
702
+ """
703
+
704
+ content = self.graph_session.make_request(
705
+ method="post",
706
+ endpoint=f"/users/{user_id}/messages/{message_id}/replyAll",
707
+ json=message,
708
+ )
709
+
710
+ return content
711
+
712
+ def create_forward_my_message(self, message_id: str) -> dict:
713
+ """Create a draft to forward the specified message. For the default user.
714
+
715
+ ### Overview:
716
+ ----
717
+ You can then update the draft to add content to the body
718
+ or change other message properties, or, simply send the
719
+ draft.
720
+
721
+ ### Parameters
722
+ ----
723
+ message_id : str
724
+ The message ID for which you wish to forward.
725
+
726
+ ### Returns
727
+ ----
728
+ dict
729
+ If successful, this method returns 201 Created response
730
+ code and `Message` object in the response body.
731
+ """
732
+
733
+ content = self.graph_session.make_request(
734
+ method="post", endpoint=f"/me/messages/{message_id}/createForward"
735
+ )
736
+
737
+ return content
738
+
739
+ def create_forward_user_message(self, user_id: str, message_id: str) -> dict:
740
+ """Create a draft to forward the specified message.
741
+
742
+ ### Overview:
743
+ ----
744
+ You can then update the draft to add content to the body
745
+ or change other message properties, or, simply send the
746
+ draft.
747
+
748
+ ### Parameters
749
+ ----
750
+ message_id : str
751
+ The message ID for which you wish to forward.
752
+
753
+ user_id : dict
754
+ The User ID you want to create a new forward
755
+ message for.
756
+
757
+ ### Returns
758
+ ----
759
+ dict
760
+ If successful, this method returns 201 Created response
761
+ code and Message object in the response body.
762
+ """
763
+
764
+ content = self.graph_session.make_request(
765
+ method="post",
766
+ endpoint=f"/users/{user_id}/messages/{message_id}/createForward",
767
+ )
768
+
769
+ return content
770
+
771
+ def forward_my_message(self, message_id: str, message: dict) -> dict:
772
+ """Forward a message for the default user. The message is saved in the
773
+ Sent Items folder.
774
+
775
+ ### Parameters
776
+ ----
777
+ message_id : str
778
+ The message ID for which you wish to forward.
779
+
780
+ message : dict
781
+ The message to send.
782
+
783
+ ### Returns
784
+ ----
785
+ dict
786
+ If successful, this method returns 202 Accepted response code.
787
+ It does not return anything in the response body.
788
+ """
789
+
790
+ content = self.graph_session.make_request(
791
+ method="post", endpoint=f"/me/messages/{message_id}/forward", json=message
792
+ )
793
+
794
+ return content
795
+
796
+ def forward_user_message(
797
+ self, user_id: str, message_id: str, message: dict
798
+ ) -> dict:
799
+ """Forward a message. The message is saved in the Sent Items folder.
800
+
801
+ ### Parameters
802
+ ----
803
+ user_id : str
804
+ The user ID which contains the email you want to
805
+ forward.
806
+
807
+ message_id : str
808
+ The message ID for which you wish to forward.
809
+
810
+ message : dict
811
+ The message to send.
812
+
813
+ ### Returns
814
+ ----
815
+ dict
816
+ If successful, this method returns 202 Accepted response code.
817
+ It does not return anything in the response body.
818
+ """
819
+
820
+ content = self.graph_session.make_request(
821
+ method="post",
822
+ endpoint=f"/users/{user_id}/messages/{message_id}/forward",
823
+ json=message,
824
+ )
825
+
826
+ return content
827
+
828
+ def send_my_mail(
829
+ self, message_id: str, message: dict, save_to_send_items: bool = True
830
+ ) -> dict:
831
+ """Send the message specified in the request body for the default user.
832
+
833
+ ### Overview:
834
+ ----
835
+ The message is saved in the Sent Items folder by default. You
836
+ can include a file attachment in the same sendMail action call.
837
+
838
+ ### Parameters
839
+ ----
840
+ message_id : dict
841
+ The message ID for which you want to send.
842
+
843
+ save_to_send_items : bool (optional)
844
+ Indicates whether to save the message in Sent Items. Specify
845
+ it only if the parameter is false; default is true.
846
+
847
+ ### Returns
848
+ ----
849
+ dict
850
+ If successful, this method returns 202 Accepted response code.
851
+ It does not return anything in the response body.
852
+ """
853
+
854
+ message["saveToSentItems"] = save_to_send_items
855
+
856
+ content = self.graph_session.make_request(
857
+ method="post", endpoint="/me/sendMail", json=message
858
+ )
859
+
860
+ return content
861
+
862
+ def send_user_mail(
863
+ self, user_id: str, message: dict, save_to_send_items: bool = True
864
+ ) -> dict:
865
+ """Send the message specified in the request body.
866
+
867
+ ### Overview:
868
+ ----
869
+ The message is saved in the Sent Items folder by default. You
870
+ can include a file attachment in the same sendMail action call.
871
+
872
+
873
+ ### Parameters
874
+ ----
875
+ user_id : str
876
+ The user for which to send a mailItem resource for.
877
+
878
+ message : dict
879
+ The message to send.
880
+
881
+ save_to_send_items : bool, optional
882
+ Indicates whether to save the message in Sent Items. Specify it
883
+ only if the parameter is false, by default True.
884
+
885
+ ### Returns
886
+ ----
887
+ dict
888
+ If successful, this method returns 202 Accepted response code.
889
+ It does not return anything in the response body.
890
+ """
891
+
892
+ message["saveToSentItems"] = save_to_send_items
893
+
894
+ content = self.graph_session.make_request(
895
+ method="post", endpoint=f"/users/{user_id}/sendMail", json=message
896
+ )
897
+
898
+ return content
899
+
900
+ def list_my_attachements(self, message_id: str) -> dict:
901
+ """Retrieve a list of `attachment` objects attached to a message.
902
+
903
+ ### Parameters
904
+ ----
905
+ message_id : str
906
+ The message Id of the mailItem resource that
907
+ you want to query attachments for.
908
+
909
+ ### Returns
910
+ ----
911
+ dict
912
+ If successful, this method returns a 200 OK response code
913
+ and collection of Attachment objects in the response body.
914
+ """
915
+ content = self.graph_session.make_request(
916
+ method="get", endpoint=f"/me/messages/{message_id}/attachments"
917
+ )
918
+
919
+ return content
920
+
921
+ def list_user_attachements(self, user_id: str, message_id: str) -> dict:
922
+ """Get all the `messageRule` objects defined for the user"s Inbox. For
923
+ the default user.
924
+
925
+ ### Returns
926
+ ----
927
+ dict
928
+ If successful, this method returns a 200 OK response code
929
+ and collection of messageRule objects in the response body.
930
+ """
931
+
932
+ content = self.graph_session.make_request(
933
+ method="get", endpoint=f"/users/{user_id}/messages/{message_id}/attachments"
934
+ )
935
+
936
+ return content
937
+
938
+ def list_my_rules(self) -> dict:
939
+ """Get all the `messageRule` objects defined for the user"s Inbox. For
940
+ the default user.
941
+
942
+ ### Returns
943
+ ----
944
+ dict
945
+ If successful, this method returns a 200 OK response code
946
+ and collection of messageRule objects in the response body.
947
+ """
948
+
949
+ content = self.graph_session.make_request(
950
+ method="get", endpoint="/me/mailFolders/inbox/messageRules"
951
+ )
952
+
953
+ return content
954
+
955
+ def list_rules(self, user_id: str) -> dict:
956
+ """Get all the `messageRule` objects defined for the user"s Inbox. For
957
+ the specific user.
958
+
959
+ ### Parameters
960
+ ----
961
+ user_id : str
962
+ The user ID for which to query `messageRules` for.
963
+
964
+ ### Returns
965
+ ----
966
+ dict
967
+ If successful, this method returns a 200 OK response code
968
+ and collection of messageRule objects in the response body.
969
+ """
970
+
971
+ content = self.graph_session.make_request(
972
+ method="get", endpoint=f"/users/{user_id}/mailFolders/inbox/messageRules"
973
+ )
974
+
975
+ return content
976
+
977
+ def create_my_message_rule(self, rule: dict) -> dict:
978
+ """Create a messageRule object by specifying a set of conditions and actions for
979
+ the default user.
980
+
981
+ ### Parameters
982
+ ----
983
+ rule : dict
984
+ The parameters that are applicable to your rule.
985
+ For more info:
986
+ https://docs.microsoft.com/en-us/graph/api/mailfolder-post-messagerules?view=graph-rest-1.0&tabs=http#request-body
987
+
988
+ ### Returns
989
+ ----
990
+ dict
991
+ If successful, this method returns 201 Created response code and a
992
+ `messageRule` object in the response body.
993
+ """
994
+
995
+ content = self.graph_session.make_request(
996
+ method="post", endpoint="/me/mailFolders/inbox/messageRules", json=rule
997
+ )
998
+
999
+ return content
1000
+
1001
+ def create_message_rule(self, user_id: str, rule: dict) -> dict:
1002
+ """Create a messageRule object by specifying a set of conditions and actions
1003
+ for the specified User.
1004
+
1005
+ ### Parameters
1006
+ ----
1007
+ user_id : str
1008
+ The User ID for which to create the message rule
1009
+ for.
1010
+
1011
+ rule : dict
1012
+ The parameters that are applicable to your rule.
1013
+ For more info:
1014
+ https://docs.microsoft.com/en-us/graph/api/mailfolder-post-messagerules?view=graph-rest-1.0&tabs=http#request-body
1015
+
1016
+ ### Returns
1017
+ ----
1018
+ dict
1019
+ If successful, this method returns 201 Created response code and a
1020
+ `messageRule` object in the response body.
1021
+ """
1022
+
1023
+ content = self.graph_session.make_request(
1024
+ method="post",
1025
+ endpoint=f"/users/{user_id}/mailFolders/inbox/messageRules",
1026
+ json=rule,
1027
+ )
1028
+
1029
+ return content
1030
+
1031
+ def list_my_overrides(self) -> dict:
1032
+ """Get the overrides that a user has set up to always classify messages from
1033
+ certain senders in specific ways.
1034
+
1035
+ ### Returns
1036
+ ----
1037
+ dict
1038
+ If successful, this method returns a 200 OK response code and a collection
1039
+ of `inferenceClassificationOverride1 objects in the response body. An
1040
+ empty collection is returned if the user doesn"t have any overrides
1041
+ set up.
1042
+ """
1043
+
1044
+ content = self.graph_session.make_request(
1045
+ method="get", endpoint="/me/inferenceClassification/overrides"
1046
+ )
1047
+
1048
+ return content
1049
+
1050
+ def list_overrides(self, user_id: str) -> dict:
1051
+ """Get the overrides that a user has set up to always classify messages from
1052
+ certain senders in specific ways.
1053
+
1054
+ ### Parameters
1055
+ ----
1056
+ user_id : str
1057
+ The User ID for which to query `inferenceClassificationOverride`
1058
+ objects for.
1059
+
1060
+ ### Returns
1061
+ ----
1062
+ dict
1063
+ If successful, this method returns a 200 OK response code and a collection
1064
+ of `inferenceClassificationOverride` objects in the response body. An
1065
+ empty collection is returned if the user doesn"t have any overrides
1066
+ set up.
1067
+ """
1068
+
1069
+ content = self.graph_session.make_request(
1070
+ method="get", endpoint=f"/users/{user_id}/inferenceClassification/overrides"
1071
+ )
1072
+
1073
+ return content