Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changes for job matching modes
  • Loading branch information
sarkar-rajarshi committed Jun 21, 2023
commit 1dfa6162e9e4298edd7b53d5d3e74bdecbe5374a
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
CloseJobResult,
RouterJob,
RouterJobItem,
JobMatchingMode,
JobMatchModeType,
ScheduleAndSuspendMode,
)


Expand Down Expand Up @@ -130,6 +133,9 @@
'ScoringRuleParameterSelector',
'RouterWorker',
'RouterWorkerItem',
'JobMatchingMode',
'JobMatchModeType',
'ScheduleAndSuspendMode',

# Created models

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def __init__(
labels: Optional[Dict[str, Union[int, float, str, bool, None]]] = None,
tags: Optional[Dict[str, Union[int, float, str, bool, None]]] = None,
notes: Dict[Union[str, datetime], str] = None,
unavailable_for_matching: Optional[bool] = None,
scheduled_time_utc: Optional[Union[str, datetime]] = None,
matching_mode: Optional["_models.JobMatchingMode"] = None,
**kwargs
):
if notes:
Expand All @@ -73,8 +72,6 @@ def __init__(
datetime_as_str: str = _datetime_as_isostr(k) # pylint:disable=protected-access
notes.pop(k)
notes[datetime_as_str] = v
if isinstance(scheduled_time_utc, str):
scheduled_time_utc = _convert_str_to_datetime(scheduled_time_utc) # pylint:disable=protected-access
super().__init__(
channel_reference=channel_reference,
channel_id=channel_id,
Expand All @@ -86,8 +83,7 @@ def __init__(
notes=notes,
labels=labels,
tags=tags,
unavailable_for_matching=unavailable_for_matching,
scheduled_time_utc=scheduled_time_utc,
matching_mode=matching_mode,
**kwargs
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
QueueAssignment,
RouterJob,
RouterJobItem,
JobMatchingMode
)

from ._shared.utils import parse_connection_str
Expand Down Expand Up @@ -559,8 +560,7 @@ def update_job(
labels: Optional[Dict[str, Union[int, float, str, bool]]],
tags: Optional[Dict[str, Union[int, float, str, bool]]],
notes: Optional[Dict[datetime, str]],
unavailable_for_matching: Optional[bool],
scheduled_time_utc: Optional[Union[str, datetime]],
matching_mode: Optional[JobMatchingMode],
**kwargs: Any
) -> RouterJob:
""" Update a job.
Expand Down Expand Up @@ -600,14 +600,8 @@ def update_job(
:keyword notes: Notes attached to a job, sorted by timestamp.
:paramtype notes: Optional[Dict[~datetime.datetime, str]]

:keyword unavailable_for_matching: A flag indicating this job is not ready for being matched with
workers.
When set to true, job matching will not be started. If set to false, job matching will start
automatically.
:paramtype unavailable_for_matching: Optional[bool]

:keyword scheduled_time_utc: If set, job will be scheduled to be enqueued at a given time.
:paramtype scheduled_time_utc: Optional[Union[str, ~datetime.datetime]]
:keyword matching_mode: If set, determines how a job will be matched
:paramtype matching_mode: Optional[~azure.communication.jobrouter.JobMatchingMode]


:return: RouterJob
Expand Down Expand Up @@ -663,14 +657,8 @@ def update_job(
:keyword notes: Notes attached to a job, sorted by timestamp.
:paramtype notes: Optional[Dict[~datetime.datetime, str]]

:keyword unavailable_for_matching: A flag indicating this job is not ready for being matched with
workers.
When set to true, job matching will not be started. If set to false, job matching will start
automatically.
:paramtype unavailable_for_matching: Optional[bool]

:keyword scheduled_time_utc: If set, job will be scheduled to be enqueued at a given time.
:paramtype scheduled_time_utc: Optional[Union[str, ~datetime.datetime]]
:keyword matching_mode: If set, determines how a job will be matched
:paramtype matching_mode: Optional[~azure.communication.jobrouter.JobMatchingMode]


:return: RouterJob
Expand Down Expand Up @@ -705,8 +693,7 @@ def update_job(
labels = kwargs.pop('labels', router_job.labels),
tags = kwargs.pop('tags', router_job.tags),
notes = kwargs.pop('notes', router_job.notes),
unavailable_for_matching = kwargs.pop('unavailable_for_matching', router_job.unavailable_for_matching),
scheduled_time_utc = kwargs.pop('scheduled_time_utc', router_job.scheduled_time_utc)
matching_mode = kwargs.pop('matching_mode', router_job.matching_mode)
)

return self._client.job_router.upsert_job(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
QueueAssignment,
RouterJob,
RouterJobItem,
JobMatchingMode
)

from .._shared.utils import parse_connection_str
Expand Down Expand Up @@ -565,8 +566,7 @@ async def update_job(
labels: Optional[Dict[str, Union[int, float, str, bool]]],
tags: Optional[Dict[str, Union[int, float, str, bool]]],
notes: Optional[Dict[datetime, str]],
unavailable_for_matching: Optional[bool],
scheduled_time_utc: Optional[Union[str, datetime]],
matching_mode: Optional[JobMatchingMode],
**kwargs: Any
) -> RouterJob:
""" Update a job.
Expand Down Expand Up @@ -606,14 +606,8 @@ async def update_job(
:keyword notes: Notes attached to a job, sorted by timestamp.
:paramtype notes: Optional[Dict[~datetime.datetime, str]]

:keyword unavailable_for_matching: A flag indicating this job is not ready for being matched with
workers.
When set to true, job matching will not be started. If set to false, job matching will start
automatically.
:paramtype unavailable_for_matching: Optional[bool]

:keyword scheduled_time_utc: If set, job will be scheduled to be enqueued at a given time.
:paramtype scheduled_time_utc: Optional[Union[str, ~datetime.datetime]]
:keyword matching_mode: If set, determines how a job will be matched
:paramtype matching_mode: Optional[~azure.communication.jobrouter.JobMatchingMode]


:return: RouterJob
Expand Down Expand Up @@ -669,14 +663,8 @@ async def update_job(
:keyword notes: Notes attached to a job, sorted by timestamp.
:paramtype notes: Optional[Dict[~datetime.datetime, str]]

:keyword unavailable_for_matching: A flag indicating this job is not ready for being matched with
workers.
When set to true, job matching will not be started. If set to false, job matching will start
automatically.
:paramtype unavailable_for_matching: Optional[bool]

:keyword scheduled_time_utc: If set, job will be scheduled to be enqueued at a given time.
:paramtype scheduled_time_utc: Optional[Union[str, ~datetime.datetime]]
:keyword matching_mode: If set, determines how a job will be matched
:paramtype matching_mode: Optional[~azure.communication.jobrouter.JobMatchingMode]


:return: RouterJob
Expand Down Expand Up @@ -711,8 +699,7 @@ async def update_job(
labels = kwargs.pop('labels', router_job.labels),
tags = kwargs.pop('tags', router_job.tags),
notes = kwargs.pop('notes', router_job.notes),
unavailable_for_matching = kwargs.pop('unavailable_for_matching', router_job.unavailable_for_matching),
scheduled_time_utc = kwargs.pop('scheduled_time_utc', router_job.scheduled_time_utc)
matching_mode = kwargs.pop('matching_mode', router_job.matching_mode)
)

return await self._client.job_router.upsert_job(
Expand Down