Skip to content

Commit bf83b41

Browse files
[ACS JobRouter] Scheduled jobs modifications (Azure#30446)
* ACS JobRouter scheduled jobs modifications * Update pipeline to accommodate for discrepancy in AioHttpTransport behaviour * fix sample
1 parent 7496abc commit bf83b41

18 files changed

+4038
-121
lines changed

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_generated/aio/operations/_operations.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Code generated by Microsoft (R) AutoRest Code Generator.
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
9+
import datetime
910
from io import IOBase
1011
import sys
1112
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
@@ -1562,7 +1563,7 @@ async def delete_job(self, id: str, **kwargs: Any) -> None: # pylint: disable=i
15621563
15631564
Deletes a job and all of its traces.
15641565
1565-
:param id: Required.
1566+
:param id: Id of the job. Required.
15661567
:type id: str
15671568
:return: None
15681569
:rtype: None
@@ -2049,6 +2050,8 @@ def list_jobs(
20492050
queue_id: Optional[str] = None,
20502051
channel_id: Optional[str] = None,
20512052
classification_policy_id: Optional[str] = None,
2053+
scheduled_before: Optional[datetime.datetime] = None,
2054+
scheduled_after: Optional[datetime.datetime] = None,
20522055
**kwargs: Any
20532056
) -> AsyncIterable["_models.RouterJobItem"]:
20542057
"""Retrieves list of jobs based on filter parameters.
@@ -2057,7 +2060,8 @@ def list_jobs(
20572060
20582061
:keyword status: (Optional) If specified, filter jobs by status. Known values are: "all",
20592062
"pendingClassification", "queued", "assigned", "completed", "closed", "cancelled",
2060-
"classificationFailed", and "active". Default value is "all".
2063+
"classificationFailed", "created", "pendingSchedule", "scheduled", "scheduleFailed",
2064+
"waitingForActivation", and "active". Default value is "all".
20612065
:paramtype status: str or ~azure.communication.jobrouter.models.JobStateSelector
20622066
:keyword queue_id: (Optional) If specified, filter jobs by queue. Default value is None.
20632067
:paramtype queue_id: str
@@ -2066,6 +2070,12 @@ def list_jobs(
20662070
:keyword classification_policy_id: (Optional) If specified, filter jobs by
20672071
classificationPolicy. Default value is None.
20682072
:paramtype classification_policy_id: str
2073+
:keyword scheduled_before: (Optional) If specified, filter on jobs that was scheduled before or
2074+
at given timestamp. Range: (-Inf, scheduledBefore]. Default value is None.
2075+
:paramtype scheduled_before: ~datetime.datetime
2076+
:keyword scheduled_after: (Optional) If specified, filter on jobs that was scheduled at or
2077+
after given value. Range: [scheduledAfter, +Inf). Default value is None.
2078+
:paramtype scheduled_after: ~datetime.datetime
20692079
:return: An iterator like instance of RouterJobItem
20702080
:rtype:
20712081
~azure.core.async_paging.AsyncItemPaged[~azure.communication.jobrouter.models.RouterJobItem]
@@ -2092,6 +2102,8 @@ def prepare_request(next_link=None):
20922102
queue_id=queue_id,
20932103
channel_id=channel_id,
20942104
classification_policy_id=classification_policy_id,
2105+
scheduled_before=scheduled_before,
2106+
scheduled_after=scheduled_after,
20952107
api_version=self._config.api_version,
20962108
headers=_headers,
20972109
params=_params,

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_generated/models/_enums.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ class JobStateSelector(str, Enum, metaclass=CaseInsensitiveEnumMeta):
2121
CLOSED = "closed"
2222
CANCELLED = "cancelled"
2323
CLASSIFICATION_FAILED = "classificationFailed"
24+
CREATED = "created"
25+
PENDING_SCHEDULE = "pendingSchedule"
26+
SCHEDULED = "scheduled"
27+
SCHEDULE_FAILED = "scheduleFailed"
28+
WAITING_FOR_ACTIVATION = "waitingForActivation"
2429
ACTIVE = "active"
2530

2631

@@ -46,6 +51,10 @@ class RouterJobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
4651
CANCELLED = "cancelled"
4752
CLASSIFICATION_FAILED = "classificationFailed"
4853
CREATED = "created"
54+
PENDING_SCHEDULE = "pendingSchedule"
55+
SCHEDULED = "scheduled"
56+
SCHEDULE_FAILED = "scheduleFailed"
57+
WAITING_FOR_ACTIVATION = "waitingForActivation"
4958

5059

5160
class RouterWorkerState(str, Enum, metaclass=CaseInsensitiveEnumMeta):

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_generated/models/_models.py

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class AcceptJobOfferResult(_serialization.Model):
3939
"""
4040

4141
_validation = {
42-
"assignment_id": {"required": True},
43-
"job_id": {"required": True},
44-
"worker_id": {"required": True},
42+
"assignment_id": {"required": True, "min_length": 1},
43+
"job_id": {"required": True, "min_length": 1},
44+
"worker_id": {"required": True, "min_length": 1},
4545
}
4646

4747
_attribute_map = {
@@ -1326,7 +1326,7 @@ class JobAssignment(_serialization.Model):
13261326
"""
13271327

13281328
_validation = {
1329-
"id": {"required": True},
1329+
"id": {"required": True, "min_length": 1},
13301330
"assign_time": {"required": True},
13311331
}
13321332

@@ -1447,8 +1447,8 @@ class JobOffer(_serialization.Model):
14471447
"""
14481448

14491449
_validation = {
1450-
"id": {"required": True},
1451-
"job_id": {"required": True},
1450+
"id": {"required": True, "min_length": 1},
1451+
"job_id": {"required": True, "min_length": 1},
14521452
"capacity_cost": {"required": True},
14531453
}
14541454

@@ -1509,9 +1509,9 @@ class JobPositionDetails(_serialization.Model):
15091509
"""
15101510

15111511
_validation = {
1512-
"job_id": {"required": True},
1512+
"job_id": {"required": True, "min_length": 1},
15131513
"position": {"required": True},
1514-
"queue_id": {"required": True},
1514+
"queue_id": {"required": True, "min_length": 1},
15151515
"queue_length": {"required": True},
15161516
"estimated_wait_time_minutes": {"required": True},
15171517
}
@@ -2078,7 +2078,7 @@ class QueueStatistics(_serialization.Model):
20782078
"""
20792079

20802080
_validation = {
2081-
"queue_id": {"required": True},
2081+
"queue_id": {"required": True, "min_length": 1},
20822082
"length": {"required": True},
20832083
}
20842084

@@ -2280,7 +2280,8 @@ class RouterJob(_serialization.Model): # pylint: disable=too-many-instance-attr
22802280
:ivar channel_reference: Reference to an external parent context, eg. call ID.
22812281
:vartype channel_reference: str
22822282
:ivar job_status: The state of the Job. Known values are: "pendingClassification", "queued",
2283-
"assigned", "completed", "closed", "cancelled", "classificationFailed", and "created".
2283+
"assigned", "completed", "closed", "cancelled", "classificationFailed", "created",
2284+
"pendingSchedule", "scheduled", "scheduleFailed", and "waitingForActivation".
22842285
:vartype job_status: str or ~azure.communication.jobrouter.models.RouterJobStatus
22852286
:ivar enqueue_time_utc: The time a job was queued.
22862287
:vartype enqueue_time_utc: ~datetime.datetime
@@ -2310,6 +2311,13 @@ class RouterJob(_serialization.Model): # pylint: disable=too-many-instance-attr
23102311
:vartype tags: dict[str, any]
23112312
:ivar notes: Notes attached to a job, sorted by timestamp.
23122313
:vartype notes: dict[str, str]
2314+
:ivar unavailable_for_matching: A flag indicating this job is ready for being matched with
2315+
workers.
2316+
When set to true, job matching will not be started. If set to false, job matching will start
2317+
automatically.
2318+
:vartype unavailable_for_matching: bool
2319+
:ivar scheduled_time_utc: If set, job will be scheduled to be enqueued at a given time.
2320+
:vartype scheduled_time_utc: ~datetime.datetime
23132321
"""
23142322

23152323
_validation = {
@@ -2336,6 +2344,8 @@ class RouterJob(_serialization.Model): # pylint: disable=too-many-instance-attr
23362344
"assignments": {"key": "assignments", "type": "{JobAssignment}"},
23372345
"tags": {"key": "tags", "type": "{object}"},
23382346
"notes": {"key": "notes", "type": "{str}"},
2347+
"unavailable_for_matching": {"key": "unavailableForMatching", "type": "bool"},
2348+
"scheduled_time_utc": {"key": "scheduledTimeUtc", "type": "iso-8601"},
23392349
}
23402350

23412351
def __init__(
@@ -2351,6 +2361,8 @@ def __init__(
23512361
labels: Optional[Dict[str, Any]] = None,
23522362
tags: Optional[Dict[str, Any]] = None,
23532363
notes: Optional[Dict[str, str]] = None,
2364+
unavailable_for_matching: Optional[bool] = None,
2365+
scheduled_time_utc: Optional[datetime.datetime] = None,
23542366
**kwargs: Any
23552367
) -> None:
23562368
"""
@@ -2378,6 +2390,13 @@ def __init__(
23782390
:paramtype tags: dict[str, any]
23792391
:keyword notes: Notes attached to a job, sorted by timestamp.
23802392
:paramtype notes: dict[str, str]
2393+
:keyword unavailable_for_matching: A flag indicating this job is ready for being matched with
2394+
workers.
2395+
When set to true, job matching will not be started. If set to false, job matching will start
2396+
automatically.
2397+
:paramtype unavailable_for_matching: bool
2398+
:keyword scheduled_time_utc: If set, job will be scheduled to be enqueued at a given time.
2399+
:paramtype scheduled_time_utc: ~datetime.datetime
23812400
"""
23822401
super().__init__(**kwargs)
23832402
self.id = None
@@ -2395,6 +2414,8 @@ def __init__(
23952414
self.assignments = None
23962415
self.tags = tags
23972416
self.notes = notes
2417+
self.unavailable_for_matching = unavailable_for_matching
2418+
self.scheduled_time_utc = scheduled_time_utc
23982419

23992420

24002421
class RouterJobItem(_serialization.Model):
@@ -2825,7 +2846,7 @@ class UnassignJobResult(_serialization.Model):
28252846
"""
28262847

28272848
_validation = {
2828-
"job_id": {"required": True},
2849+
"job_id": {"required": True, "min_length": 1},
28292850
"unassignment_count": {"required": True},
28302851
}
28312852

@@ -3009,8 +3030,8 @@ class WorkerAssignment(_serialization.Model):
30093030
"""
30103031

30113032
_validation = {
3012-
"id": {"required": True},
3013-
"job_id": {"required": True},
3033+
"id": {"required": True, "min_length": 1},
3034+
"job_id": {"required": True, "min_length": 1},
30143035
"capacity_cost": {"required": True},
30153036
"assign_time": {"required": True},
30163037
}

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_generated/models/_patch.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def __init__(
5757
labels: Optional[Dict[str, Union[int, float, str, bool, None]]] = None,
5858
tags: Optional[Dict[str, Union[int, float, str, bool, None]]] = None,
5959
notes: Dict[Union[str, datetime], str] = None,
60+
unavailable_for_matching: Optional[bool] = None,
61+
scheduled_time_utc: Optional[Union[str, datetime]] = None,
6062
**kwargs
6163
):
6264
if notes:
@@ -71,18 +73,25 @@ def __init__(
7173
datetime_as_str: str = _datetime_as_isostr(k) # pylint:disable=protected-access
7274
notes.pop(k)
7375
notes[datetime_as_str] = v
76+
77+
if isinstance(scheduled_time_utc, str):
78+
scheduled_time_utc = _convert_str_to_datetime(scheduled_time_utc) # pylint:disable=protected-access
79+
7480
super().__init__(
75-
channel_reference = channel_reference,
76-
channel_id = channel_id,
77-
classification_policy_id = classification_policy_id,
78-
queue_id = queue_id,
79-
priority = priority,
80-
disposition_code = disposition_code,
81-
requested_worker_selectors = requested_worker_selectors,
82-
notes = notes,
83-
labels = labels,
84-
tags = tags,
85-
**kwargs)
81+
channel_reference=channel_reference,
82+
channel_id=channel_id,
83+
classification_policy_id=classification_policy_id,
84+
queue_id=queue_id,
85+
priority=priority,
86+
disposition_code=disposition_code,
87+
requested_worker_selectors=requested_worker_selectors,
88+
notes=notes,
89+
labels=labels,
90+
tags=tags,
91+
unavailable_for_matching=unavailable_for_matching,
92+
scheduled_time_utc=scheduled_time_utc,
93+
**kwargs
94+
)
8695

8796

8897
class RouterWorker(RouterWorkerGenerated):
@@ -102,13 +111,14 @@ def __init__(
102111
if not isinstance(v, (MutableMapping, JSON, type(None))):
103112
raise ValueError("tags only accept 'QueueAssignment', 'JSON' and 'NoneType' as values.")
104113
super().__init__(
105-
queue_assignments = queue_assignments,
106-
total_capacity = total_capacity,
107-
labels = labels,
108-
tags = tags,
109-
channel_configurations = channel_configurations,
110-
available_for_offers = available_for_offers,
111-
**kwargs)
114+
queue_assignments=queue_assignments,
115+
total_capacity=total_capacity,
116+
labels=labels,
117+
tags=tags,
118+
channel_configurations=channel_configurations,
119+
available_for_offers=available_for_offers,
120+
**kwargs
121+
)
112122

113123

114124
__all__: List[str] = [

0 commit comments

Comments
 (0)