-
Notifications
You must be signed in to change notification settings - Fork 43
Task/release cleanup #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a9c89c5
Move azure identity library to dev dependency
samwelkanda 2bb6036
Set version 0.1.0 as the initial development release
samwelkanda d8aa25b
Update flit metadata
samwelkanda 591872e
Add a custom package name for PyPI
samwelkanda 583a0f5
Set package name as msgraph-core
samwelkanda 7810de1
Refactor directory structure to enable 'from msgraph.core' import format
samwelkanda e0c2953
Run both unit and integration tests in a single command
samwelkanda c279e49
Update CI with new directory structure and test command
samwelkanda efa4e74
Add a microsoft license header to files
samwelkanda 6f9a6b0
Remove unused imports
samwelkanda 0414a3b
Make modulues in core to be private
samwelkanda 01025bd
Update samples
samwelkanda 6f0c354
Update the README file with the latest information on how to use the …
samwelkanda 2f2dc95
Explicity name default values
samwelkanda 0b48eff
Update package author email for easier subject tagging
samwelkanda a6b1872
Update sample in README to use InteractiveBrowserCredential for authe…
samwelkanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,4 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ----------------------------------- |
This file contains hidden or 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,10 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
from ._client_factory import HTTPClientFactory | ||
from ._constants import SDK_VERSION | ||
from ._enums import APIVersion, NationalClouds | ||
from ._graph_client import GraphClient | ||
|
||
__version__ = SDK_VERSION |
15 changes: 9 additions & 6 deletions
15
msgraphcore/client_factory.py → msgraph/core/_client_factory.py
This file contains hidden or 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 hidden or 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,11 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
""" | ||
Application constants | ||
""" | ||
REQUEST_TIMEOUT = 100 | ||
CONNECTION_TIMEOUT = 30 | ||
BASE_URL = 'https://graph.microsoft.com/' | ||
SDK_VERSION = '0.1.0' |
This file contains hidden or 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
12 changes: 6 additions & 6 deletions
12
msgraphcore/graph_client.py → msgraph/core/_graph_client.py
This file contains hidden or 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 hidden or 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,4 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ |
This file contains hidden or 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,11 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class TokenCredential(ABC): | ||
@abstractmethod | ||
def get_token(self, *scopes, **kwargs): | ||
pass |
10 changes: 7 additions & 3 deletions
10
msgraphcore/middleware/authorization.py → msgraph/core/middleware/authorization.py
This file contains hidden or 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
7 changes: 5 additions & 2 deletions
7
msgraphcore/middleware/middleware.py → msgraph/core/middleware/middleware.py
This file contains hidden or 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
6 changes: 5 additions & 1 deletion
6
msgraphcore/middleware/request_context.py → msgraph/core/middleware/request_context.py
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,11 +1,17 @@ | ||
[build-system] | ||
requires = ["flit_core >=2,<3", "requests >= 2.23.0"] | ||
requires = ["flit_core >=2,<4", "requests >= 2.23.0"] | ||
build-backend = "flit_core.buildapi" | ||
|
||
[tool.flit.metadata] | ||
module = "msgraphcore" | ||
module = "msgraph" | ||
author = "Microsoft" | ||
author-email = "[email protected]" | ||
samwelkanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
home-page="https://github.com/microsoftgraph/msgraph-sdk-python-core" | ||
dist-name="msgraph-core" | ||
requires=[ | ||
"requests >= 2.23.0", | ||
] | ||
requires-python=">=3.5" | ||
classifiers = ["License :: OSI Approved :: MIT License"] | ||
description-file = "README.md" | ||
|
This file contains hidden or 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,114 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
#pylint: disable=undefined-variable | ||
""" | ||
Demonstrates using the HTTPClientFactory to create a client and make HTTP requests | ||
to Microsoft Graph | ||
""" | ||
import json | ||
from pprint import pprint | ||
|
||
# This sample uses InteractiveBrowserCredential only for demonstration. | ||
# Any azure-identity TokenCredential class will work the same. | ||
from azure.identity import InteractiveBrowserCredential | ||
from requests import Session | ||
|
||
from msgraph.core import APIVersion, HTTPClientFactory, NationalClouds | ||
|
||
scopes = ['user.read'] | ||
browser_credential = InteractiveBrowserCredential(client_id='YOUR_CLIENT_ID') | ||
|
||
# Create client with default middleware | ||
client = HTTPClientFactory().create_with_default_middleware(browser_credential) | ||
|
||
|
||
def get_sample(): | ||
"""Sample HTTP GET request using the client""" | ||
result = client.get( | ||
'/users', | ||
params={ | ||
'$select': 'displayName', | ||
'$top': '10' | ||
}, | ||
) | ||
pprint(result.json()) | ||
|
||
|
||
def post_sample(): | ||
"""Sample HTTP POST request using the client""" | ||
body = { | ||
'message': { | ||
'subject': 'Python SDK Meet for lunch?', | ||
'body': { | ||
'contentType': 'Text', | ||
'content': 'The new cafeteria is open.' | ||
}, | ||
'toRecipients': [{ | ||
'emailAddress': { | ||
'address': 'ENTER_RECEPIENT_EMAIL_ADDRESS' | ||
} | ||
}] | ||
} | ||
} | ||
|
||
result = client \ | ||
.post('/me/sendMail', | ||
data=json.dumps(body), | ||
scopes=['mail.send'], | ||
headers={'Content-Type': 'application/json'} | ||
) | ||
pprint(result.status_code) | ||
|
||
|
||
def client_with_custom_session_sample(): | ||
"""Sample client with a custom Session object""" | ||
session = Session() | ||
my_client = HTTPClientFactory(session=session | ||
).create_with_default_middleware(browser_credential) | ||
result = my_client.get('/me') | ||
pprint(result.json()) | ||
|
||
|
||
def client_with_custom_settings_sample(): | ||
"""Sample client that makes requests against the beta api on a specified cloud endpoint""" | ||
my_client = HTTPClientFactory( | ||
credential=browser_credential, | ||
api_version=APIVersion.beta, | ||
cloud=NationalClouds.Germany, | ||
).create_with_default_middleware(browser_credential) | ||
result = my_client.get( | ||
'/users', | ||
params={ | ||
'$select': 'displayName', | ||
'$top': '10' | ||
}, | ||
) | ||
pprint(result.json()) | ||
|
||
|
||
def client_with_custom_middleware(): | ||
"""Sample client with a custom middleware chain""" | ||
middleware = [ | ||
CustomAuthorizationHandler(), | ||
MyCustomMiddleware(), | ||
] | ||
|
||
my_client = HTTPClientFactory().create_with_custom_middleware(middleware) | ||
result = my_client.get( | ||
'https://graph.microsoft.com/v1.0/users', | ||
params={ | ||
'$select': 'displayName', | ||
'$top': '10' | ||
}, | ||
) | ||
pprint(result.json()) | ||
|
||
|
||
if __name__ == '__main__': | ||
get_sample() | ||
post_sample() | ||
client_with_custom_session_sample() | ||
client_with_custom_settings_sample() | ||
client_with_custom_middleware() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.