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/notes.py ADDED
@@ -0,0 +1,276 @@
1
+ from ms_graph.session import GraphSession
2
+
3
+
4
+ class Notes():
5
+
6
+ """
7
+ ## Overview:
8
+ ----
9
+ Microsoft Graph lets your app get authorized access to a user's
10
+ OneNote notebooks, sections, and pages in a personal or organization
11
+ account. With the appropriate delegated or application permissions,
12
+ your app can access the OneNote data of the signed-in user or any
13
+ user in a tenant.
14
+ """
15
+
16
+ def __init__(self, session: object) -> None:
17
+ """Initializes the `Notes` object.
18
+
19
+ ### Parameters
20
+ ----
21
+ session : object
22
+ An authenticated session for our Microsoft Graph Client.
23
+ """
24
+
25
+ # Set the session.
26
+ self.graph_session: GraphSession = session
27
+
28
+ # Set the endpoint.
29
+ self.endpoint = "onenote"
30
+
31
+ def list_my_notebooks(self) -> dict:
32
+ """Retrieve a list of your notebook objects.
33
+
34
+ ### Returns
35
+ ----
36
+ dict :
37
+ A List of `Notebook` Resource Object.
38
+ """
39
+
40
+ # define the endpoints.
41
+ endpoint = "me/" + self.endpoint + "/notebooks"
42
+
43
+ content = self.graph_session.make_request(
44
+ method="get",
45
+ endpoint=endpoint
46
+ )
47
+
48
+ return content
49
+
50
+ def list_user_notebooks(self, user_id: str) -> dict:
51
+ """Retrieve a list of notebook objects.
52
+
53
+ ### Parameters
54
+ ----
55
+ user_id (str): The User"s ID that is assoicated with
56
+ their Graph account.
57
+
58
+ ### Returns
59
+ ----
60
+ dict :
61
+ A List of `Notebook` Resource Object.
62
+ """
63
+
64
+ # Define the endpoint.
65
+ endpoint = f"users/{user_id}/" + self.endpoint + "/notebooks"
66
+
67
+ content = self.graph_session.make_request(
68
+ method="get",
69
+ endpoint=endpoint
70
+ )
71
+
72
+ return content
73
+
74
+ def list_group_notebooks(self, group_id: str) -> dict:
75
+ """Retrieve a list of notebook objects.
76
+
77
+ ### Parameters
78
+ ----
79
+ group_id (str): The Group ID that you want to pull
80
+ notebooks for.
81
+
82
+ ### Returns
83
+ ----
84
+ dict :
85
+ A List of `Notebook` Resource Object.
86
+ """
87
+
88
+ # Define the endpoint.
89
+ endpoint = f"groups/{group_id}" + self.endpoint + "/notebooks"
90
+
91
+ content = self.graph_session.make_request(
92
+ method="get",
93
+ endpoint=endpoint
94
+ )
95
+
96
+ return content
97
+
98
+ def list_site_notebooks(self, site_id: str) -> dict:
99
+ """Retrieve a list of notebook objects.
100
+
101
+ ### Parameters
102
+ ----
103
+ site_id (str): The Site ID that you want to pull
104
+ notebooks for.
105
+
106
+ ### Returns
107
+ ----
108
+ dict :
109
+ A List of `Notebook` Resource Object.
110
+ """
111
+
112
+ # Define the endpoint.
113
+ endpoint = f"sites/{site_id}" + self.endpoint + "/notebooks"
114
+
115
+ content = self.graph_session.make_request(
116
+ method="get",
117
+ endpoint=endpoint
118
+ )
119
+
120
+ return content
121
+
122
+ def get_my_notebook(self, notebook_id: str) -> dict:
123
+ """Retrieve a list of notebook objects.
124
+
125
+ ### Parameters
126
+ ----
127
+ notebook_id (str): The User"s Notebook ID that you
128
+ want to pull.
129
+
130
+ ### Returns
131
+ ----
132
+ dict :
133
+ A List of `Notebook` Resource Object.
134
+ """
135
+
136
+ # define the endpoints.
137
+ endpoint = "me/" + self.endpoint + f"/notebooks/{notebook_id}"
138
+
139
+ content = self.graph_session.make_request(
140
+ method="get",
141
+ endpoint=endpoint
142
+ )
143
+
144
+ return content
145
+
146
+ def get_user_notebook(self, user_id: str, notebook_id: str) -> dict:
147
+ """Retrieve a notebook object from a user by it"s ID.
148
+
149
+ ### Parameters
150
+ ----
151
+ user_id (str): The User"s ID that is assoicated with
152
+ their Graph account.
153
+
154
+ notebook_id (str): The Notebook ID that you
155
+ want to pull.
156
+
157
+ ### Returns
158
+ ----
159
+ dict :
160
+ A List of `Notebook` Resource Object.
161
+ """
162
+
163
+ # Define the endpoint.
164
+ endpoint = f"users/{user_id}" + self.endpoint + f"/notebooks/{notebook_id}"
165
+
166
+ content = self.graph_session.make_request(
167
+ method="get",
168
+ endpoint=endpoint
169
+ )
170
+
171
+ return content
172
+
173
+ def get_group_notebook(self, group_id: str, notebook_id: str) -> dict:
174
+ """Retrieve a notebook object from a Group by it"s ID.
175
+
176
+ ### Parameters
177
+ ----
178
+ group_id (str): The Group ID that you want to pull
179
+ notebooks for.
180
+
181
+ notebook_id (str): The Notebook ID that you
182
+ want to pull.
183
+
184
+ ### Returns
185
+ ----
186
+ dict :
187
+ A List of `Notebook` Resource Object.
188
+ """
189
+
190
+ # Define the endpoint.
191
+ endpoint = f"groups/{group_id}" + self.endpoint + f"/notebooks/{notebook_id}"
192
+
193
+ content = self.graph_session.make_request(
194
+ method="get",
195
+ endpoint=endpoint
196
+ )
197
+
198
+ return content
199
+
200
+ def get_site_notebook(self, site_id: str, notebook_id: str) -> dict:
201
+ """Retrieve a notebook object from a SharePoint Site by it"s ID.
202
+
203
+ ### Parameters
204
+ ----
205
+ site_id (str): The Site ID that you want to pull
206
+ notebooks for.
207
+
208
+ notebook_id (str): The Notebook ID that you
209
+ want to pull.
210
+
211
+ ### Returns
212
+ ----
213
+ dict :
214
+ A List of `Notebook` Resource Object.
215
+ """
216
+
217
+ # Define the endpoint.
218
+ endpoint = f"sites/{site_id}" + self.endpoint + f"/notebooks/{notebook_id}"
219
+
220
+ content = self.graph_session.make_request(
221
+ method="get",
222
+ endpoint=endpoint
223
+ )
224
+
225
+ return content
226
+
227
+ def list_my_notebook_sections(self, notebook_id: str) -> dict:
228
+ """Retrieve a list of onenoteSection objects from one of your notebooks.
229
+
230
+ ### Parameters
231
+ ----
232
+ notebook_id (str): The Notebook ID that you
233
+ want to pull.
234
+
235
+ ### Returns
236
+ ----
237
+ dict :
238
+ A List of `Notebook` Resource Object.
239
+ """
240
+
241
+ # Define the endpoint.
242
+ endpoint = endpoint = "me/" + self.endpoint + f"/notebooks/{notebook_id}/sections"
243
+
244
+ content = self.graph_session.make_request(
245
+ method="get",
246
+ endpoint=endpoint
247
+ )
248
+
249
+ return content
250
+
251
+ def list_my_notebook_pages(self, section_id: str) -> dict:
252
+ """Retrieve a list of onenoteSection objects from one of your notebooks.
253
+
254
+ ### Parameters
255
+ ----
256
+ notebook_id (str): The Notebook ID that you
257
+ want to pull.
258
+
259
+ section (str): The Section ID that you
260
+ want to pull.
261
+
262
+ ### Returns
263
+ ----
264
+ dict :
265
+ A List of `Notebook` Resource Object.
266
+ """
267
+
268
+ # Define the endpoint.
269
+ endpoint = endpoint = f"me/{self.endpoint}/" + f"/sections/{section_id}"
270
+
271
+ content = self.graph_session.make_request(
272
+ method="get",
273
+ endpoint=endpoint
274
+ )
275
+
276
+ return content
@@ -0,0 +1,226 @@
1
+ from ms_graph.session import GraphSession
2
+
3
+
4
+ class PersonalContacts():
5
+
6
+ """
7
+ ## Overview:
8
+ ----
9
+ A contact is an item in Outlook where you can organize and save
10
+ information about the people and organizations you communicate
11
+ with. Contacts are contained in contact folders.
12
+ """
13
+
14
+ def __init__(self, session: object) -> None:
15
+ """Initializes the `PersonalContacts` object.
16
+
17
+ ### Parameters
18
+ ----
19
+ session : object
20
+ An authenticated session for our Microsoft Graph Client.
21
+ """
22
+
23
+ # Set the session.
24
+ self.graph_session: GraphSession = session
25
+
26
+ # Set the endpoint.
27
+ self.endpoint = "contacts"
28
+ self.endpoint_folders = "contactFolders"
29
+
30
+ def list_my_contacts(self) -> dict:
31
+ """Retrieves all the contacts from the users mailbox.
32
+
33
+ ### Returns
34
+ ----
35
+ dict :
36
+ A List of `Contact` Resource Object.
37
+ """
38
+
39
+ # define the endpoints.
40
+ endpoint = "me/" + self.endpoint
41
+
42
+ content = self.graph_session.make_request(
43
+ method="get",
44
+ endpoint=endpoint
45
+ )
46
+
47
+ return content
48
+
49
+ def list_my_contacts_folder(self) -> dict:
50
+ """Retrieves all the contacts folders from the users mailbox.
51
+
52
+ ### Returns
53
+ ----
54
+ dict :
55
+ A List of `ContactFolders` Resource Object.
56
+ """
57
+
58
+ # define the endpoints.
59
+ endpoint = "me/" + self.endpoint_folders
60
+
61
+ content = self.graph_session.make_request(
62
+ method="get",
63
+ endpoint=endpoint
64
+ )
65
+
66
+ return content
67
+
68
+ def list_contacts_folder_by_id(self, user_id: str, folder_id: str) -> dict:
69
+ """Retrieves all the contacts folders from the users mailbox.
70
+
71
+ ### Parameters
72
+ ----
73
+ user_id : str
74
+ The User ID that the folder belongs to.
75
+
76
+ folder_id : str
77
+ The folder ID you want to retrieve.
78
+
79
+ ### Returns
80
+ ----
81
+ dict :
82
+ A List of `ContactFolders` Resource Object.
83
+ """
84
+
85
+ # define the endpoints.
86
+ endpoint = f"users/{user_id}/" + self.endpoint_folders + f"/{folder_id}"
87
+
88
+ content = self.graph_session.make_request(
89
+ method="get",
90
+ endpoint=endpoint
91
+ )
92
+
93
+ return content
94
+
95
+ def create_my_contact_folder(self, folder_resource: dict) -> dict:
96
+ """Creates a new Contact Folder under the default users profile.
97
+
98
+ ### Parameters
99
+ ----
100
+ folder_resource : dict
101
+ A dictionary that specifies the folder resource
102
+ attributes like the folder ID and folder display
103
+ value.
104
+
105
+ ### Returns
106
+ ----
107
+ dict :
108
+ A `ContactFolder` Resource Object.
109
+ """
110
+
111
+ # define the endpoints.
112
+ endpoint = "me/" + self.endpoint_folders
113
+
114
+ content = self.graph_session.make_request(
115
+ method="post",
116
+ endpoint=endpoint,
117
+ json=folder_resource
118
+ )
119
+
120
+ return content
121
+
122
+ def create_user_contact_folder(self, user_id: str, folder_resource: dict) -> dict:
123
+ """Creates a new Contact Folder under the specified users profile.
124
+
125
+ ### Parameters
126
+ ----
127
+ user_id : str
128
+ The User ID that the folder belongs to.
129
+
130
+ folder_resource : dict
131
+ A dictionary that specifies the folder resource
132
+ attributes like the folder ID and folder display
133
+ value.
134
+
135
+ ### Returns
136
+ ----
137
+ dict :
138
+ A `ContactFolder` Resource Object.
139
+ """
140
+
141
+ # define the endpoints.
142
+ endpoint = f"users/{user_id}/" + self.endpoint_folders
143
+
144
+ content = self.graph_session.make_request(
145
+ method="post",
146
+ endpoint=endpoint,
147
+ json=folder_resource
148
+ )
149
+
150
+ return content
151
+
152
+ def get_my_contacts_folder_by_id(self, folder_id: str) -> dict:
153
+ """Retrieves a contactsFolder resource using the specified ID.
154
+
155
+ ### Parameters
156
+ ----
157
+ folder_id : str
158
+ The folder ID you want to retrieve.
159
+
160
+ ### Returns
161
+ ----
162
+ dict :
163
+ A `ContactFolder` Resource Object.
164
+ """
165
+
166
+ # define the endpoints.
167
+ endpoint = "me/" + self.endpoint_folders + f"/{folder_id}"
168
+
169
+ content = self.graph_session.make_request(
170
+ method="get",
171
+ endpoint=endpoint
172
+ )
173
+
174
+ return content
175
+
176
+ def get_contacts_folder_by_id(self, user_id: str, folder_id: str) -> dict:
177
+ """Retrieves a contactsFolder resource using the specified ID for the
178
+ specified user.
179
+
180
+ ### Parameters
181
+ ----
182
+ user_id : str
183
+ The User ID that the folder belongs to.
184
+
185
+ folder_id : str
186
+ The folder ID you want to retrieve.
187
+
188
+ ### Returns
189
+ ----
190
+ dict :
191
+ A `ContactFolder` Resource Object.
192
+ """
193
+
194
+ # define the endpoints.
195
+ endpoint = f"users/{user_id}/" + self.endpoint_folders + f"/{folder_id}"
196
+
197
+ content = self.graph_session.make_request(
198
+ method="get",
199
+ endpoint=endpoint
200
+ )
201
+
202
+ return content
203
+
204
+ def get_my_contact_by_id(self, contact_id: str) -> dict:
205
+ """Retrieves the Contact Resource for the specified contact ID.
206
+
207
+ ### Parameters
208
+ ----
209
+ contact_id : str
210
+ An authenticated session for our Microsoft Graph Client.
211
+
212
+ ### Returns
213
+ ----
214
+ dict :
215
+ A List of `Contact` Resource Object.
216
+ """
217
+
218
+ # define the endpoints.
219
+ endpoint = "me/" + self.endpoint + f"/{contact_id}"
220
+
221
+ content = self.graph_session.make_request(
222
+ method="get",
223
+ endpoint=endpoint
224
+ )
225
+
226
+ return content
ms_graph/search.py ADDED
@@ -0,0 +1,48 @@
1
+ from ms_graph.session import GraphSession
2
+
3
+
4
+ class Search():
5
+
6
+ """
7
+ ## Overview:
8
+ ----
9
+ You can use the Microsoft Search API to query Microsoft 365 data in your apps.
10
+ Search requests run in the context of the signed-in user, identified using an
11
+ access token with delegated permissions.
12
+ """
13
+
14
+ def __init__(self, session: object) -> None:
15
+ """Initializes the `Query` object.
16
+
17
+ ### Parameters
18
+ ----
19
+ session : object
20
+ An authenticated session for our Microsoft Graph Client.
21
+ """
22
+
23
+ # Set the session.
24
+ self.graph_session: GraphSession = session
25
+
26
+ # Set the endpoint.
27
+ self.endpoint = "search"
28
+
29
+ def query(self, search_request: dict) -> dict:
30
+ """Runs the query specified in the request body. Search
31
+ results are provided in the response.
32
+
33
+ ### Returns
34
+ ----
35
+ dict :
36
+ A `SearchResponse` collection.
37
+ """
38
+
39
+ # define the endpoints.
40
+ endpoint = self.endpoint + "/query"
41
+
42
+ content = self.graph_session.make_request(
43
+ method="post",
44
+ endpoint=endpoint,
45
+ json=search_request
46
+ )
47
+
48
+ return content