Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 16 additions & 1 deletion taskbadger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,11 @@ components:
nullable: true
description: Datetime when status is set to a terminal value.Can be set
via the API.
time_to_start:
type: string
nullable: true
description: Duration between task creation and when status first changes
from pending. (seconds)
max_runtime:
type: integer
maximum: 2147483647
Expand Down Expand Up @@ -813,6 +818,11 @@ components:
nullable: true
description: Datetime when status is set to a terminal value.Can be set
via the API.
time_to_start:
type: string
nullable: true
description: Duration between task creation and when status first changes
from pending. (seconds)
max_runtime:
type: integer
maximum: 2147483647
Expand All @@ -837,8 +847,8 @@ components:
type: object
additionalProperties:
type: string
maxLength: 255
minLength: 2
maxLength: 255
description: Tags for the task represented as a mapping from 'namespace'
to 'value'.
required:
Expand Down Expand Up @@ -891,6 +901,11 @@ components:
nullable: true
description: Datetime when status is set to a terminal value.Can be set
via the API.
time_to_start:
type: string
nullable: true
description: Duration between task creation and when status first changes
from pending. (seconds)
max_runtime:
type: integer
maximum: 2147483647
Expand Down
3 changes: 2 additions & 1 deletion taskbadger/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def apply_async(self, *args, **kwargs):

result = super().apply_async(*args, **kwargs)

tb_task_id = result.info.get(TB_TASK_ID) if result.info else None
info = result.info
tb_task_id = info.get(TB_TASK_ID) if isinstance(info, dict) else None
setattr(result, TB_TASK_ID, tb_task_id)

