Skip to content

Commit da03fd9

Browse files
committed
Update snippets
1 parent a0e704e commit da03fd9

File tree

8 files changed

+62
-80
lines changed

8 files changed

+62
-80
lines changed

articles/communication-services/concepts/router/exception-policy.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ administration_client.create_exception_policy(
9999

100100
```java
101101
administrationClient.createExceptionPolicy(new CreateExceptionPolicyOptions("policy1",
102-
Map.of("rule1", new ExceptionRule()
103-
.setTrigger(new QueueLengthExceptionTrigger().setThreshold(1))
104-
.setActions(Map.of("cancelAction", new CancelExceptionAction())))
102+
Map.of("rule1", new ExceptionRule(
103+
new QueueLengthExceptionTrigger().setThreshold(1)
104+
Map.of("cancelAction", new CancelExceptionAction())))
105105
).setName("Max Queue Length Policy"));
106106
```
107107

@@ -181,12 +181,12 @@ administration_client.create_exception_policy(
181181

182182
```java
183183
administrationClient.createExceptionPolicy(new CreateExceptionPolicyOptions("policy2", Map.of(
184-
"rule1", new ExceptionRule()
185-
.setTrigger(new WaitTimeExceptionTrigger().setThresholdSeconds(60))
186-
.setActions(Map.of("increasePriority", new ManualReclassifyExceptionAction().setPriority(10))),
187-
"rule2", new ExceptionRule()
188-
.setTrigger(new WaitTimeExceptionTrigger().setThresholdSeconds(300))
189-
.setActions(Map.of("changeQueue", new ManualReclassifyExceptionAction().setQueueId("queue2"))))
184+
"rule1", new ExceptionRule(
185+
new WaitTimeExceptionTrigger(60),
186+
Map.of("increasePriority", new ManualReclassifyExceptionAction().setPriority(10))),
187+
"rule2", new ExceptionRule(
188+
new WaitTimeExceptionTrigger(300),
189+
Map.of("changeQueue", new ManualReclassifyExceptionAction().setQueueId("queue2"))))
190190
).setName("Escalation Policy"));
191191
```
192192

articles/communication-services/concepts/router/matching-concepts.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ await client.createWorker("worker-1", {
8181
client.create_worker(worker_id = "worker-1", router_worker = RouterWorker(
8282
total_capacity = 2,
8383
queue_assignments = {
84-
"queue2": QueueAssignment()
84+
"queue2": RouterQueueAssignment()
8585
},
8686
channel_configurations = {
8787
"voice": ChannelConfiguration(capacity_cost_per_job = 2),
@@ -103,11 +103,11 @@ client.create_worker(worker_id = "worker-1", router_worker = RouterWorker(
103103
```java
104104
client.createWorker(new CreateWorkerOptions("worker-1", 2)
105105
.setQueueAssignments(Map.of(
106-
"queue1", new QueueAssignment(),
107-
"queue2", new QueueAssignment()))
106+
"queue1", new RouterQueueAssignment(),
107+
"queue2", new RouterQueueAssignment()))
108108
.setChannelConfigurations(Map.of(
109-
"voice", new ChannelConfiguration().setCapacityCostPerJob(2),
110-
"chat", new ChannelConfiguration().setCapacityCostPerJob(1)))
109+
"voice", new ChannelConfiguration(2),
110+
"chat", new ChannelConfiguration(1)))
111111
.setLabels(Map.of(
112112
"Skill", new LabelValue(11),
113113
"English", new LabelValue(true),
@@ -194,14 +194,8 @@ client.create_job(job_id = "job1", router_job = RouterJob(
194194
```java
195195
client.createJob(new CreateJobOptions("job1", "chat", "queue1")
196196
.setRequestedWorkerSelectors(List.of(
197-
new RouterWorkerSelector()
198-
.setKey("English")
199-
.setLabelOperator(LabelOperator.EQUAL)
200-
.setValue(new LabelValue(true)),
201-
new RouterWorkerSelector()
202-
.setKey("Skill")
203-
.setLabelOperator(LabelOperator.GREATER_THAN)
204-
.setValue(new LabelValue(10))))
197+
new RouterWorkerSelector("English", LabelOperator.EQUAL, new LabelValue(true)),
198+
new RouterWorkerSelector("Skill", LabelOperator.GREATER_THAN, new LabelValue(10))))
205199
.setLabels(Map.of("name", new LabelValue("John"))));
206200
```
207201

articles/communication-services/concepts/router/worker-capacity-concepts.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ client.create_worker(worker_id = "worker1", router_worker = RouterWorker(
7979
client.createWorker(new CreateWorkerOptions("worker1", 100)
8080
.setQueueAssignments(Map.of("queue1", new RouterQueueAssignment()))
8181
.setChannelConfigurations(Map.of(
82-
"voice", new ChannelConfiguration().setCapacityCostPerJob(100),
83-
"chat", new ChannelConfiguration().setCapacityCostPerJob(20))))
82+
"voice", new ChannelConfiguration(100),
83+
"chat", new ChannelConfiguration(20))));
8484
```
8585

8686
::: zone-end
@@ -147,9 +147,9 @@ client.create_worker(worker_id = "worker1", router_worker = RouterWorker(
147147
client.createWorker(new CreateWorkerOptions("worker1", 100)
148148
.setQueueAssignments(Map.of("queue1", new RouterQueueAssignment()))
149149
.setChannelConfigurations(Map.of(
150-
"voice", new ChannelConfiguration().setCapacityCostPerJob(60),
151-
"chat", new ChannelConfiguration().setCapacityCostPerJob(10).setMaxNumberOfJobs(2),
152-
"email", new ChannelConfiguration().setCapacityCostPerJob(10).setMaxNumberOfJobs(2))))
150+
"voice", new ChannelConfiguration(60),
151+
"chat", new ChannelConfiguration(10).setMaxNumberOfJobs(2),
152+
"email", new ChannelConfiguration(10).setMaxNumberOfJobs(2))));
153153
```
154154

155155
::: zone-end

articles/communication-services/how-tos/router-sdk/escalate-job.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var classificationPolicy = await administrationClient.CreateClassificationPolicy
4545
{
4646
new ConditionalQueueSelectorAttachment(
4747
condition: new ExpressionRouterRule("job.Escalated = true"),
48-
labelSelectors: new List<RouterQueueSelector>
48+
queueSelectors: new List<RouterQueueSelector>
4949
{
5050
new (key: "Id", labelOperator: LabelOperator.Equal, value: new LabelValue("XBOX_Escalation_Queue"))
5151
})
@@ -67,7 +67,7 @@ var classificationPolicy = await administrationClient.createClassificationPolicy
6767
kind: "expression-rule",
6868
expression: 'job.Escalated = true'
6969
},
70-
labelSelectors: [{
70+
queueSelectors: [{
7171
key: "Id",
7272
labelOperator: "equal",
7373
value: "XBOX_Escalation_Queue"
@@ -91,7 +91,7 @@ classification_policy: ClassificationPolicy = administration_client.create_class
9191
queue_selectors = [
9292
ConditionalQueueSelectorAttachment(
9393
condition = ExpressionRouterRule(expression = 'job.Escalated = true'),
94-
label_selectors = [
94+
queue_selectors = [
9595
RouterQueueSelector(key = "Id", label_operator = LabelOperator.EQUAL, value = "XBOX_Escalation_Queue")
9696
]
9797
)
@@ -107,12 +107,10 @@ classification_policy: ClassificationPolicy = administration_client.create_class
107107
ClassificationPolicy classificationPolicy = administrationClient.createClassificationPolicy(
108108
new CreateClassificationPolicyOptions("Classify_XBOX_Voice_Jobs")
109109
.setName("Classify XBOX Voice Jobs")
110-
.setQueueSelectors(List.of(new ConditionalQueueSelectorAttachment()
111-
.setCondition(new ExpressionRouterRule().setExpression("job.Escalated = true"))
112-
.setLabelSelectors(List.of(
113-
new RouterQueueSelector().setKey("Id").setLabelOperator(LabelOperator.EQUAL).setValue("XBOX_Escalation_Queue"))
114-
)))
115-
.setPrioritizationRule(new ExpressionRouterRule().setExpression("If(job.Escalated = true, 10, 1)")));
110+
.setQueueSelectors(List.of(new ConditionalQueueSelectorAttachment(
111+
new ExpressionRouterRule("job.Escalated = true"),
112+
List.of(new RouterQueueSelector("Id", LabelOperator.EQUAL, new LabelValue("XBOX_Escalation_Queue"))))))
113+
.setPrioritizationRule(new ExpressionRouterRule("If(job.Escalated = true, 10, 1)")));
116114
```
117115

118116
::: zone-end
@@ -188,9 +186,8 @@ administration_client.create_exception_policy(
188186

189187
```java
190188
administrationClient.createExceptionPolicy(new CreateExceptionPolicyOptions("Escalate_XBOX_Policy",
191-
Map.of("Escalated_Rule", new ExceptionRule()
192-
.setTrigger(new WaitTimeExceptionTrigger().setThresholdSeconds(5 * 60))
193-
.setActions(Map.of("EscalateReclassifyExceptionAction", new ReclassifyExceptionAction()
189+
Map.of("Escalated_Rule", new ExceptionRule(new WaitTimeExceptionTrigger(5 * 60),
190+
Map.of("EscalateReclassifyExceptionAction", new ReclassifyExceptionAction()
194191
.setClassificationPolicyId(classificationPolicy.getId())
195192
.setLabelsToUpsert(Map.of("Escalated", new LabelValue(true))))))
196193
).setName("Add escalated label and reclassify XBOX Job requests after 5 minutes"));
@@ -282,9 +279,9 @@ When you submit the Job, it is added to the queue `XBOX_Queue` with the `voice`
282279
```csharp
283280
await client.CreateJobAsync(new CreateJobOptions(jobId: "job1", channelId: "voice", queueId: defaultQueue.Value.Id)
284281
{
285-
RequestedWorkerSelectors = new List<RouterWorkerSelector>
282+
RequestedWorkerSelectors =
286283
{
287-
new(key: "XBOX_Hardware", labelOperator: LabelOperator.GreaterThanEqual, value: new LabelValue(7))
284+
new RouterWorkerSelector(key: "XBOX_Hardware", labelOperator: LabelOperator.GreaterThanEqual, value: new LabelValue(7))
288285
}
289286
});
290287
```
@@ -322,10 +319,8 @@ administration_client.create_job(
322319

323320
```java
324321
administrationClient.createJob(new CreateJobOptions("job1", "voice", defaultQueue.getId())
325-
.setRequestedWorkerSelectors(List.of(new RouterWorkerSelector()
326-
.setKey("XBOX_Hardware")
327-
.setLabelOperator(LabelOperator.GREATER_THAN_EQUAL)
328-
.setValue(new LabelValue(7)))));
322+
.setRequestedWorkerSelectors(List.of(
323+
new RouterWorkerSelector("XBOX_Hardware", LabelOperator.GREATER_THAN_EQUAL, new LabelValue(7)))));
329324
```
330325

331326
::: zone-end

articles/communication-services/how-tos/router-sdk/job-classification.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,9 @@ classification_policy: ClassificationPolicy = administration_client.create_class
104104
ClassificationPolicy classificationPolicy = administrationClient.createClassificationPolicy(
105105
new CreateClassificationPolicyOptions("XBOX_NA_QUEUE_Priority_1_10")
106106
.setName("Select XBOX Queue and set priority to 1 or 10")
107-
.setQueueSelectors(List.of(new ConditionalQueueSelectorAttachment()
108-
.setCondition(new ExpressionRouterRule().setExpression("job.Region = \"NA\""))
109-
.setQueueSelectors(List.of(
110-
new RouterQueueSelector().setKey("Id").setLabelOperator(LabelOperator.EQUAL).setValue("XBOX_NA_QUEUE"))
111-
)))
107+
.setQueueSelectors(List.of(new ConditionalQueueSelectorAttachment(
108+
new ExpressionRouterRule("job.Region = \"NA\""),
109+
List.of(new RouterQueueSelector("Id", LabelOperator.EQUAL, new LabelValue("XBOX_NA_QUEUE"))))))
112110
.setFallbackQueueId("XBOX_DEFAULT_QUEUE")
113111
.setPrioritizationRule(new ExpressionRouterRule().setExpression("If(job.Hardware_VIP = true, 10, 1)")));
114112
```
@@ -243,8 +241,8 @@ administration_client.create_classification_policy(
243241

244242
```java
245243
administrationClient.createClassificationPolicy(new CreateClassificationPolicyOptions("policy-1")
246-
.setWorkerSelectors(List.of(new StaticWorkerSelectorAttachment()
247-
.setWorkerSelector(new RouterWorkerSelector().setKey("Foo").setLabelOperator(LabelOperator.EQUAL).setValue("Bar")))));
244+
.setWorkerSelectors(List.of(
245+
new StaticWorkerSelectorAttachment(new RouterWorkerSelector("Foo", LabelOperator.EQUAL, new LabelValue("Bar"))))));
248246
```
249247

250248
::: zone-end
@@ -310,9 +308,9 @@ administration_client.create_classification_policy(
310308

311309
```java
312310
administrationClient.createClassificationPolicy(new CreateClassificationPolicyOptions("policy-1")
313-
.setWorkerSelectors(List.of(new ConditionalRouterWorkerSelectorAttachment()
314-
.setCondition(new ExpressionRouterRule().setExpression("job.Urgent = true"))
315-
.setWorkerSelectors(List.of(new RouterWorkerSelector().setKey("Foo").setLabelOperator(LabelOperator.EQUAL).setValue("Bar"))))));
311+
.setWorkerSelectors(List.of(new ConditionalRouterWorkerSelectorAttachment(
312+
new ExpressionRouterRule("job.Urgent = true"),
313+
List.of(new RouterWorkerSelector("Foo", LabelOperator.EQUAL, new LabelValue("Bar")))))));
316314
```
317315

318316
::: zone-end
@@ -370,8 +368,7 @@ administration_client.create_classification_policy(
370368

371369
```java
372370
administrationClient.createClassificationPolicy(new CreateClassificationPolicyOptions("policy-1")
373-
.setWorkerSelectors(List.of(new PassThroughWorkerSelectorAttachment()
374-
.setKey("Foo").setLabelOperator(LabelOperator.EQUAL))));
371+
.setWorkerSelectors(List.of(new PassThroughWorkerSelectorAttachment("Foo", LabelOperator.EQUAL))));
375372
```
376373

377374
::: zone-end
@@ -449,10 +446,10 @@ administration_client.create_classification_policy(
449446

450447
```java
451448
administrationClient.createClassificationPolicy(new CreateClassificationPolicyOptions("policy-1")
452-
.setWorkerSelectors(List.of(new WeightedAllocationWorkerSelectorAttachment()
453-
.setAllocations(List.of(new WorkerWeightedAllocation().setWeight(0.3).setWorkerSelectors(List.of(
454-
new RouterWorkerSelector().setKey("Vendor").setLabelOperator(LabelOperator.EQUAL).setValue("A"),
455-
new RouterWorkerSelector().setKey("Vendor").setLabelOperator(LabelOperator.EQUAL).setValue("B")
449+
.setWorkerSelectors(List.of(new WeightedAllocationWorkerSelectorAttachment(
450+
List.of(new WorkerWeightedAllocation(0.3, List.of(
451+
new RouterWorkerSelector("Vendor", LabelOperator.EQUAL, new LabelValue("A")),
452+
new RouterWorkerSelector("Vendor", LabelOperator.EQUAL, new LabelValue("B"))
456453
)))))));
457454
```
458455

articles/communication-services/how-tos/router-sdk/preferred-worker.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,11 @@ client.create_job(job_id = "job1", router_job = RouterJob(
9191

9292
```java
9393
client.createJob(new CreateJobOptions("job1", "Xbox_Chat_Channel", queue.getId())
94-
.setRequestedWorkerSelectors(List.of(new RouterWorkerSelector().setKey("Id")
95-
.setLabelOperator(LabelOperator.EQUAL)
96-
.setValue(new LabelValue("<preferred_worker_id>"))
97-
.setExpireAfterSeconds(45.0)
98-
.setExpedite(true))));
99-
```
94+
.setRequestedWorkerSelectors(List.of(
95+
new RouterWorkerSelector("Id", LabelOperator.EQUAL, new LabelValue("<preferred_worker_id>"))
96+
.setExpireAfterSeconds(45.0)
97+
.setExpedite(true))));
98+
```
10099

101100
::: zone-end
102101

articles/communication-services/how-tos/router-sdk/scheduled-jobs.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ In the following example, a job is created that will be scheduled 3 minutes from
4040
```csharp
4141
await client.CreateJobAsync(new CreateJobOptions(jobId: "job1", channelId: "Voice", queueId: "Callback")
4242
{
43-
MatchingMode = new ScheduleAndSuspendMode(scheduleAt: DateTimeOffset.UtcNow.Add(TimeSpan.FromMinutes(3)))
43+
MatchingMode = new JobMatchingMode(
44+
new ScheduleAndSuspendMode(scheduleAt: DateTimeOffset.UtcNow.Add(TimeSpan.FromMinutes(3))))
4445
});
4546
```
4647

@@ -53,7 +54,6 @@ await client.createJob("job1", {
5354
channelId: "Voice",
5455
queueId: "Callback",
5556
matchingMode: {
56-
modeType: "scheduleAndSuspendMode",
5757
scheduleAndSuspendMode: {
5858
scheduleAt: new Date(Date.now() + 3 * 60000)
5959
}
@@ -70,7 +70,6 @@ client.create_job(job_id = "job1", router_job = RouterJob(
7070
channel_id = "Voice",
7171
queue_id = "Callback",
7272
matching_mode = JobMatchingMode(
73-
mode_type = "scheduleAndSuspendMode",
7473
schedule_and_suspend_mode = ScheduleAndSuspendMode(scheduled_at = datetime.utcnow() + timedelta(minutes = 3)))))
7574
```
7675

@@ -80,7 +79,7 @@ client.create_job(job_id = "job1", router_job = RouterJob(
8079

8180
```java
8281
client.createJob(new CreateJobOptions("job1", "Voice", "Callback")
83-
.setMatchingMode(new ScheduleAndSuspendMode(OffsetDateTime.now().plusMinutes(3))));
82+
.setMatchingMode(new JobMatchingMode(new ScheduleAndSuspendMode(OffsetDateTime.now().plusMinutes(3)))));
8483
```
8584

8685
::: zone-end
@@ -99,7 +98,7 @@ if (eventGridEvent.EventType == "Microsoft.Communication.RouterJobWaitingForActi
9998
10099
await client.UpdateJobAsync(new UpdateJobOptions(jobId: eventGridEvent.Data.JobId)
101100
{
102-
MatchingMode = new QueueAndMatchMode(),
101+
MatchingMode = new JobMatchingMode(new QueueAndMatchMode()),
103102
Priority = 100
104103
});
105104
}
@@ -116,7 +115,7 @@ if (eventGridEvent.EventType == "Microsoft.Communication.RouterJobWaitingForActi
116115
// Perform required actions here
117116

118117
await client.updateJob(eventGridEvent.data.jobId, {
119-
matchingMode: { modeType: "queueAndMatchMode", queueAndMatchMode: {} },
118+
matchingMode: { queueAndMatchMode: {} },
120119
priority: 100
121120
});
122121
}
@@ -133,7 +132,7 @@ if (eventGridEvent.event_type == "Microsoft.Communication.RouterJobWaitingForAct
133132
# Perform required actions here
134133

135134
client.update_job(job_id = eventGridEvent.data.job_id,
136-
matching_mode = JobMatchingMode(mode_type = queueAndMatchMode, queue_and_match_mode = {}),
135+
matching_mode = JobMatchingMode(queue_and_match_mode = {}),
137136
priority = 100)
138137
}
139138
```
@@ -149,7 +148,7 @@ if (eventGridEvent.EventType == "Microsoft.Communication.RouterJobWaitingForActi
149148
// Perform required actions here
150149

151150
client.updateJob(new UpdateJobOptions(eventGridEvent.Data.JobId)
152-
.setMatchingMode(new QueueAndMatchMode())
151+
.setMatchingMode(new JobMatchingMode(new QueueAndMatchMode()))
153152
.setPriority(100));
154153
}
155154
```

articles/communication-services/quickstarts/router/includes/router-quickstart-java.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,8 @@ Now, we can submit a job directly to that queue, with a worker selector that req
151151
```java
152152
RouterJob job = routerClient.createJob(new CreateJobOptions("job-1", "voice", queue.getId())
153153
.setPriority(1)
154-
.setRequestedWorkerSelectors(List.of(new RouterWorkerSelector()
155-
.setKey("Some-Skill")
156-
.setLabelOperator(LabelOperator.GREATER_THAN)
157-
.setValue(new LabelValue(10)))));
154+
.setRequestedWorkerSelectors(List.of(
155+
new RouterWorkerSelector("Some-Skill", LabelOperator.GREATER_THAN, new LabelValue(10)))));
158156
```
159157

160158
## Create a worker
@@ -166,7 +164,7 @@ RouterWorker worker = routerClient.createWorker(
166164
new CreateWorkerOptions("worker-1", 1)
167165
.setQueueAssignments(Map.of(queue.getId(), new RouterQueueAssignment()))
168166
.setLabels(Map.of("Some-Skill", new LabelValue(11)))
169-
.setChannelConfigurations(Map.of("voice", new ChannelConfiguration().setCapacityCostPerJob(1))));
167+
.setChannelConfigurations(Map.of("voice", new ChannelConfiguration(1))));
170168
```
171169

172170
## Receive an offer

0 commit comments

Comments
 (0)