-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typings enhancements and examples updates
- Loading branch information
Showing
44 changed files
with
257 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
""" | ||
Retrieves site columns | ||
https://learn.microsoft.com/en-us/graph/api/site-list-columns?view=graph-rest-1.0 | ||
""" | ||
from office365.graph_client import GraphClient | ||
from office365.onedrive.columns.definition import ColumnDefinition | ||
from tests.graph_case import acquire_token_by_username_password | ||
|
||
client = GraphClient(acquire_token_by_username_password) | ||
columns = client.sites.root.columns.get().execute_query() | ||
for column in columns: | ||
print(column.name) | ||
print(column) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
List recent files | ||
https://learn.microsoft.com/en-us/graph/api/drive-recent?view=graph-rest-1.0 | ||
""" | ||
from office365.graph_client import GraphClient | ||
from tests import test_client_id, test_password, test_tenant, test_username | ||
|
||
client = GraphClient.with_username_and_password( | ||
test_tenant, test_client_id, test_username, test_password | ||
) | ||
items = client.me.drive.recent().execute_query() | ||
for item in items: | ||
print(item.web_url) |
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
""" | ||
Retrieve a list of worksheet objects. | ||
https://learn.microsoft.com/en-us/graph/api/workbook-list-worksheets?view=graph-rest-1.0 | ||
""" | ||
|
||
import sys | ||
|
||
from examples.onedrive import upload_excel_sample | ||
from office365.graph_client import GraphClient | ||
from tests.graph_case import acquire_token_by_username_password | ||
|
||
client = GraphClient(acquire_token_by_username_password) | ||
drive_item = upload_excel_sample(client) | ||
# Load worksheets | ||
drive_item = client.me.drive.root.get_by_path("Financial Sample.xlsx") | ||
worksheets = drive_item.workbook.worksheets.get().execute_query() | ||
if len(worksheets) == 0: | ||
sys.exit("No worksheets found") | ||
print("Worksheet name: {0}".format(worksheets[0].name)) | ||
|
||
for worksheet in worksheets: | ||
print("Worksheet name: {0}".format(worksheet)) |
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
|
||
def print_progress(offset): | ||
# type: (int) -> None | ||
print("Downloaded '{0}' bytes...".format(offset)) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Lists site permissions. | ||
""" | ||
|
||
from office365.graph_client import GraphClient | ||
from tests import test_team_site_url | ||
from tests.graph_case import acquire_token_by_client_credentials | ||
|
||
client = GraphClient(acquire_token_by_client_credentials) | ||
|
||
site = client.sites.get_by_url(test_team_site_url) | ||
permissions = site.permissions.get().execute_query() | ||
for perm in permissions: | ||
print(perm.granted_to) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Revokes permissions from a site. | ||
https://learn.microsoft.com/en-us/graph/api/site-delete-permission?view=graph-rest-1.0 | ||
""" | ||
|
||
from office365.graph_client import GraphClient | ||
from tests import test_client_credentials, test_team_site_url | ||
from tests.graph_case import acquire_token_by_client_credentials | ||
|
||
client = GraphClient(acquire_token_by_client_credentials) | ||
|
||
app = client.applications.get_by_app_id(test_client_credentials.clientId) | ||
site = client.sites.get_by_url(test_team_site_url) | ||
site.permissions.delete(["write"], app).execute_query() | ||
# site.permissions.delete_all().execute_query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Returns the folder object from the tokenized sharing link URL. | ||
""" | ||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.sharing.links.kind import SharingLinkKind | ||
from tests import test_team_site_url, test_user_credentials | ||
|
||
ctx = ClientContext(test_team_site_url).with_credentials(test_user_credentials) | ||
|
||
folder = ctx.web.get_folder_by_server_relative_url("Shared Documents/Archive") | ||
# Share a folder | ||
result = folder.share_link(SharingLinkKind.OrganizationView).execute_query() | ||
|
||
|
||
shared_folder = ctx.web.get_folder_by_guest_url(str(result.value)).execute_query() | ||
print(shared_folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Demonstrates how to rename a folder | ||
""" | ||
from office365.sharepoint.client_context import ClientContext | ||
from tests import create_unique_name, test_client_credentials, test_team_site_url | ||
|
||
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials) | ||
|
||
folder = ctx.web.default_document_library().root_folder.add( | ||
create_unique_name("Orders - (2007)") | ||
) # create temp folder | ||
|
||
folder.rename("OUT - (Drafts 123)").execute_query() | ||
|
||
folder.delete_object().execute_query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.