Skip to content

Commit 466afa8

Browse files
committed
update schema and client with tags
1 parent ba50adb commit 466afa8

21 files changed

Lines changed: 242 additions & 417 deletions

taskbadger.yaml

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,23 @@ paths:
4747
examples:
4848
ListResponse:
4949
value:
50-
previous: string
51-
next: string
50+
next: http://api.example.org/accounts/?cursor=cD00ODY%3D"
51+
previous: http://api.example.org/accounts/?cursor=cj0xJnA9NDg3
5252
results:
53-
- id: 57ae8eVBrH7jbDgmYj6Ut2vR9S
54-
organization: example_org
55-
project: example_org
56-
name: example task
57-
status: processing
58-
value: 63
59-
value_percent: 63
60-
data:
61-
property1: customValue
62-
created: '2022-08-24T14:15:22Z'
63-
updated: '2022-08-24T16:15:22Z'
53+
- previous: string
54+
next: string
55+
results:
56+
- id: 57ae8eVBrH7jbDgmYj6Ut2vR9S
57+
organization: example_org
58+
project: example_org
59+
name: example task
60+
status: processing
61+
value: 63
62+
value_percent: 63
63+
data:
64+
property1: customValue
65+
created: '2022-08-24T14:15:22Z'
66+
updated: '2022-08-24T16:15:22Z'
6467
summary: List Response
6568
description: ''
6669
post:
@@ -100,6 +103,9 @@ paths:
100103
status: pending
101104
data:
102105
property1: customValue
106+
tags:
107+
project: demo
108+
user: admin
103109
summary: Create Payload
104110
required: true
105111
security:
@@ -601,9 +607,7 @@ components:
601607
status:
602608
type: string
603609
readOnly: true
604-
config:
605-
type: object
606-
additionalProperties: {}
610+
config: {}
607611
created:
608612
type: string
609613
format: date-time
@@ -631,21 +635,25 @@ components:
631635
type: string
632636
minLength: 1
633637
maxLength: 50
634-
config:
635-
type: object
636-
additionalProperties: {}
638+
config: {}
637639
required:
638640
- integration
639641
- trigger
640642
PaginatedTaskList:
641643
type: object
644+
required:
645+
- results
642646
properties:
643647
next:
644648
type: string
645649
nullable: true
650+
format: uri
651+
example: http://api.example.org/accounts/?cursor=cD00ODY%3D"
646652
previous:
647653
type: string
648654
nullable: true
655+
format: uri
656+
example: http://api.example.org/accounts/?cursor=cj0xJnA9NDg3
649657
results:
650658
type: array
651659
items:
@@ -661,9 +669,7 @@ components:
661669
type: string
662670
minLength: 1
663671
maxLength: 50
664-
config:
665-
type: object
666-
additionalProperties: {}
672+
config: {}
667673
PatchedTaskRequest:
668674
type: object
669675
properties:
@@ -675,15 +681,6 @@ components:
675681
status:
676682
allOf:
677683
- $ref: '#/components/schemas/StatusEnum'
678-
description: |-
679-
* `pending` - pending
680-
* `pre_processing` - pre_processing
681-
* `processing` - processing
682-
* `post_processing` - post_processing
683-
* `success` - success
684-
* `error` - error
685-
* `cancelled` - cancelled
686-
* `stale` - stale
687684
default: pending
688685
value:
689686
type: integer
@@ -699,8 +696,6 @@ components:
699696
format: int64
700697
description: Maximum value of the task. Defaults to 100.
701698
data:
702-
type: object
703-
additionalProperties: {}
704699
nullable: true
705700
description: Custom metadata
706701
start_time:
@@ -728,7 +723,15 @@ components:
728723
minimum: 1
729724
nullable: true
730725
description: Maximum time to allow between task updates before considering
731-
the task stale. Only applies when task is in a running state. (seconds)
726+
the task stale. (seconds)
727+
tags:
728+
type: object
729+
additionalProperties:
730+
type: string
731+
minLength: 2
732+
maxLength: 255
733+
description: Tags for the task represented as a mapping from 'namespace'
734+
to 'value'.
732735
StatusEnum:
733736
enum:
734737
- pending
@@ -740,6 +743,15 @@ components:
740743
- cancelled
741744
- stale
742745
type: string
746+
description: |-
747+
* `pending` - pending
748+
* `pre_processing` - pre_processing
749+
* `processing` - processing
750+
* `post_processing` - post_processing
751+
* `success` - success
752+
* `error` - error
753+
* `cancelled` - cancelled
754+
* `stale` - stale
743755
Task:
744756
type: object
745757
properties:
@@ -760,15 +772,6 @@ components:
760772
status:
761773
allOf:
762774
- $ref: '#/components/schemas/StatusEnum'
763-
description: |-
764-
* `pending` - pending
765-
* `pre_processing` - pre_processing
766-
* `processing` - processing
767-
* `post_processing` - post_processing
768-
* `success` - success
769-
* `error` - error
770-
* `cancelled` - cancelled
771-
* `stale` - stale
772775
default: pending
773776
value:
774777
type: integer
@@ -788,8 +791,6 @@ components:
788791
readOnly: true
789792
nullable: true
790793
data:
791-
type: object
792-
additionalProperties: {}
793794
nullable: true
794795
description: Custom metadata
795796
created:
@@ -825,13 +826,21 @@ components:
825826
minimum: 1
826827
nullable: true
827828
description: Maximum time to allow between task updates before considering
828-
the task stale. Only applies when task is in a running state. (seconds)
829+
the task stale. (seconds)
829830
url:
830831
type: string
831832
readOnly: true
832833
public_url:
833834
type: string
834835
readOnly: true
836+
tags:
837+
type: object
838+
additionalProperties:
839+
type: string
840+
maxLength: 255
841+
minLength: 2
842+
description: Tags for the task represented as a mapping from 'namespace'
843+
to 'value'.
835844
required:
836845
- created
837846
- id
@@ -853,15 +862,6 @@ components:
853862
status:
854863
allOf:
855864
- $ref: '#/components/schemas/StatusEnum'
856-
description: |-
857-
* `pending` - pending
858-
* `pre_processing` - pre_processing
859-
* `processing` - processing
860-
* `post_processing` - post_processing
861-
* `success` - success
862-
* `error` - error
863-
* `cancelled` - cancelled
864-
* `stale` - stale
865865
default: pending
866866
value:
867867
type: integer
@@ -877,8 +877,6 @@ components:
877877
format: int64
878878
description: Maximum value of the task. Defaults to 100.
879879
data:
880-
type: object
881-
additionalProperties: {}
882880
nullable: true
883881
description: Custom metadata
884882
start_time:
@@ -906,7 +904,15 @@ components:
906904
minimum: 1
907905
nullable: true
908906
description: Maximum time to allow between task updates before considering
909-
the task stale. Only applies when task is in a running state. (seconds)
907+
the task stale. (seconds)
908+
tags:
909+
type: object
910+
additionalProperties:
911+
type: string
912+
minLength: 2
913+
maxLength: 255
914+
description: Tags for the task represented as a mapping from 'namespace'
915+
to 'value'.
910916
required:
911917
- name
912918
securitySchemes:

