Skip to content

Commit 1793a0b

Browse files
update readme and samples (#32548)
1 parent 25b6533 commit 1793a0b

36 files changed

+401
-483
lines changed

sdk/communication/azure-communication-jobrouter/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ router_admin_client = JobRouterAdministrationClient.from_connection_string(conn_
9292
Before we can create a Queue, we need a Distribution Policy.
9393

9494
```python
95-
from azure.communication.jobrouter import (
95+
from azure.communication.jobrouter.models import (
9696
LongestIdleMode,
9797
DistributionPolicy
9898
)
@@ -106,15 +106,15 @@ distribution_policy: DistributionPolicy = DistributionPolicy(
106106
)
107107

108108
distribution_policy: DistributionPolicy = router_admin_client.create_distribution_policy(
109-
distribution_policy_id = "distribution-policy-1",
109+
id = "distribution-policy-1",
110110
distribution_policy = distribution_policy
111111
)
112112
```
113113
### Queue
114114
Next, we can create the queue.
115115

116116
```python
117-
from azure.communication.jobrouter import (
117+
from azure.communication.jobrouter.models import (
118118
RouterQueue
119119
)
120120

@@ -123,15 +123,15 @@ queue: RouterQueue = RouterQueue(
123123
)
124124

125125
queue: RouterQueue = router_admin_client.create_queue(
126-
queue_id = "queue-1",
126+
id = "queue-1",
127127
queue = queue
128128
)
129129
```
130130

131131
### Job
132132
Now, we can submit a job directly to that queue, with a worker selector the requires the worker to have the label `Some-Skill` greater than 10.
133133
```python
134-
from azure.communication.jobrouter import (
134+
from azure.communication.jobrouter.models import (
135135
RouterJob,
136136
RouterWorkerSelector,
137137
LabelOperator
@@ -148,15 +148,15 @@ router_job: RouterJob = RouterJob(
148148
)
149149

150150
job: RouterJob = router_client.create_job(
151-
job_id = "jobId-1",
151+
id = "jobId-1",
152152
router_job = router_job
153153
)
154154
```
155155

156156
### Worker
157157
Now, we register a worker to receive work from that queue, with a label of `Some-Skill` equal to 11.
158158
```python
159-
from azure.communication.jobrouter import (
159+
from azure.communication.jobrouter.models import (
160160
RouterWorker,
161161
ChannelConfiguration
162162
)
@@ -209,7 +209,7 @@ for event in events:
209209

210210
However, we could also wait a few seconds and then query the worker directly against the JobRouter API to see if an offer was issued to it.
211211
```python
212-
from azure.communication.jobrouter import (
212+
from azure.communication.jobrouter.models import (
213213
RouterWorker,
214214
)
215215

@@ -221,7 +221,7 @@ for offer in router_worker.offers:
221221
### Accept an offer
222222
Once a worker receives an offer, it can take two possible actions: accept or decline. We are going to accept the offer.
223223
```python
224-
from azure.communication.jobrouter import (
224+
from azure.communication.jobrouter.models import (
225225
RouterJobOffer,
226226
AcceptJobOfferResult,
227227
RouterJobStatus
@@ -262,7 +262,7 @@ print(f"Job has been successfully completed.")
262262
### Closing a job
263263
After a job has been completed, the worker can perform wrap up actions to the job before closing the job and finally releasing its capacity to accept more incoming jobs
264264
```python
265-
from azure.communication.jobrouter import (
265+
from azure.communication.jobrouter.models import (
266266
RouterJob,
267267
RouterJobStatus
268268
)
@@ -282,7 +282,7 @@ print(f"Updated job status: {update_job.job_status == RouterJobStatus.CLOSED}")
282282
```python
283283
import time
284284
from datetime import datetime, timedelta
285-
from azure.communication.jobrouter import (
285+
from azure.communication.jobrouter.models import (
286286
RouterJob,
287287
RouterJobStatus
288288
)

0 commit comments

Comments
 (0)