Skip to content

Commit c61bb25

Browse files
committed
rename client to graph_client
1 parent ac501ad commit c61bb25

File tree

4 files changed

+12
-29
lines changed

4 files changed

+12
-29
lines changed

samples/batch_requests/batch_request_with_collection.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@
1616

1717
from msgraph_core.requests.batch_request_content import BatchRequestContent
1818
from msgraph_core.requests.batch_request_content_collection import BatchRequestContentCollection
19-
from msgraph_core.requests.batch_request_builder import BatchRequestBuilder
2019
# Create a client
2120
# code to create graph client
2221

23-
user_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
22+
graph_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
2423

2524
# Create a request adapter from the client
26-
request_adapter = user_client.request_adapter
27-
28-
# Create an instance of BatchRequestBuilder
29-
batch_request_builder = BatchRequestBuilder(request_adapter)
25+
request_adapter = graph_client.request_adapter
3026

3127
# Create some BatchRequestItems
3228

@@ -86,7 +82,7 @@
8682
# post a collection
8783
async def main():
8884

89-
batch_response_content = await client.batch.post(batch_request_content=collection)
85+
batch_response_content = await graph_client.batch.post(batch_request_content=collection)
9086
responses = batch_response_content.get_responses()
9187
for item in responses:
9288
for item_body in item.responses:

samples/batch_requests/batch_request_with_content.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@
1616

1717
from msgraph_core.requests.batch_response_content import BatchResponseContent
1818
from msgraph_core.requests.batch_response_content_collection import BatchResponseContentCollection
19-
from msgraph_core.requests.batch_request_builder import BatchRequestBuilder
2019

2120
# Create a client
2221
# code to create a graph client
23-
user_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
22+
graph_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
2423

2524
# Create a request adapter from the clinet
26-
request_adapter = user_client.request_adapter
27-
28-
# Create an instance of BatchRequestBuilder
29-
batch_request_builder = BatchRequestBuilder(request_adapter)
25+
request_adapter = graph_client.request_adapter
3026

3127
# Create batch Items
3228
request_info1 = RequestInformation()
@@ -55,7 +51,7 @@
5551

5652

5753
async def main():
58-
batch_response_content = await client.batch.post(batch_request_content=batch_content)
54+
batch_response_content = await graph_client.batch.post(batch_request_content=batch_content)
5955

6056
# Print the batch response content
6157
print(f"Batch Response Content: {batch_response_content.responses}")

samples/batch_requests/batch_request_with_custom_error_class.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
from msgraph_core.requests.batch_request_content import BatchRequestContent
2020

2121
from msgraph_core.requests.batch_response_content import BatchResponseContent
22-
from msgraph_core.requests.batch_request_builder import BatchRequestBuilder
2322
# create client
2423
# code to create client
25-
user_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
24+
graph_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
2625

2726

2827
# Create an Error map Parsable or import it from wherever you have it
@@ -41,10 +40,7 @@ def not_found() -> 'CustomError':
4140

4241

4342
# Create a request adapter from client
44-
request_adapter = user_client.request_adapter
45-
46-
# Create an instance of BatchRequestBuilder
47-
batch_request_builder = BatchRequestBuilder(request_adapter)
43+
request_adapter = graph_client.request_adapter
4844

4945
# Create batch Items
5046
request_info1 = RequestInformation()
@@ -86,7 +82,7 @@ def not_found() -> 'CustomError':
8682
async def main():
8783
error_map = {"400": CustomError, "404": CustomError.not_found}
8884

89-
batch_response_content = await client.batch.post(
85+
batch_response_content = await graph_client.batch.post(
9086
batch_request_content=batch_content, error_map=error_map
9187
)
9288

samples/batch_requests/batch_request_with_parsable_as_response_type.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,16 @@
1414
from msgraph_core.requests.batch_request_item import BatchRequestItem
1515
from msgraph_core.requests.batch_request_content import BatchRequestContent
1616

17-
from msgraph_core.requests.batch_request_builder import BatchRequestBuilder
18-
1917
# import User model to serialize to
2018
from msgraph.generated.models.user import User
2119
# Create a client
2220
# code to create graph client
23-
user_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
21+
graph_client = GraphServiceClient(credentials=token, scopes=graph_scopes)
2422

2523
print(f"Graph Scopes: {graph_scopes}")
2624

2725
# Create a request adapter from the client
28-
request_adapter = user_client.request_adapter
29-
30-
# Create an instance of BatchRequestBuilder
31-
batch_request_builder = BatchRequestBuilder(request_adapter)
26+
request_adapter = graph_client.request_adapter
3227

3328
# Create batch Items
3429
request_info1 = RequestInformation()
@@ -59,7 +54,7 @@
5954

6055
# Function to demonstrate the usage of BatchRequestBuilder
6156
async def main():
62-
batch_response_content = await client.batch.post(batch_request_content=batch_content)
57+
batch_response_content = await graph_client.batch.post(batch_request_content=batch_content)
6358
# response_type=User
6459

6560
try:

0 commit comments

Comments
 (0)