taskbadger/integrations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Any
33

44
from taskbadger.exceptions import TaskbadgerException
5-
from taskbadger.internal.models import ActionRequest, ActionRequestConfig
5+
from taskbadger.internal.models import ActionRequest
66

77

88
def from_config(integration_id: str, config: str):
@@ -47,17 +47,17 @@ class EmailIntegration(Integration):
4747
to: str # custom type
4848
id: str = "email"
4949

50-
def request_config(self) -> ActionRequestConfig:
51-
return ActionRequestConfig.from_dict({"to": self.to})
50+
def request_config(self) -> dict:
51+
return {"to": self.to}
5252

5353

5454
@dataclasses.dataclass
5555
class WebhookIntegration(Integration):
5656
type = "webhook"
5757
id: str
5858

59-
def request_config(self) -> ActionRequestConfig:
60-
return ActionRequestConfig.from_dict({})
59+
def request_config(self) -> dict:
60+
return {}
6161

6262

6363
ALL = [EmailIntegration, WebhookIntegration]
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
11
"""Contains all the data models used in inputs/outputs"""
22

33
from .action import Action
4-
from .action_config import ActionConfig
54
from .action_request import ActionRequest
6-
from .action_request_config import ActionRequestConfig
75
from .paginated_task_list import PaginatedTaskList
86
from .patched_action_request import PatchedActionRequest
9-
from .patched_action_request_config import PatchedActionRequestConfig
107
from .patched_task_request import PatchedTaskRequest
11-
from .patched_task_request_data_type_0 import PatchedTaskRequestDataType0
8+
from .patched_task_request_tags import PatchedTaskRequestTags
129
from .status_enum import StatusEnum
1310
from .task import Task
14-
from .task_data_type_0 import TaskDataType0
1511
from .task_request import TaskRequest
16-
from .task_request_data_type_0 import TaskRequestDataType0
12+
from .task_request_tags import TaskRequestTags
13+
from .task_tags import TaskTags
1714

