@@ -19,7 +19,8 @@ Authentication
1919
2020To interact with the OneDrive API, you must authenticate. You can use the following code sample to do so.
2121
22- <pre ><code >import onedrivesdk
22+ ``` python
23+ import onedrivesdk
2324from onedrivesdk.helpers import GetAuthCodeServer
2425
2526redirect_uri = " http://localhost:8080/"
@@ -36,7 +37,7 @@ auth_url = client.auth_provider.get_auth_url(redirect_uri)
3637code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
3738
3839client.auth_provider.authenticate(code, redirect_uri, client_secret)
39- </ code ></ pre >
40+ ```
4041
4142Once you are authenticated, you should have access to the OneDrive API, and
4243can begin making calls using the SDK!
@@ -50,32 +51,37 @@ NOTE: All examples assume that the
5051Upload an Item
5152--------------
5253
53- <pre ><code >returned_item = client.item(drive="me", id="root").children["newfile.txt"].upload("./path_to_file.txt")</code ></pre >
54+ ``` python
55+ returned_item = client.item(drive = " me" , id = " root" ).children[" newfile.txt" ].upload(" ./path_to_file.txt" )
56+ ```
5457
5558Download an Item
5659----------------
5760
58- <pre ><code >root_folder = client.item(drive="me", id="root").children.get()
61+ ``` python
62+ root_folder = client.item(drive = " me" , id = " root" ).children.get()
5963id_of_file = root_folder[0 ].id
6064
6165client.item(drive = " me" , id = id_of_file).download(" ./path_to_download_to.txt" )
62- </ code ></ pre >
66+ ```
6367
6468Add a Folder
6569------------
6670
67- <pre ><code >f = onedrivesdk.Folder()
71+ ``` python
72+ f = onedrivesdk.Folder()
6873i = onedrivesdk.Item()
6974i.name = " New Folder"
7075i.folder = f
7176
7277returned_item = client.item(drive = " me" , id = " root" ).children.add(i)
73- </ code ></ pre >
78+ ```
7479
7580Copying an Item
7681---------------
7782
78- <pre ><code >from onedrivesdk.item_reference import ItemReference
83+ ``` python
84+ from onedrivesdk.item_reference import ItemReference
7985
8086ref = ItemReference()
8187ref.id = " yourparent!id" # path also supported
@@ -87,30 +93,32 @@ copy_operation = client.item(drive="me", id="youritemtocopy!id").copy(name="new
8793# and copy_operation.item is no longer None
8894copy_operation.poll_until_complete()
8995
90- </ code ></ pre >
96+ ```
9197
9298Renaming an Item
9399----------------
94100
95- <pre ><code >renamed_item = onedrivesdk.Item()
101+ ``` python
102+ renamed_item = onedrivesdk.Item()
96103renamed_item.name = " NewItemName"
97104renamed_item.id = " youritemtorename!id"
98105
99106new_item = client.item(drive = " me" , id = renamed_item.id).update(renamed_item)
100- </ code ></ pre >
107+ ```
101108
102109Paging through a Collection
103110---------------------------
104111
105- <pre ><code >#get the top 3 elements of root, leaving the next page for more elements
112+ ``` python
113+ # get the top 3 elements of root, leaving the next page for more elements
106114collection = client.item(drive = " me" , id = " root" ).children.request(top = 3 ).get()
107115
108116# get the first item in the collection
109117item = collection[0 ]
110118
111119# get next page of 3 elements, if none exist, returns None
112120collection2 = collection.next_page_request.get()
113- </ code ></ pre >
121+ ```
114122
115123Async operations
116124----------------
@@ -120,7 +128,8 @@ For async operations, you create an asyncio.coroutine which
120128implements asyncio.ascompleted, and execute it with
121129loop.run\_ until\_ complete.
122130
123- <pre ><code >import asyncio
131+ ``` python
132+ import asyncio
124133
125134@asyncio.coroutine
126135def run_gets (client ):
@@ -131,4 +140,4 @@ def run_gets(client):
131140
132141loop = asyncio.get_event_loop()
133142loop.run_until_complete(run_gets(client))
134- </ code ></ pre >
143+ ```
0 commit comments