azure-communication-jobrouter


Nameazure-communication-jobrouter JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/Azure/azure-sdk-for-python/tree/main/sdk
SummaryMicrosoft Communication JobRouter Client Library for Python
upload_time2023-11-18 00:53:37
maintainerNone
docs_urlNone
authorMicrosoft Corporation
requires_python>=3.7
licenseMIT License
keywords azure azure sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Azure Communication JobRouter Package client library for Python

This package contains a Python SDK for Azure Communication Services for JobRouter.
Read more about Azure Communication Services [here][product_docs]

[Source code][source] | [Package (Pypi)][pypi] | [Product documentation][product_docs]

## _Disclaimer_

_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_

## Getting started

### Prerequisites
You need an [Azure subscription][azure_sub] and a [Communication Service Resource][communication_resource_docs] to use this package.

- Python 3.7 or later is required to use this package. For more details, please read our page on [Azure SDK for Python version support policy](https://github.com/Azure/azure-sdk-for-python/wiki/Azure-SDKs-Python-version-support-policy).
- To create a new Communication Service, you can use the [Azure Portal][communication_resource_create_portal], the [Azure PowerShell][communication_resource_create_power_shell]

### Install the package

Install the Azure Communication JobRouter client library for Python with [pip][pip]:

```bash
pip install azure-communication-jobrouter
```

## Key concepts

### Job
A Job represents the unit of work, which needs to be routed to an available Worker.
A real-world example of this may be an incoming call or chat in the context of a call center.

### Worker
A Worker represents the supply available to handle a Job. Each worker registers with or more queues to receive jobs.
A real-world example of this may be an agent working in a call center.

### Queue
A Queue represents an ordered list of jobs waiting to be served by a worker.  Workers will register with a queue to receive work from it.
A real-world example of this may be a call queue in a call center.

## Channel
A Channel represents a grouping of jobs by some type.  When a worker registers to receive work, they must also specify for which channels they can handle work, and how much of each can they handle concurrently.
A real-world example of this may be `voice calls` or `chats` in a call center.

### Offer
An Offer is extended by JobRouter to a worker to handle a particular job when it determines a match, this notification is normally delivered via [EventGrid][subscribe_events].  The worker can either accept or decline the offer using th JobRouter API, or it will expire according to the time to live configured on the distribution policy.
A real-world example of this may be the ringing of an agent in a call center.

### Distribution Policy
A Distribution Policy represents a configuration set that governs how jobs in a queue are distributed to workers registered with that queue.
This configuration includes how long an Offer is valid before it expires and the distribution mode, which define the order in which workers are picked when there are multiple available.

#### Distribution Mode
The 3 types of modes are
- **Round Robin**: Workers are ordered by `Id` and the next worker after the previous one that got an offer is picked.
- **Longest Idle**: The worker that has not been working on a job for the longest.
- **Best Worker**: You can specify an expression to compare 2 workers to determine which one to pick.

### Labels
You can attach labels to workers, jobs and queues.  These are key value pairs that can be of `string`, `number` or `boolean` data types.
A real-world example of this may be the skill level of a particular worker or the team or geographic location.

### Label Selectors
Label selectors can be attached to a job in order to target a subset of workers serving the queue.
A real-world example of this may be a condition on an incoming call that the agent must have a minimum level of knowledge of a particular product.

### Classification policy
A classification policy can be used to dynamically select a queue, determine job priority and attach worker label selectors to a job by leveraging a rules engine.

### Exception policy
An exception policy controls the behavior of a Job based on a trigger and executes a desired action. The exception policy is attached to a Queue so it can control the behavior of Jobs in the Queue.

## Examples

### Client Initialization
To initialize the SMS Client, the connection string can be used to instantiate.
Alternatively, you can also use Active Directory authentication using DefaultAzureCredential.

```python
from azure.communication.jobrouter import (
    JobRouterClient,
    JobRouterAdministrationClient
)

connection_string = "endpoint=ENDPOINT;accessKey=KEY"
router_client = JobRouterClient.from_connection_string(conn_str = connection_string)
router_admin_client = JobRouterAdministrationClient.from_connection_string(conn_str = connection_string)
```

### Distribution Policy
Before we can create a Queue, we need a Distribution Policy.

```python
from azure.communication.jobrouter.models import (
    LongestIdleMode,
    DistributionPolicy
)

distribution_policy: DistributionPolicy = DistributionPolicy(
    offer_expires_after_seconds = 24 * 60 * 60,
    mode = LongestIdleMode(
        min_concurrent_offers = 1,
        max_concurrent_offers = 1
    )
)

distribution_policy: DistributionPolicy = router_admin_client.upsert_distribution_policy(
    "distribution-policy-1",
    distribution_policy
)
```
### Queue
Next, we can create the queue.

```python
from azure.communication.jobrouter.models import (
    RouterQueue
)

queue: RouterQueue = RouterQueue(
    distribution_policy_id = "distribution-policy-1"
)

queue: RouterQueue = router_admin_client.upsert_queue(
    "queue-1",
    queue
)
```

### Job
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.
```python
from azure.communication.jobrouter.models import (
    RouterJob,
    RouterWorkerSelector,
    LabelOperator
)

router_job: RouterJob = RouterJob(
    channel_id = "my-channel",
    queue_id = "queue-1",
    channel_reference = "12345",
    priority = 1,
    requested_worker_selectors = [
        RouterWorkerSelector(key = "Some-Skill", label_operator = LabelOperator.EQUAL, value = 10)
    ]
)

job: RouterJob = router_client.upsert_job(
    "jobId-1",
    router_job
)
```

### Worker
Now, we register a worker to receive work from that queue, with a label of `Some-Skill` equal to 11.
```python
from azure.communication.jobrouter.models import (
    RouterWorker,
    RouterChannel
)

router_worker: RouterWorker = RouterWorker(
    capacity = 1,
    queues = [
        "queue-1"
    ],
    labels = {
        "Some-Skill": 11
    },
    channels = [
        RouterChannel(channel_id = "my-channel", capacity_cost_per_job = 1)
    ],
    available_for_offers = True
)

worker = router_client.upsert_worker(
    "worker-1",
    router_worker
)
```

### Offer
We should get a [RouterWorkerOfferIssued][offer_issued_event_schema] from our [EventGrid subscription][subscribe_events].

There are several different Azure services that act as a [event handler][event_grid_event_handlers].
For this scenario, we are going to assume Webhooks for event delivery. [Learn more about Webhook event delivery][webhook_event_grid_event_delivery]

Once events are delivered to the event handler, we can deserialize the JSON payload into a list of events.

```python
# Parse the JSON payload into a list of events
from azure.eventgrid import EventGridEvent
import json

## deserialize payload into a list of typed Events
events = [EventGridEvent.from_json(json.loads(msg)) for msg in payload]
```

```python
offer_id = ""
for event in events:
    if event.event_type == "Microsoft.Communication.RouterWorkerOfferIssued":
        offer_id = event.data.offer_id
    else:
        continue
```

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.
```python
from azure.communication.jobrouter.models import (
    RouterWorker,
)

router_worker: RouterWorker = router_client.get_worker(worker_id = "worker-1")

for offer in router_worker.offers:
    print(f"Worker {router_worker.id} has an active offer for job {offer.job_id}")
```
### Accept an offer
Once a worker receives an offer, it can take two possible actions: accept or decline. We are going to accept the offer.
```python
from azure.communication.jobrouter.models import (
    RouterJobOffer,
    AcceptJobOfferResult,
    RouterJobStatus
)

# fetching the offer id
job_offer: RouterJobOffer = [offer for offer in router_worker.offers if offer.job_id == "jobId-1"][0]
offer_id = job_offer.offer_id

# accepting the offer sent to `worker-1`
accept_job_offer_result: AcceptJobOfferResult = router_client.accept_job_offer(
    worker_id = "worker-1",
    offer_id = offer_id
)

print(f"Offer: {job_offer.offer_id} sent to worker: {router_worker.id} has been accepted")
print(f"Job has been assigned to worker: {router_worker.id} with assignment: {accept_job_offer_result.assignment_id}")

# verify job assignment is populated when querying job
updated_job = router_client.get_job(job_id = "jobId-1")
print(f"Job assignment has been successful: {updated_job.job_status == RouterJobStatus.Assigned and accept_job_offer_result.assignment_id in updated_job.assignments}")
```

### Completing a job
Once the worker is done with the job, the worker has to mark the job as `completed`.
```python
import datetime
from azure.communication.jobrouter.models import (
    CompleteJobOptions
)
complete_job_result = router_client.complete_job(
    "jobId-1",
    accept_job_offer_result.assignment_id,
    CompleteJobOptions(
        note = f"Job has been completed by {router_worker.id} at {datetime.datetime.utcnow()}"
    )
)

print(f"Job has been successfully completed.")
```

### Closing a job
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
```python
from azure.communication.jobrouter.models import (
    RouterJob,
    RouterJobStatus,
    CloseJobOptions,
)

close_job_result = router_client.close_job(
    "jobId-1",
    accept_job_offer_result.assignment_id,
    CloseJobOptions(
        note = f"Job has been closed by {router_worker.id} at {datetime.datetime.utcnow()}"
    )
)

print(f"Job has been successfully closed.")

update_job: RouterJob = router_client.get_job(job_id = "jobId-1")
print(f"Updated job status: {update_job.job_status == RouterJobStatus.CLOSED}")
```

```python
import time
from datetime import datetime, timedelta
from azure.communication.jobrouter.models import (
    RouterJob,
    RouterJobStatus,
    CloseJobOptions,
)

close_job_in_future_result = router_client.close_job(
    "jobId-1",
    accept_job_offer_result.assignment_id,
    CloseJobOptions(
        note = f"Job has been closed by {router_worker.id} at {datetime.utcnow()}",
        close_at = datetime.utcnow() + timedelta(seconds = 2)
    )
)

print(f"Job has been marked to close")
time.sleep(secs = 2)
update_job: RouterJob = router_client.get_job(job_id = "jobId-1")
print(f"Updated job status: {update_job.job_status == RouterJobStatus.CLOSED}")
```

## Troubleshooting

Running into issues? This section should contain details as to what to do there.

## Next steps
- [Read more about Router in Azure Communication Services][nextsteps]

### More sample code
Please take a look at the [samples][job_router_samples] directory for detailed examples of how to use this library.

## Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].

This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments.

<!-- LINKS -->
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md
[azure_sub]: https://azure.microsoft.com/free/python/
[cla]: https://cla.microsoft.com
[coc]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:opencode@microsoft.com
[communication_resource_docs]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
[communication_resource_create_portal]:  https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
[communication_resource_create_power_shell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
[communication_resource_create_net]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net
[nextsteps]:https://docs.microsoft.com/azure/communication-services/concepts/router/concepts

[source]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/communication/azure-communication-jobrouter
[product_docs]: https://docs.microsoft.com/azure/communication-services/overview
[classification_concepts]: https://docs.microsoft.com/azure/communication-services/concepts/router/classification-concepts
[subscribe_events]: https://docs.microsoft.com/azure/communication-services/how-tos/router-sdk/subscribe-events
[offer_issued_event_schema]: https://docs.microsoft.com/azure/communication-services/how-tos/router-sdk/subscribe-events#microsoftcommunicationrouterworkerofferissued
[deserialize_event_grid_event_data]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventgrid/azure-eventgrid#consume-from-servicebus
[event_grid_event_handlers]: https://docs.microsoft.com/azure/event-grid/event-handlers
[webhook_event_grid_event_delivery]: https://docs.microsoft.com/azure/event-grid/webhook-event-delivery
[pypi]: https://pypi.org
[pip]: https://pypi.org/project/pip/

[job_router_samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/communication/azure-communication-jobrouter/samples

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk",
    "name": "azure-communication-jobrouter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "azure,azure sdk",
    "author": "Microsoft Corporation",
    "author_email": "azpysdkhelp@microsoft.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/73/9bedf336675a2149c3f5b2bcb4b736657c26517bdc84a87db8ee76c8e8ed/azure-communication-jobrouter-1.0.0.tar.gz",
    "platform": null,
    "description": "# Azure Communication JobRouter Package client library for Python\n\nThis package contains a Python SDK for Azure Communication Services for JobRouter.\nRead more about Azure Communication Services [here][product_docs]\n\n[Source code][source] | [Package (Pypi)][pypi] | [Product documentation][product_docs]\n\n## _Disclaimer_\n\n_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_\n\n## Getting started\n\n### Prerequisites\nYou need an [Azure subscription][azure_sub] and a [Communication Service Resource][communication_resource_docs] to use this package.\n\n- Python 3.7 or later is required to use this package. For more details, please read our page on [Azure SDK for Python version support policy](https://github.com/Azure/azure-sdk-for-python/wiki/Azure-SDKs-Python-version-support-policy).\n- To create a new Communication Service, you can use the [Azure Portal][communication_resource_create_portal], the [Azure PowerShell][communication_resource_create_power_shell]\n\n### Install the package\n\nInstall the Azure Communication JobRouter client library for Python with [pip][pip]:\n\n```bash\npip install azure-communication-jobrouter\n```\n\n## Key concepts\n\n### Job\nA Job represents the unit of work, which needs to be routed to an available Worker.\nA real-world example of this may be an incoming call or chat in the context of a call center.\n\n### Worker\nA Worker represents the supply available to handle a Job. Each worker registers with or more queues to receive jobs.\nA real-world example of this may be an agent working in a call center.\n\n### Queue\nA Queue represents an ordered list of jobs waiting to be served by a worker.  Workers will register with a queue to receive work from it.\nA real-world example of this may be a call queue in a call center.\n\n## Channel\nA Channel represents a grouping of jobs by some type.  When a worker registers to receive work, they must also specify for which channels they can handle work, and how much of each can they handle concurrently.\nA real-world example of this may be `voice calls` or `chats` in a call center.\n\n### Offer\nAn Offer is extended by JobRouter to a worker to handle a particular job when it determines a match, this notification is normally delivered via [EventGrid][subscribe_events].  The worker can either accept or decline the offer using th JobRouter API, or it will expire according to the time to live configured on the distribution policy.\nA real-world example of this may be the ringing of an agent in a call center.\n\n### Distribution Policy\nA Distribution Policy represents a configuration set that governs how jobs in a queue are distributed to workers registered with that queue.\nThis configuration includes how long an Offer is valid before it expires and the distribution mode, which define the order in which workers are picked when there are multiple available.\n\n#### Distribution Mode\nThe 3 types of modes are\n- **Round Robin**: Workers are ordered by `Id` and the next worker after the previous one that got an offer is picked.\n- **Longest Idle**: The worker that has not been working on a job for the longest.\n- **Best Worker**: You can specify an expression to compare 2 workers to determine which one to pick.\n\n### Labels\nYou can attach labels to workers, jobs and queues.  These are key value pairs that can be of `string`, `number` or `boolean` data types.\nA real-world example of this may be the skill level of a particular worker or the team or geographic location.\n\n### Label Selectors\nLabel selectors can be attached to a job in order to target a subset of workers serving the queue.\nA real-world example of this may be a condition on an incoming call that the agent must have a minimum level of knowledge of a particular product.\n\n### Classification policy\nA classification policy can be used to dynamically select a queue, determine job priority and attach worker label selectors to a job by leveraging a rules engine.\n\n### Exception policy\nAn exception policy controls the behavior of a Job based on a trigger and executes a desired action. The exception policy is attached to a Queue so it can control the behavior of Jobs in the Queue.\n\n## Examples\n\n### Client Initialization\nTo initialize the SMS Client, the connection string can be used to instantiate.\nAlternatively, you can also use Active Directory authentication using DefaultAzureCredential.\n\n```python\nfrom azure.communication.jobrouter import (\n    JobRouterClient,\n    JobRouterAdministrationClient\n)\n\nconnection_string = \"endpoint=ENDPOINT;accessKey=KEY\"\nrouter_client = JobRouterClient.from_connection_string(conn_str = connection_string)\nrouter_admin_client = JobRouterAdministrationClient.from_connection_string(conn_str = connection_string)\n```\n\n### Distribution Policy\nBefore we can create a Queue, we need a Distribution Policy.\n\n```python\nfrom azure.communication.jobrouter.models import (\n    LongestIdleMode,\n    DistributionPolicy\n)\n\ndistribution_policy: DistributionPolicy = DistributionPolicy(\n    offer_expires_after_seconds = 24 * 60 * 60,\n    mode = LongestIdleMode(\n        min_concurrent_offers = 1,\n        max_concurrent_offers = 1\n    )\n)\n\ndistribution_policy: DistributionPolicy = router_admin_client.upsert_distribution_policy(\n    \"distribution-policy-1\",\n    distribution_policy\n)\n```\n### Queue\nNext, we can create the queue.\n\n```python\nfrom azure.communication.jobrouter.models import (\n    RouterQueue\n)\n\nqueue: RouterQueue = RouterQueue(\n    distribution_policy_id = \"distribution-policy-1\"\n)\n\nqueue: RouterQueue = router_admin_client.upsert_queue(\n    \"queue-1\",\n    queue\n)\n```\n\n### Job\nNow, 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.\n```python\nfrom azure.communication.jobrouter.models import (\n    RouterJob,\n    RouterWorkerSelector,\n    LabelOperator\n)\n\nrouter_job: RouterJob = RouterJob(\n    channel_id = \"my-channel\",\n    queue_id = \"queue-1\",\n    channel_reference = \"12345\",\n    priority = 1,\n    requested_worker_selectors = [\n        RouterWorkerSelector(key = \"Some-Skill\", label_operator = LabelOperator.EQUAL, value = 10)\n    ]\n)\n\njob: RouterJob = router_client.upsert_job(\n    \"jobId-1\",\n    router_job\n)\n```\n\n### Worker\nNow, we register a worker to receive work from that queue, with a label of `Some-Skill` equal to 11.\n```python\nfrom azure.communication.jobrouter.models import (\n    RouterWorker,\n    RouterChannel\n)\n\nrouter_worker: RouterWorker = RouterWorker(\n    capacity = 1,\n    queues = [\n        \"queue-1\"\n    ],\n    labels = {\n        \"Some-Skill\": 11\n    },\n    channels = [\n        RouterChannel(channel_id = \"my-channel\", capacity_cost_per_job = 1)\n    ],\n    available_for_offers = True\n)\n\nworker = router_client.upsert_worker(\n    \"worker-1\",\n    router_worker\n)\n```\n\n### Offer\nWe should get a [RouterWorkerOfferIssued][offer_issued_event_schema] from our [EventGrid subscription][subscribe_events].\n\nThere are several different Azure services that act as a [event handler][event_grid_event_handlers].\nFor this scenario, we are going to assume Webhooks for event delivery. [Learn more about Webhook event delivery][webhook_event_grid_event_delivery]\n\nOnce events are delivered to the event handler, we can deserialize the JSON payload into a list of events.\n\n```python\n# Parse the JSON payload into a list of events\nfrom azure.eventgrid import EventGridEvent\nimport json\n\n## deserialize payload into a list of typed Events\nevents = [EventGridEvent.from_json(json.loads(msg)) for msg in payload]\n```\n\n```python\noffer_id = \"\"\nfor event in events:\n    if event.event_type == \"Microsoft.Communication.RouterWorkerOfferIssued\":\n        offer_id = event.data.offer_id\n    else:\n        continue\n```\n\nHowever, 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.\n```python\nfrom azure.communication.jobrouter.models import (\n    RouterWorker,\n)\n\nrouter_worker: RouterWorker = router_client.get_worker(worker_id = \"worker-1\")\n\nfor offer in router_worker.offers:\n    print(f\"Worker {router_worker.id} has an active offer for job {offer.job_id}\")\n```\n### Accept an offer\nOnce a worker receives an offer, it can take two possible actions: accept or decline. We are going to accept the offer.\n```python\nfrom azure.communication.jobrouter.models import (\n    RouterJobOffer,\n    AcceptJobOfferResult,\n    RouterJobStatus\n)\n\n# fetching the offer id\njob_offer: RouterJobOffer = [offer for offer in router_worker.offers if offer.job_id == \"jobId-1\"][0]\noffer_id = job_offer.offer_id\n\n# accepting the offer sent to `worker-1`\naccept_job_offer_result: AcceptJobOfferResult = router_client.accept_job_offer(\n    worker_id = \"worker-1\",\n    offer_id = offer_id\n)\n\nprint(f\"Offer: {job_offer.offer_id} sent to worker: {router_worker.id} has been accepted\")\nprint(f\"Job has been assigned to worker: {router_worker.id} with assignment: {accept_job_offer_result.assignment_id}\")\n\n# verify job assignment is populated when querying job\nupdated_job = router_client.get_job(job_id = \"jobId-1\")\nprint(f\"Job assignment has been successful: {updated_job.job_status == RouterJobStatus.Assigned and accept_job_offer_result.assignment_id in updated_job.assignments}\")\n```\n\n### Completing a job\nOnce the worker is done with the job, the worker has to mark the job as `completed`.\n```python\nimport datetime\nfrom azure.communication.jobrouter.models import (\n    CompleteJobOptions\n)\ncomplete_job_result = router_client.complete_job(\n    \"jobId-1\",\n    accept_job_offer_result.assignment_id,\n    CompleteJobOptions(\n        note = f\"Job has been completed by {router_worker.id} at {datetime.datetime.utcnow()}\"\n    )\n)\n\nprint(f\"Job has been successfully completed.\")\n```\n\n### Closing a job\nAfter 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\n```python\nfrom azure.communication.jobrouter.models import (\n    RouterJob,\n    RouterJobStatus,\n    CloseJobOptions,\n)\n\nclose_job_result = router_client.close_job(\n    \"jobId-1\",\n    accept_job_offer_result.assignment_id,\n    CloseJobOptions(\n        note = f\"Job has been closed by {router_worker.id} at {datetime.datetime.utcnow()}\"\n    )\n)\n\nprint(f\"Job has been successfully closed.\")\n\nupdate_job: RouterJob = router_client.get_job(job_id = \"jobId-1\")\nprint(f\"Updated job status: {update_job.job_status == RouterJobStatus.CLOSED}\")\n```\n\n```python\nimport time\nfrom datetime import datetime, timedelta\nfrom azure.communication.jobrouter.models import (\n    RouterJob,\n    RouterJobStatus,\n    CloseJobOptions,\n)\n\nclose_job_in_future_result = router_client.close_job(\n    \"jobId-1\",\n    accept_job_offer_result.assignment_id,\n    CloseJobOptions(\n        note = f\"Job has been closed by {router_worker.id} at {datetime.utcnow()}\",\n        close_at = datetime.utcnow() + timedelta(seconds = 2)\n    )\n)\n\nprint(f\"Job has been marked to close\")\ntime.sleep(secs = 2)\nupdate_job: RouterJob = router_client.get_job(job_id = \"jobId-1\")\nprint(f\"Updated job status: {update_job.job_status == RouterJobStatus.CLOSED}\")\n```\n\n## Troubleshooting\n\nRunning into issues? This section should contain details as to what to do there.\n\n## Next steps\n- [Read more about Router in Azure Communication Services][nextsteps]\n\n### More sample code\nPlease take a look at the [samples][job_router_samples] directory for detailed examples of how to use this library.\n\n## Provide Feedback\n\nIf you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project\n\n## Contributing\n\nThis project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].\n\nThis project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments.\n\n<!-- LINKS -->\n[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md\n[azure_sub]: https://azure.microsoft.com/free/python/\n[cla]: https://cla.microsoft.com\n[coc]: https://opensource.microsoft.com/codeofconduct/\n[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/\n[coc_contact]: mailto:opencode@microsoft.com\n[communication_resource_docs]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp\n[communication_resource_create_portal]:  https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp\n[communication_resource_create_power_shell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice\n[communication_resource_create_net]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net\n[nextsteps]:https://docs.microsoft.com/azure/communication-services/concepts/router/concepts\n\n[source]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/communication/azure-communication-jobrouter\n[product_docs]: https://docs.microsoft.com/azure/communication-services/overview\n[classification_concepts]: https://docs.microsoft.com/azure/communication-services/concepts/router/classification-concepts\n[subscribe_events]: https://docs.microsoft.com/azure/communication-services/how-tos/router-sdk/subscribe-events\n[offer_issued_event_schema]: https://docs.microsoft.com/azure/communication-services/how-tos/router-sdk/subscribe-events#microsoftcommunicationrouterworkerofferissued\n[deserialize_event_grid_event_data]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventgrid/azure-eventgrid#consume-from-servicebus\n[event_grid_event_handlers]: https://docs.microsoft.com/azure/event-grid/event-handlers\n[webhook_event_grid_event_delivery]: https://docs.microsoft.com/azure/event-grid/webhook-event-delivery\n[pypi]: https://pypi.org\n[pip]: https://pypi.org/project/pip/\n\n[job_router_samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/communication/azure-communication-jobrouter/samples\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Microsoft Communication JobRouter Client Library for Python",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk"
    },
    "split_keywords": [
        "azure",
        "azure sdk"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "493fd3b5af1b514eb81c0d7ff40c79dd097ba1ef54834890e852e1423311aebc",
                "md5": "6fd550f3573f72573bf4c5579bc88aba",
                "sha256": "ba30f9a9a7d126635b3b2b5eb42a075b8a7eab140a27caff3816061e8848fe9a"
            },
            "downloads": -1,
            "filename": "azure_communication_jobrouter-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6fd550f3573f72573bf4c5579bc88aba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 113998,
            "upload_time": "2023-11-18T00:53:39",
            "upload_time_iso_8601": "2023-11-18T00:53:39.901324Z",
            "url": "https://files.pythonhosted.org/packages/49/3f/d3b5af1b514eb81c0d7ff40c79dd097ba1ef54834890e852e1423311aebc/azure_communication_jobrouter-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a7739bedf336675a2149c3f5b2bcb4b736657c26517bdc84a87db8ee76c8e8ed",
                "md5": "9f21ae81ebfef0cf456ec8e525f3417b",
                "sha256": "d5cb87c2a605161ef999ff649a048c1c66d3458e0ff45f8dc900d75e02a7452c"
            },
            "downloads": -1,
            "filename": "azure-communication-jobrouter-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9f21ae81ebfef0cf456ec8e525f3417b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 145128,
            "upload_time": "2023-11-18T00:53:37",
            "upload_time_iso_8601": "2023-11-18T00:53:37.955461Z",
            "url": "https://files.pythonhosted.org/packages/a7/73/9bedf336675a2149c3f5b2bcb4b736657c26517bdc84a87db8ee76c8e8ed/azure-communication-jobrouter-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-18 00:53:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Azure",
    "github_project": "azure-sdk-for-python",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "azure-communication-jobrouter"
}
        
Elapsed time: 0.53077s