1815
__all__ = (
1916
"Action",
20-
"ActionConfig",
2117
"ActionRequest",
22-
"ActionRequestConfig",
2318
"PaginatedTaskList",
2419
"PatchedActionRequest",
25-
"PatchedActionRequestConfig",
2620
"PatchedTaskRequest",
27-
"PatchedTaskRequestDataType0",
21+
"PatchedTaskRequestTags",
2822
"StatusEnum",
2923
"Task",
30-
"TaskDataType0",
3124
"TaskRequest",
32-
"TaskRequestDataType0",
25+
"TaskRequestTags",
26+
"TaskTags",
3327
)

taskbadger/internal/models/action.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import datetime
2-
from typing import TYPE_CHECKING, Any, TypeVar, Union
2+
from typing import Any, TypeVar, Union
33

44
from attrs import define as _attrs_define
55
from attrs import field as _attrs_field
66
from dateutil.parser import isoparse
77

88
from ..types import UNSET, Unset
99

10-
if TYPE_CHECKING:
11-
from ..models.action_config import ActionConfig
12-
13-
1410
T = TypeVar("T", bound="Action")
1511

1612

@@ -25,7 +21,7 @@ class Action:
2521
status (str):
2622
created (datetime.datetime):
2723
updated (datetime.datetime):
28-
config (Union[Unset, ActionConfig]):
24+
config (Union[Unset, Any]):
2925
"""
3026

3127
id: int
@@ -35,7 +31,7 @@ class Action:
3531
status: str
3632
created: datetime.datetime
3733
updated: datetime.datetime
38-
config: Union[Unset, "ActionConfig"] = UNSET
34+
config: Union[Unset, Any] = UNSET
3935
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
4036

4137
def to_dict(self) -> dict[str, Any]:
@@ -53,9 +49,7 @@ def to_dict(self) -> dict[str, Any]:
5349

5450
updated = self.updated.isoformat()
5551

56-
config: Union[Unset, dict[str, Any]] = UNSET
57-
if not isinstance(self.config, Unset):
58-
config = self.config.to_dict()
52+
config = self.config
5953

6054
field_dict: dict[str, Any] = {}
6155
field_dict.update(self.additional_properties)
@@ -77,8 +71,6 @@ def to_dict(self) -> dict[str, Any]:
7771

7872
@classmethod
7973
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
80-
from ..models.action_config import ActionConfig
81-
8274
d = src_dict.copy()
8375
id = d.pop("id")
8476

@@ -94,12 +86,7 @@ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
9486

9587
updated = isoparse(d.pop("updated"))
9688

97-
_config = d.pop("config", UNSET)
98-
config: Union[Unset, ActionConfig]
99-
if isinstance(_config, Unset):
100-
config = UNSET
101-
else:
102-
config = ActionConfig.from_dict(_config)
89+
config = d.pop("config", UNSET)
10390

10491
action = cls(
10592
id=id,

0 commit comments

Comments
 (0)