_get_task = functools.partial(get_task, tb_task_id) if tb_task_id else lambda: None
Expand Down
1 change: 1 addition & 0 deletions taskbadger/internal/api/action_endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
1 change: 1 addition & 0 deletions taskbadger/internal/api/action_endpoints/action_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def _get_kwargs(
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
if response.status_code == 204:
return None

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 2 additions & 2 deletions taskbadger/internal/api/action_endpoints/action_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ def _get_kwargs(
"url": f"/api/{organization_slug}/{project_slug}/tasks/{task_id}/actions/",
}

_body = body.to_dict()
_kwargs["json"] = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
Expand All @@ -38,6 +37,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_201 = Action.from_dict(response.json())

return response_201

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
1 change: 1 addition & 0 deletions taskbadger/internal/api/action_endpoints/action_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_200 = Action.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
1 change: 1 addition & 0 deletions taskbadger/internal/api/action_endpoints/action_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _parse_response(
response_200.append(response_200_item)

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def _get_kwargs(
"url": f"/api/{organization_slug}/{project_slug}/tasks/{task_id}/actions/{id}/",
}

_body = body.to_dict()
_kwargs["json"] = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
Expand All @@ -40,6 +39,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_200 = Action.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 2 additions & 2 deletions taskbadger/internal/api/action_endpoints/action_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def _get_kwargs(
"url": f"/api/{organization_slug}/{project_slug}/tasks/{task_id}/actions/{id}/",
}

_body = body.to_dict()
_kwargs["json"] = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
Expand All @@ -40,6 +39,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_200 = Action.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
1 change: 1 addition & 0 deletions taskbadger/internal/api/task_endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
1 change: 1 addition & 0 deletions taskbadger/internal/api/task_endpoints/task_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _get_kwargs(
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
if response.status_code == 204:
return None

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 2 additions & 2 deletions taskbadger/internal/api/task_endpoints/task_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ def _get_kwargs(
"url": f"/api/{organization_slug}/{project_slug}/tasks/",
}

_body = body.to_dict()
_kwargs["json"] = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
Expand All @@ -41,6 +40,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_201 = Task.from_dict(response.json())

return response_201

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
1 change: 1 addition & 0 deletions taskbadger/internal/api/task_endpoints/task_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_200 = Task.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
1 change: 1 addition & 0 deletions taskbadger/internal/api/task_endpoints/task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def _parse_response(
response_200 = PaginatedTaskList.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 2 additions & 2 deletions taskbadger/internal/api/task_endpoints/task_partial_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def _get_kwargs(
"url": f"/api/{organization_slug}/{project_slug}/tasks/{id}/",
}

_body = body.to_dict()
_kwargs["json"] = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
Expand All @@ -39,6 +38,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_200 = Task.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
4 changes: 2 additions & 2 deletions taskbadger/internal/api/task_endpoints/task_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def _get_kwargs(
"url": f"/api/{organization_slug}/{project_slug}/tasks/{id}/",
}

_body = body.to_dict()
_kwargs["json"] = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
Expand All @@ -39,6 +38,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
response_200 = Task.from_dict(response.json())

return response_200

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand Down
5 changes: 3 additions & 2 deletions taskbadger/internal/models/action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union

from attrs import define as _attrs_define
Expand Down Expand Up @@ -70,8 +71,8 @@ def to_dict(self) -> dict[str, Any]:
return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
d = src_dict.copy()
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
id = d.pop("id")

task = d.pop("task")
Expand Down
5 changes: 3 additions & 2 deletions taskbadger/internal/models/action_request.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union

from attrs import define as _attrs_define
Expand Down Expand Up @@ -43,8 +44,8 @@ def to_dict(self) -> dict[str, Any]:
return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
d = src_dict.copy()
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
trigger = d.pop("trigger")

integration = d.pop("integration")
Expand Down
5 changes: 3 additions & 2 deletions taskbadger/internal/models/paginated_task_list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast

from attrs import define as _attrs_define
Expand Down Expand Up @@ -59,10 +60,10 @@ def to_dict(self) -> dict[str, Any]:
return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.task import Task

d = src_dict.copy()
d = dict(src_dict)
results = []
_results = d.pop("results")
for results_item_data in _results:
Expand Down
5 changes: 3 additions & 2 deletions taskbadger/internal/models/patched_action_request.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union

from attrs import define as _attrs_define
Expand Down Expand Up @@ -42,8 +43,8 @@ def to_dict(self) -> dict[str, Any]:
return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
d = src_dict.copy()
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
trigger = d.pop("trigger", UNSET)

integration = d.pop("integration", UNSET)
Expand Down
26 changes: 24 additions & 2 deletions taskbadger/internal/models/patched_task_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast

from attrs import define as _attrs_define
Expand Down Expand Up @@ -35,6 +36,8 @@ class PatchedTaskRequest:
set via the API.
end_time (Union[None, Unset, datetime.datetime]): Datetime when status is set to a terminal value.Can be set via
the API.
time_to_start (Union[None, Unset, str]): Duration between task creation and when status first changes from
pending. (seconds)
max_runtime (Union[None, Unset, int]): Maximum duration the task can be running for before being considered
failed. (seconds)
stale_timeout (Union[None, Unset, int]): Maximum time to allow between task updates before considering the task
Expand All @@ -50,6 +53,7 @@ class PatchedTaskRequest:
data: Union[Unset, Any] = UNSET
start_time: Union[None, Unset, datetime.datetime] = UNSET
end_time: Union[None, Unset, datetime.datetime] = UNSET
time_to_start: Union[None, Unset, str] = UNSET
max_runtime: Union[None, Unset, int] = UNSET
stale_timeout: Union[None, Unset, int] = UNSET
tags: Union[Unset, "PatchedTaskRequestTags"] = UNSET
Expand Down Expand Up @@ -88,6 +92,12 @@ def to_dict(self) -> dict[str, Any]:
else:
end_time = self.end_time

time_to_start: Union[None, Unset, str]
if isinstance(self.time_to_start, Unset):
time_to_start = UNSET
else:
time_to_start = self.time_to_start

max_runtime: Union[None, Unset, int]
if isinstance(self.max_runtime, Unset):
max_runtime = UNSET
Expand Down Expand Up @@ -121,6 +131,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["start_time"] = start_time
if end_time is not UNSET:
field_dict["end_time"] = end_time
if time_to_start is not UNSET:
field_dict["time_to_start"] = time_to_start
if max_runtime is not UNSET:
field_dict["max_runtime"] = max_runtime
if stale_timeout is not UNSET:
Expand All @@ -131,10 +143,10 @@ def to_dict(self) -> dict[str, Any]:
return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.patched_task_request_tags import PatchedTaskRequestTags

d = src_dict.copy()
d = dict(src_dict)
name = d.pop("name", UNSET)

_status = d.pop("status", UNSET)
Expand Down Expand Up @@ -191,6 +203,15 @@ def _parse_end_time(data: object) -> Union[None, Unset, datetime.datetime]:

end_time = _parse_end_time(d.pop("end_time", UNSET))

def _parse_time_to_start(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)

time_to_start = _parse_time_to_start(d.pop("time_to_start", UNSET))

def _parse_max_runtime(data: object) -> Union[None, Unset, int]:
if data is None:
return data
Expand Down Expand Up @@ -224,6 +245,7 @@ def _parse_stale_timeout(data: object) -> Union[None, Unset, int]:
data=data,
start_time=start_time,
end_time=end_time,
time_to_start=time_to_start,
max_runtime=max_runtime,
stale_timeout=stale_timeout,
tags=tags,
Expand Down
5 changes: 3 additions & 2 deletions taskbadger/internal/models/patched_task_request_tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
Expand All @@ -19,8 +20,8 @@ def to_dict(self) -> dict[str, Any]:
return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
d = src_dict.copy()
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
patched_task_request_tags = cls()

patched_task_request_tags.additional_properties = d
Expand Down
Loading