Skip to content

Commit 9900ae4

Browse files
regenerate close job and complete job with updated signature (#33017)
1 parent cfd8040 commit 9900ae4

21 files changed

+304
-218
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727
- Create and update methods have been removed for `RouterWorker`. Use `upsert_worker` instead.
2828
- `list_jobs` returns `(Async)Iterable[RouterJob]` instead of `(Async)Iterable[RouterJobItem]`
2929
- `list_workers` returns `(Async)Iterable[RouterWorker]` instead of `(Async)Iterable[RouterWorkerItem]`
30-
- `decline_job_offer` - keyword argument `retry_offer_at: Optional[datetime]` removed from method. Use `decline_job_offer_options: Optional[Union[DeclineJobOfferOptions, JSON, IO]]` instead.
31-
- `close_job` - keyword arguments `close_at: Optional[datetime]`, `disposition_code: Optional[str]`, `note: Optional[str]` removed from method. Use `close_job_options: Union[CloseJobOptions, JSON, IO]` instead.
32-
- `cancel_job` - keyword arguments `disposition_code: Optional[str]`, `note: Optional[str]` removed from method. Use `cancel_job_options: Optional[Union[CancelJobOptions, JSON, IO]]` instead.
33-
- `complete_job` - keyword argument `note: Optional[str]` removed from method. Use `complete_job_options: Union[CompleteJobOptions, JSON, IO]` instead.
34-
- `unassign_job` - keyword argument `suspend_matching: Optional[bool]` removed from method. Use `unassign_job_options: Optional[Union[UnassignJobOptions, JSON, IO]]` instead.
30+
- `decline_job_offer` - keyword argument `retry_offer_at: Optional[datetime]` removed from method. Use `options: Optional[Union[DeclineJobOfferOptions, JSON, IO]]` instead.
31+
- `close_job`
32+
- keyword arguments `close_at: Optional[datetime]`, `disposition_code: Optional[str]`, `note: Optional[str]` removed from method. Use `options: Optional[Union[CloseJobOptions, JSON, IO]]` instead.
33+
- `assignment_id: str` added as positional argument.
34+
- `cancel_job` - keyword arguments `disposition_code: Optional[str]`, `note: Optional[str]` removed from method. Use `options: Optional[Union[CancelJobOptions, JSON, IO]]` instead.
35+
- `complete_job`
36+
- keyword argument `note: Optional[str]` removed from method. Use `options: Optional[Union[CompleteJobOptions, JSON, IO]]` instead.
37+
- `assignment_id: str` added as positional argument.
38+
- `unassign_job` - keyword argument `suspend_matching: Optional[bool]` removed from method. Use `options: Optional[Union[UnassignJobOptions, JSON, IO]]` instead.
3539
- `RouterJob`
3640
- Property `notes` - Changed from `Dict[str, ~datetime.datetime]` to `List[RouterJobNote]`
3741
- `ClassificationPolicy`
@@ -47,6 +51,10 @@
4751
- Property changed `queue_assignments: Dict[str, RouterQueueAssignment]` -> `queues: List[str]`
4852
- Rename `total_capacity` -> `capacity`
4953
- Property changed `channel_configurations: Dict[str, ChannelConfiguration]` -> `channels: List[RouterChannel]`
54+
- `CloseJobOptions`
55+
- Removed property `assignment_id`
56+
- `CompleteJobOptions`
57+
- Removed property `assignment_id`
5058

5159
#### Renames
5260
- `ChannelConfiguration` -> `RouterChannel`
@@ -79,7 +87,7 @@
7987
- `ExceptionRule`
8088
- Add `id`
8189
- `ExceptionAction` and all derived classes `CancelExceptionAction`, `ManualReclassifyExceptionAction`, `ReclassifyExceptionAction`
82-
- Add `id`. Property is read-only. If not provided, it will be generated by the service.
90+
- Add `id`. If not provided, it will be generated by the service.
8391
- `RouterChannel`
8492
- Add `channel_id`
8593

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ from azure.communication.jobrouter.models import (
254254
)
255255
complete_job_result = router_client.complete_job(
256256
"jobId-1",
257+
accept_job_offer_result.assignment_id,
257258
CompleteJobOptions(
258-
assignment_id = accept_job_offer_result.assignment_id,
259259
note = f"Job has been completed by {router_worker.id} at {datetime.datetime.utcnow()}"
260260
)
261261
)
@@ -274,8 +274,8 @@ from azure.communication.jobrouter.models import (
274274

275275
close_job_result = router_client.close_job(
276276
"jobId-1",
277+
accept_job_offer_result.assignment_id,
277278
CloseJobOptions(
278-
assignment_id = accept_job_offer_result.assignment_id,
279279
note = f"Job has been closed by {router_worker.id} at {datetime.datetime.utcnow()}"
280280
)
281281
)
@@ -297,8 +297,8 @@ from azure.communication.jobrouter.models import (
297297

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

sdk/communication/azure-communication-jobrouter/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/communication/azure-communication-jobrouter",
5-
"Tag": "python/communication/azure-communication-jobrouter_1176d5225c"
5+
"Tag": "python/communication/azure-communication-jobrouter_40b4f337cd"
66
}

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_operations/_operations.py

Lines changed: 85 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ def build_job_router_cancel_job_request(job_id: str, **kwargs: Any) -> HttpReque
628628
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
629629

630630

631-
def build_job_router_complete_job_request(job_id: str, **kwargs: Any) -> HttpRequest:
631+
def build_job_router_complete_job_request(job_id: str, assignment_id: str, **kwargs: Any) -> HttpRequest:
632632
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
633633
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
634634

@@ -637,9 +637,10 @@ def build_job_router_complete_job_request(job_id: str, **kwargs: Any) -> HttpReq
637637
accept = _headers.pop("Accept", "application/json")
638638

639639
# Construct URL
640-
_url = "/routing/jobs/{jobId}:complete"
640+
_url = "/routing/jobs/{jobId}/assignments/{assignmentId}:complete"
641641
path_format_arguments = {
642642
"jobId": _SERIALIZER.url("job_id", job_id, "str"),
643+
"assignmentId": _SERIALIZER.url("assignment_id", assignment_id, "str"),
643644
}
644645

645646
_url: str = _url.format(**path_format_arguments) # type: ignore
@@ -655,7 +656,7 @@ def build_job_router_complete_job_request(job_id: str, **kwargs: Any) -> HttpReq
655656
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
656657

657658

658-
def build_job_router_close_job_request(job_id: str, **kwargs: Any) -> HttpRequest:
659+
def build_job_router_close_job_request(job_id: str, assignment_id: str, **kwargs: Any) -> HttpRequest:
659660
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
660661
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
661662

@@ -664,9 +665,10 @@ def build_job_router_close_job_request(job_id: str, **kwargs: Any) -> HttpReques
664665
accept = _headers.pop("Accept", "application/json")
665666

666667
# Construct URL
667-
_url = "/routing/jobs/{jobId}:close"
668+
_url = "/routing/jobs/{jobId}/assignments/{assignmentId}:close"
668669
path_format_arguments = {
669670
"jobId": _SERIALIZER.url("job_id", job_id, "str"),
671+
"assignmentId": _SERIALIZER.url("assignment_id", assignment_id, "str"),
670672
}
671673

672674
_url: str = _url.format(**path_format_arguments) # type: ignore
@@ -3128,7 +3130,7 @@ def _reclassify_job( # pylint: disable=protected-access
31283130
31293131
Reclassify a job.
31303132
3131-
:param job_id: Id of the job. Required.
3133+
:param job_id: The id of the job. Required.
31323134
:type job_id: str
31333135
:param options: Request object for reclassifying a job. Is one of the following types:
31343136
ReclassifyJobOptions, JSON, IO Default value is None.
@@ -3235,7 +3237,7 @@ def _cancel_job( # pylint: disable=protected-access
32353237
32363238
Submits request to cancel an existing job by Id while supplying free-form cancellation reason.
32373239
3238-
:param job_id: Id of the job. Required.
3240+
:param job_id: The id of the job. Required.
32393241
:type job_id: str
32403242
:param options: Request model for cancelling job. Is one of the following types:
32413243
CancelJobOptions, JSON, IO Default value is None.
@@ -3315,7 +3317,8 @@ def _cancel_job( # pylint: disable=protected-access
33153317
def _complete_job( # pylint: disable=protected-access
33163318
self,
33173319
job_id: str,
3318-
options: _models._models.CompleteJobOptions,
3320+
assignment_id: str,
3321+
options: Optional[_models._models.CompleteJobOptions] = None,
33193322
*,
33203323
content_type: str = "application/json",
33213324
**kwargs: Any
@@ -3324,28 +3327,46 @@ def _complete_job( # pylint: disable=protected-access
33243327

33253328
@overload
33263329
def _complete_job( # pylint: disable=protected-access
3327-
self, job_id: str, options: JSON, *, content_type: str = "application/json", **kwargs: Any
3330+
self,
3331+
job_id: str,
3332+
assignment_id: str,
3333+
options: Optional[JSON] = None,
3334+
*,
3335+
content_type: str = "application/json",
3336+
**kwargs: Any
33283337
) -> _models._models.CompleteJobResult:
33293338
...
33303339

33313340
@overload
33323341
def _complete_job( # pylint: disable=protected-access
3333-
self, job_id: str, options: IO, *, content_type: str = "application/json", **kwargs: Any
3342+
self,
3343+
job_id: str,
3344+
assignment_id: str,
3345+
options: Optional[IO] = None,
3346+
*,
3347+
content_type: str = "application/json",
3348+
**kwargs: Any
33343349
) -> _models._models.CompleteJobResult:
33353350
...
33363351

33373352
@distributed_trace
33383353
def _complete_job( # pylint: disable=protected-access
3339-
self, job_id: str, options: Union[_models._models.CompleteJobOptions, JSON, IO], **kwargs: Any
3354+
self,
3355+
job_id: str,
3356+
assignment_id: str,
3357+
options: Optional[Union[_models._models.CompleteJobOptions, JSON, IO]] = None,
3358+
**kwargs: Any
33403359
) -> _models._models.CompleteJobResult:
33413360
"""Completes an assigned job.
33423361
33433362
Completes an assigned job.
33443363
3345-
:param job_id: Id of the job. Required.
3364+
:param job_id: The id of the job. Required.
33463365
:type job_id: str
3366+
:param assignment_id: The Id of the job assignment. Required.
3367+
:type assignment_id: str
33473368
:param options: Request model for completing job. Is one of the following types:
3348-
CompleteJobOptions, JSON, IO Required.
3369+
CompleteJobOptions, JSON, IO Default value is None.
33493370
:type options: ~azure.communication.jobrouter.models.CompleteJobOptions or JSON or IO
33503371
:keyword content_type: Body parameter Content-Type. Known values are: application/json. Default
33513372
value is None.
@@ -3375,10 +3396,14 @@ def _complete_job( # pylint: disable=protected-access
33753396
if isinstance(options, (IOBase, bytes)):
33763397
_content = options
33773398
else:
3378-
_content = json.dumps(options, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
3399+
if options is not None:
3400+
_content = json.dumps(options, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
3401+
else:
3402+
_content = None
33793403

33803404
_request = build_job_router_complete_job_request(
33813405
job_id=job_id,
3406+
assignment_id=assignment_id,
33823407
content_type=content_type,
33833408
api_version=self._config.api_version,
33843409
content=_content,
@@ -3419,7 +3444,8 @@ def _complete_job( # pylint: disable=protected-access
34193444
def _close_job( # pylint: disable=protected-access
34203445
self,
34213446
job_id: str,
3422-
options: _models._models.CloseJobOptions,
3447+
assignment_id: str,
3448+
options: Optional[_models._models.CloseJobOptions] = None,
34233449
*,
34243450
content_type: str = "application/json",
34253451
**kwargs: Any
@@ -3428,28 +3454,46 @@ def _close_job( # pylint: disable=protected-access
34283454

34293455
@overload
34303456
def _close_job( # pylint: disable=protected-access
3431-
self, job_id: str, options: JSON, *, content_type: str = "application/json", **kwargs: Any
3457+
self,
3458+
job_id: str,
3459+
assignment_id: str,
3460+
options: Optional[JSON] = None,
3461+
*,
3462+
content_type: str = "application/json",
3463+
**kwargs: Any
34323464
) -> _models._models.CloseJobResult:
34333465
...
34343466

34353467
@overload
34363468
def _close_job( # pylint: disable=protected-access
3437-
self, job_id: str, options: IO, *, content_type: str = "application/json", **kwargs: Any
3469+
self,
3470+
job_id: str,
3471+
assignment_id: str,
3472+
options: Optional[IO] = None,
3473+
*,
3474+
content_type: str = "application/json",
3475+
**kwargs: Any
34383476
) -> _models._models.CloseJobResult:
34393477
...
34403478

34413479
@distributed_trace
34423480
def _close_job( # pylint: disable=protected-access
3443-
self, job_id: str, options: Union[_models._models.CloseJobOptions, JSON, IO], **kwargs: Any
3481+
self,
3482+
job_id: str,
3483+
assignment_id: str,
3484+
options: Optional[Union[_models._models.CloseJobOptions, JSON, IO]] = None,
3485+
**kwargs: Any
34443486
) -> _models._models.CloseJobResult:
34453487
"""Closes a completed job.
34463488
34473489
Closes a completed job.
34483490
3449-
:param job_id: Id of the job. Required.
3491+
:param job_id: The id of the job. Required.
34503492
:type job_id: str
3493+
:param assignment_id: The Id of the job assignment. Required.
3494+
:type assignment_id: str
34513495
:param options: Request model for closing job. Is one of the following types: CloseJobOptions,
3452-
JSON, IO Required.
3496+
JSON, IO Default value is None.
34533497
:type options: ~azure.communication.jobrouter.models.CloseJobOptions or JSON or IO
34543498
:keyword content_type: Body parameter Content-Type. Known values are: application/json. Default
34553499
value is None.
@@ -3479,10 +3523,14 @@ def _close_job( # pylint: disable=protected-access
34793523
if isinstance(options, (IOBase, bytes)):
34803524
_content = options
34813525
else:
3482-
_content = json.dumps(options, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
3526+
if options is not None:
3527+
_content = json.dumps(options, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
3528+
else:
3529+
_content = None
34833530

34843531
_request = build_job_router_close_job_request(
34853532
job_id=job_id,
3533+
assignment_id=assignment_id,
34863534
content_type=content_type,
34873535
api_version=self._config.api_version,
34883536
content=_content,
@@ -3501,27 +3549,18 @@ def _close_job( # pylint: disable=protected-access
35013549

35023550
response = pipeline_response.http_response
35033551

3504-
if response.status_code not in [200, 202]:
3552+
if response.status_code not in [200]:
35053553
if _stream:
35063554
response.read() # Load the body in memory and close the socket
35073555
map_error(status_code=response.status_code, response=response, error_map=error_map)
35083556
raise HttpResponseError(response=response)
35093557

3510-
if response.status_code == 200:
3511-
if _stream:
3512-
deserialized = response.iter_bytes()
3513-
else:
3514-
deserialized = _deserialize(
3515-
_models._models.CloseJobResult, response.json() # pylint: disable=protected-access
3516-
)
3517-
3518-
if response.status_code == 202:
3519-
if _stream:
3520-
deserialized = response.iter_bytes()
3521-
else:
3522-
deserialized = _deserialize(
3523-
_models._models.CloseJobResult, response.json() # pylint: disable=protected-access
3524-
)
3558+
if _stream:
3559+
deserialized = response.iter_bytes()
3560+
else:
3561+
deserialized = _deserialize(
3562+
_models._models.CloseJobResult, response.json() # pylint: disable=protected-access
3563+
)
35253564

35263565
if cls:
35273566
return cls(pipeline_response, deserialized, {}) # type: ignore
@@ -3726,9 +3765,9 @@ def unassign_job(
37263765
37273766
Un-assign a job.
37283767
3729-
:param job_id: Id of the job to un-assign. Required.
3768+
:param job_id: The id of the job. Required.
37303769
:type job_id: str
3731-
:param assignment_id: Id of the assignment to un-assign. Required.
3770+
:param assignment_id: The Id of the job assignment. Required.
37323771
:type assignment_id: str
37333772
:param options: Request body for unassign route. Default value is None.
37343773
:type options: ~azure.communication.jobrouter.models.UnassignJobOptions
@@ -3756,9 +3795,9 @@ def unassign_job(
37563795
37573796
Un-assign a job.
37583797
3759-
:param job_id: Id of the job to un-assign. Required.
3798+
:param job_id: The id of the job. Required.
37603799
:type job_id: str
3761-
:param assignment_id: Id of the assignment to un-assign. Required.
3800+
:param assignment_id: The Id of the job assignment. Required.
37623801
:type assignment_id: str
37633802
:param options: Request body for unassign route. Default value is None.
37643803
:type options: JSON
@@ -3786,9 +3825,9 @@ def unassign_job(
37863825
37873826
Un-assign a job.
37883827
3789-
:param job_id: Id of the job to un-assign. Required.
3828+
:param job_id: The id of the job. Required.
37903829
:type job_id: str
3791-
:param assignment_id: Id of the assignment to un-assign. Required.
3830+
:param assignment_id: The Id of the job assignment. Required.
37923831
:type assignment_id: str
37933832
:param options: Request body for unassign route. Default value is None.
37943833
:type options: IO
@@ -3814,9 +3853,9 @@ def unassign_job(
38143853
38153854
Un-assign a job.
38163855
3817-
:param job_id: Id of the job to un-assign. Required.
3856+
:param job_id: The id of the job. Required.
38183857
:type job_id: str
3819-
:param assignment_id: Id of the assignment to un-assign. Required.
3858+
:param assignment_id: The Id of the job assignment. Required.
38203859
:type assignment_id: str
38213860
:param options: Request body for unassign route. Is one of the following types:
38223861
UnassignJobOptions, JSON, IO Default value is None.
@@ -3901,7 +3940,7 @@ def accept_job_offer(self, worker_id: str, offer_id: str, **kwargs: Any) -> _mod
39013940
39023941
:param worker_id: Id of the worker. Required.
39033942
:type worker_id: str
3904-
:param offer_id: Id of the offer. Required.
3943+
:param offer_id: The Id of the offer. Required.
39053944
:type offer_id: str
39063945
:keyword bool stream: Whether to stream the response of this operation. Defaults to False. You
39073946
will have to context manage the returned stream.
@@ -4007,7 +4046,7 @@ def _decline_job_offer( # pylint: disable=protected-access
40074046
40084047
:param worker_id: Id of the worker. Required.
40094048
:type worker_id: str
4010-
:param offer_id: Id of the offer. Required.
4049+
:param offer_id: The Id of the offer. Required.
40114050
:type offer_id: str
40124051
:param options: Request model for declining offer. Is one of the following types:
40134052
DeclineJobOfferOptions, JSON, IO Default value is None.

0 commit comments

Comments
 (0)