forked from GearPlug/microsoftgraph-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.py
More file actions
87 lines (64 loc) · 3.03 KB
/
notes.py
File metadata and controls
87 lines (64 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from microsoftgraph.decorators import token_required
from microsoftgraph.response import Response
class Notes(object):
def __init__(self, client) -> None:
"""Use the OneNote REST API.
https://docs.microsoft.com/en-us/graph/api/resources/onenote-api-overview?view=graph-rest-1.0
Args:
client (Client): Library Client.
"""
self._client = client
@token_required
def list_notebooks(self, params: dict = None) -> Response:
"""Retrieve a list of notebook objects.
https://docs.microsoft.com/en-us/graph/api/onenote-list-notebooks?view=graph-rest-1.0&tabs=http
Args:
params (dict, optional): Query. Defaults to None.
Returns:
Response: Microsoft Graph Response.
"""
return self._client._get(self._client.base_url + "me/onenote/notebooks", params=params)
@token_required
def get_notebook(self, notebook_id: str, params: dict = None) -> Response:
"""Retrieve the properties and relationships of a notebook object.
https://docs.microsoft.com/en-us/graph/api/notebook-get?view=graph-rest-1.0&tabs=http
Args:
notebook_id (str): The unique identifier of the notebook.
params (dict, optional): Query. Defaults to None.
Returns:
Response: Microsoft Graph Response.
"""
return self._client._get(self._client.base_url + "me/onenote/notebooks/" + notebook_id, params=params)
@token_required
def list_sections(self, notebook_id: str, params: dict = None) -> Response:
"""Retrieve a list of onenoteSection objects from the specified notebook.
https://docs.microsoft.com/en-us/graph/api/notebook-list-sections?view=graph-rest-1.0&tabs=http
Args:
notebook_id (str): The unique identifier of the notebook.
params (dict, optional): Query. Defaults to None.
Returns:
Response: Microsoft Graph Response.
"""
url = "me/onenote/notebooks/{}/sections".format(notebook_id)
return self._client._get(self._client.base_url + url, params=params)
@token_required
def list_pages(self, params: dict = None) -> Response:
"""Retrieve a list of page objects.
Args:
params (dict, optional): Query. Defaults to None.
Returns:
Response: Microsoft Graph Response.
"""
return self._client._get(self._client.base_url + "me/onenote/pages", params=params)
@token_required
def create_page(self, section_id: str, files: list) -> Response:
"""Create a new page in the specified section.
https://docs.microsoft.com/en-us/graph/api/section-post-pages?view=graph-rest-1.0
Args:
section_id (str): The unique identifier of the section.
files (list): Attachments.
Returns:
Response: Microsoft Graph Response.
"""
url = "me/onenote/sections/{}/pages".format(section_id)
return self._client._post(self._client.base_url + url, files=files)