Skip to content
Prev Previous commit
Next Next commit
update CHANGELOG.md and add samples
  • Loading branch information
sarkar-rajarshi committed Feb 29, 2024
commit 8b887cbde2a7ac1ac4c6c3478424a2cc2410b386
12 changes: 12 additions & 0 deletions sdk/communication/azure-communication-jobrouter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Release History
## 1.1.0b1 (Unreleased)

This is the beta release of Azure Communication Job Router Python SDK. For more information, please see the [README][read_me].

This is a Public Preview version, so breaking changes are possible in subsequent releases as we improve the product. To provide feedback, please submit an issue in our [Azure SDK for Python GitHub repo][issues].

### Features Added
- `JobRouterClient`
- `upsert_worker`
- keyword argument `max_concurrent_offers: Optional[int]` added.
- `RouterWorker`
- Add `max_concurrent_offers`

## 1.0.0 (2023-11-01)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,42 @@ def create_worker(self):

# [END create_worker]

def create_worker_w_limit_concurrent_offers(self):
connection_string = self.endpoint
worker_id = self._worker_id
# [START create_worker_w_limit_concurrent_offers]
from azure.communication.jobrouter import (
JobRouterClient,
)
from azure.communication.jobrouter.models import (
RouterWorker,
RouterChannel,
)

# set `connection_string` to an existing ACS endpoint
router_client = JobRouterClient.from_connection_string(conn_str=connection_string)
print("JobRouterClient created successfully!")

router_worker: RouterWorker = router_client.upsert_worker(
worker_id,
RouterWorker(
capacity=100,
queues=["worker-q-1", "worker-q-2"],
channels=[
RouterChannel(channel_id="WebChat", capacity_cost_per_job=1),
RouterChannel(channel_id="WebChatEscalated", capacity_cost_per_job=20),
RouterChannel(channel_id="Voip", capacity_cost_per_job=100),
],
labels={"Location": "NA", "English": 7, "O365": True, "Xbox_Support": False},
tags={"Name": "John Doe", "Department": "IT_HelpDesk"},
max_concurrent_offers=1,
),
)

print(f"Router worker successfully created with id: {router_worker.id}")

# [END create_worker_w_limit_concurrent_offers]

def update_worker(self):
connection_string = self.endpoint
worker_id = self._worker_id
Expand Down Expand Up @@ -235,6 +271,7 @@ def clean_up(self):
sample.setup_distribution_policy()
sample.setup_queues()
sample.create_worker()
sample.create_worker_w_limit_concurrent_offers()
sample.update_worker()
sample.get_worker()
sample.register_worker()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,41 @@ async def create_worker(self):

# [END create_worker_async]

async def create_worker_w_limit_concurrent_offers(self):
connection_string = self.endpoint
worker_id = self._worker_id
# [START create_worker_w_limit_concurrent_offers_async]
from azure.communication.jobrouter.aio import JobRouterClient
from azure.communication.jobrouter.models import (
RouterWorker,
RouterChannel,
)

# set `connection_string` to an existing ACS endpoint
router_client = JobRouterClient.from_connection_string(conn_str=connection_string)
print("JobRouterClient created successfully!")

async with router_client:
router_worker: RouterWorker = await router_client.upsert_worker(
worker_id,
RouterWorker(
capacity=100,
queues=["worker-q-1", "worker-q-2"],
channels=[
RouterChannel(channel_id="WebChat", capacity_cost_per_job=1),
RouterChannel(channel_id="WebChatEscalated", capacity_cost_per_job=20),
RouterChannel(channel_id="Voip", capacity_cost_per_job=100),
],
labels={"Location": "NA", "English": 7, "O365": True, "Xbox_Support": False},
tags={"Name": "John Doe", "Department": "IT_HelpDesk"},
max_concurrent_offers = 1,
),
)

print(f"Router worker successfully created with id: {router_worker.id}")

# [END create_worker_w_limit_concurrent_offers_async]

async def update_worker(self):
connection_string = self.endpoint
worker_id = self._worker_id
Expand Down Expand Up @@ -247,6 +282,7 @@ async def main():
await sample.setup_distribution_policy()
await sample.setup_queues()
await sample.create_worker()
await sample.create_worker_w_limit_concurrent_offers()
await sample.update_worker()
await sample.get_worker()
await sample.register_worker()
Expand Down