Skip to content

Commit 4868b8d

Browse files
authored
Merge pull request #250 from microsoftgraph/beta/pipelinebuild/127655
Generated beta models and request builders
2 parents f430900 + a1bce1a commit 4868b8d

File tree

32,261 files changed

+1720166
-1592433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

32,261 files changed

+1720166
-1592433
lines changed

.github/workflows/build_publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
python -m pip install --upgrade pip
2626
pip install -r requirements-dev.txt
2727
- name: Lint with Pylint
28-
run: pylint msgraph --disable=W --rcfile=.pylintrc
28+
run: pylint msgraph_beta --disable=W --rcfile=.pylintrc
2929

3030
deploy:
3131
name: Publish distribution to PyPI

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ disable=long-suffix,
8181
R0801,
8282
R0904,
8383
line-too-long,
84+
import-outside-toplevel,
8485

8586

8687
# Enable the message, report, category or checker with the given id(s). You can

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.0rc0] - 2023-10-27
9+
10+
### Added
11+
- Added request translation method to native request object
12+
- Added opentelemetry to support observability.
13+
- Added support for continous access evaluation.
14+
- Added backing store support and enabled backing store by default.
15+
16+
17+
### Changed
18+
- Refactored request headers from dictionary to HeaderCollection class.
19+
- Fix issue with using raw url in request builder due to incorrect parameter order.
20+
- Switched from uritemplate to std-uritemplate for URI templating.
21+
- Simplified the creation of a graph client.
22+
23+
24+
## [1.0.0a8] - 2023-04-25
25+
26+
### Added
27+
28+
### Changed
29+
30+
- Changed the request builders api to include indexers as part of the path. [#2528](https://github.com/microsoft/kiota/issues/2528)
31+
832
## [1.0.0a8] - 2023-04-25
933

1034
### Added

README.md

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,22 @@ pip install msgraph-beta-sdk
1818

1919
Register your application by following the steps at [Register your app with the Microsoft Identity Platform](https://docs.microsoft.com/graph/auth-register-app-v2).
2020

21-
### 2.2 Create an AuthenticationProvider object
21+
### 2.3 Get a GraphServiceClient object
22+
23+
You must get a **GraphServiceClient** object to make requests against the service.
2224

23-
An instance of the **GraphServiceClient** class handles building client. To create a new instance of this class, you need to provide an instance of **AuthenticationProvider**, which can authenticate requests to Microsoft Graph.
25+
An instance of the **GraphServiceClient** class handles building client. To create a new instance of this class, you need to provide an instance of **Credential**, which can authenticate requests to Microsoft Graph.
2426

2527
> **Note**: For authentication we support both `sync` and `async` credential classes from `azure.identity`. Please see the azure identity [docs](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python) for more information.
2628
2729
```py
2830
# Example using async credentials.
2931
from azure.identity.aio import EnvironmentCredential
30-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
32+
from msgraph_beta import GraphServiceClient
3133

3234
scopes = ['User.Read', 'Mail.Read']
3335
credential=EnvironmentCredential()
34-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
35-
```
36-
37-
### 2.3 Initialise a GraphRequestAdapter object
38-
39-
The SDK uses an adapter object that handles the HTTP concerns. This HTTP adapter object is used to build the Graph client for making requests.
40-
41-
To initialise one using the authentication provider created in the previous step:
42-
43-
```py
44-
from msgraph import GraphRequestAdapter
45-
46-
adapter = GraphRequestAdapter(auth_provider)
47-
```
48-
49-
We currently use [HTTPX](https://www.python-httpx.org/) as our HTTP client. You can pass your custom configured `httpx.AsyncClient` using:
50-
51-
```py
52-
from msgraph import GraphRequestAdapter
53-
from msgraph_core import GraphClientFactory
54-
55-
http_Client = GraphClientFactory.create_with_default_middleware(client=httpx.AsyncClient())
56-
request_adapter = GraphRequestAdapter(auth_Provider, http_client)
57-
```
58-
59-
### 2.3 Get a GraphServiceClient object
60-
61-
You must get a **GraphServiceClient** object to make requests against the service.
62-
63-
```py
64-
from msgraph import GraphServiceClient
65-
66-
client = GraphServiceClient(request_adapter)
36+
client = GraphServiceClient(credentials, scopes=scopes)
6737
```
6838

6939
## 3. Make requests against the service
@@ -77,25 +47,20 @@ The following is a complete example that shows how to fetch a user from Microsof
7747
```py
7848
import asyncio
7949
from azure.identity.aio import ClientSecretCredential
80-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
81-
from msgraph import GraphRequestAdapter
82-
from msgraph import GraphServiceClient
50+
from msgraph_beta import GraphServiceClient
8351

8452
credential = ClientSecretCredential(
8553
'tenant_id',
8654
'client_id',
8755
'client_secret'
8856
)
8957
scopes = ['https://graph.microsoft.com/.default']
90-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
91-
request_adapter = GraphRequestAdapter(auth_provider)
92-
client = GraphServiceClient(request_adapter)
58+
client = GraphServiceClient(credential, scopes=scopes)
9359

9460
async def get_user():
9561
user = await client.users.by_user_id('userPrincipalName').get()
9662
if user:
9763
print(user.display_name)
98-
9964
asyncio.run(get_user())
10065
```
10166

@@ -104,21 +69,16 @@ Note that to calling `me` requires a signed-in user and therefore delegated perm
10469
```py
10570
import asyncio
10671
from azure.identity import InteractiveBrowserCredential
107-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
108-
from msgraph import GraphRequestAdapter
109-
from msgraph import GraphServiceClient
72+
from msgraph_beta import GraphServiceClient
11073

11174
credential = InteractiveBrowserCredential()
11275
scopes=['User.Read']
113-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
114-
request_adapter = GraphRequestAdapter(auth_provider)
115-
client = GraphServiceClient(request_adapter)
76+
client = GraphServiceClient(credential, scopes=scopes)
11677

11778
async def me():
11879
me = await client.me.get()
11980
if me:
12081
print(me.display_name)
121-
12282
asyncio.run(me())
12383
```
12484

@@ -133,11 +93,8 @@ async def get_user():
13393
print(user.user_principal_name, user.display_name, user.id)
13494
except APIError as e:
13595
print(f'Error: {e.error.message}')
136-
13796
asyncio.run(get_user())
13897
```
139-
140-
14198
## Documentation and resources
14299

143100
* [Overview](https://docs.microsoft.com/graph/overview)

docs/applications_samples.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,25 @@
44
import asyncio
55

66
from azure.identity import EnvironmentCredential
7-
from kiota_abstractions.api_error import APIError
8-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
9-
from msgraph import GraphRequestAdapter
10-
from msgraph import GraphServiceClient
7+
from msgraph_beta import GraphServiceClient
118

129
# Set the event loop policy for Windows
1310
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
1411

1512
# Create authentication provider object. Used to authenticate request
1613
credential=EnvironmentCredential()
17-
auth_provider = AzureIdentityAuthenticationProvider(credential)
18-
19-
# Initialize a request adapter. Handles the HTTP concerns.
20-
request_adapter = GraphRequestAdapter(auth_provider)
2114

2215
# Get a service client.
23-
client = GraphServiceClient(request_adapter)
16+
client = GraphServiceClient(credentials=credential)
2417
```
2518

2619
## 1. LIST ALL APPLICATIONS IN THE TENANT (GET /applications)
2720

2821
```py
2922
async def get_applications():
30-
try:
31-
apps = await client.applications.get()
32-
if apps and apps.value:
33-
for app in apps.value:
34-
print(app.id)
35-
except APIError as e:
36-
print(e.error.message)
23+
apps = await client.applications.get()
24+
if apps and apps.value:
25+
for app in apps.value:
26+
print(app.id)
3727
asyncio.run(get_applications())
3828
```

docs/authentication_samples.md

Lines changed: 24 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import asyncio
77

88
from azure.identity import DeviceCodeCredential
9-
from kiota_abstractions.api_error import APIError
10-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
11-
from msgraph import GraphRequestAdapter, GraphServiceClient
9+
from msgraph_beta import GraphServiceClient
1210

1311
# Set the event loop policy for Windows
1412
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
@@ -20,23 +18,15 @@ credential = DeviceCodeCredential(
2018
)
2119

2220
scopes = ["User.Read"]
23-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
2421

25-
# Initialize a request adapter with the auth provider.
26-
request_adapter = GraphRequestAdapter(auth_provider)
27-
28-
# Create an API client with the request adapter.
29-
client = GraphServiceClient(request_adapter)
22+
# Create an API client with the credentials and scopes.
23+
client = GraphServiceClient(credential, scopes=scopes)
3024

3125
# GET A USER USING THE USER ID (GET /users/{id})
3226
async def get_user():
33-
try:
34-
user = await client.users_by_id('USER_ID').get()
35-
if user:
36-
print(user.user_principal_name, user.display_name, user.id)
37-
except APIError as e:
38-
print(f'Error: {e.error.message}')
39-
27+
user = await client.users_by_id('USER_ID').get()
28+
if user:
29+
print(user.user_principal_name, user.display_name, user.id)
4030
asyncio.run(get_user())
4131
```
4232

@@ -45,32 +35,22 @@ asyncio.run(get_user())
4535
```py
4636
import asyncio
4737
from azure.identity import InteractiveBrowserCredential
48-
from kiota_abstractions.api_error import APIError
49-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
50-
from msgraph import GraphRequestAdapter, GraphServiceClient
38+
from msgraph_beta import GraphServiceClient
5139

5240
# Set the event loop policy for Windows
5341
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
5442

5543
# Create authentication provider object. Used to authenticate requests
5644
credential = InteractiveBrowserCredential()
5745
scopes = ["User.Read"]
58-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
59-
60-
# Initialize a request adapter with the auth provider.
61-
request_adapter = GraphRequestAdapter(auth_provider)
62-
63-
# Create an API client with the request adapter.
64-
client = GraphServiceClient(request_adapter)
46+
# Create an API client with the credentials and scopes.
47+
client = GraphServiceClient(credential, scopes=scopes)
6548

6649
# GET A USER USING THE USER ID (GET /users/{id})
6750
async def get_user():
68-
try:
69-
user = await client.users_by_id('USER_ID').get()
70-
if user:
71-
print(user.user_principal_name, user.display_name, user.id)
72-
except APIError as e:
73-
print(f'Error: {e.error.message}')
51+
user = await client.users_by_id('USER_ID').get()
52+
if user:
53+
print(user.user_principal_name, user.display_name, user.id)
7454
asyncio.run(get_user())
7555
```
7656

@@ -82,9 +62,7 @@ asyncio.run(get_user())
8262
import asyncio
8363

8464
from azure.identity import ClientSecretCredential
85-
from kiota_abstractions.api_error import APIError
86-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
87-
from msgraph import GraphRequestAdapter, GraphServiceClient
65+
from msgraph_beta import GraphServiceClient
8866

8967
# Set the event loop policy for Windows
9068
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
@@ -96,22 +74,15 @@ credential = ClientSecretCredential(
9674
client_secret='CLIENT_SECRET'
9775
)
9876
scopes = ['https://graph.microsoft.com/.default']
99-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
100-
101-
# Initialize a request adapter with the auth provider.
102-
request_adapter = GraphRequestAdapter(auth_provider)
10377

104-
# Create an API client with the request adapter.
105-
client = GraphServiceClient(request_adapter)
78+
# Create an API client with the credentials and scopes.
79+
client = GraphServiceClient(credential, scopes=scopes)
10680

10781
# GET A USER USING THE USER ID (GET /users/{id})
10882
async def get_user():
109-
try:
110-
user = await client.users.by_user_id('USER_ID').get()
111-
if user:
112-
print(user.user_principal_name, user.display_name, user.id)
113-
except APIError as e:
114-
print(f'Error: {e.error.message}')
83+
user = await client.users.by_user_id('USER_ID').get()
84+
if user:
85+
print(user.user_principal_name, user.display_name, user.id)
11586
asyncio.run(get_user())
11687
```
11788

@@ -121,31 +92,22 @@ asyncio.run(get_user())
12192
import asyncio
12293

12394
from azure.identity.aio import EnvironmentCredential
124-
from kiota_abstractions.api_error import APIError
125-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
126-
from msgraph import GraphRequestAdapter, GraphServiceClient
95+
from msgraph_beta import GraphServiceClient
12796

12897
# Set the event loop policy for Windows
12998
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
13099

131100
# Create authentication provider object. Used to authenticate request
132101
credential = EnvironmentCredential()
133102
scopes = ['https://graph.microsoft.com/.default']
134-
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
135-
136-
# Initialize a request adapter with the auth provider.
137-
request_adapter = GraphRequestAdapter(auth_provider)
138103

139-
# Create an API client with the request adapter.
140-
client = GraphServiceClient(request_adapter)
104+
# Create an API client with the credentials and scopes.
105+
client = GraphServiceClient(credential, scopes=scopes)
141106

142107
# GET A USER USING THE USER ID (GET /users/{id})
143108
async def get_user():
144-
try:
145-
user = await client.users.by_user_id('USER_ID').get()
146-
if user:
147-
print(user.user_principal_name, user.display_name, user.id)
148-
except APIError as e:
149-
print(f'Error: {e.error.message}')
109+
user = await client.users.by_user_id('USER_ID').get()
110+
if user:
111+
print(user.user_principal_name, user.display_name, user.id)
150112

151113
asyncio.run(get_user())

0 commit comments

Comments
 (0)