Repository navigation
Expand file tree
/
Copy pathmodels.py
More file actions
93 lines (73 loc) · 2.03 KB
/
Copy pathmodels.py
File metadata and controls
93 lines (73 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from typing import List, Optional
from sqlalchemy.orm import relationship
from sqlalchemy import Column, Integer, String, Boolean
from sqlalchemy_utils import TSVectorType, JSONType
from dispatch.database import Base
from dispatch.models import DispatchBase
from dispatch.plugins.base import plugins
class Plugin(Base):
id = Column(Integer, primary_key=True)
title = Column(String)
slug = Column(String, unique=True)
description = Column(String)
version = Column(String)
author = Column(String)
author_url = Column(String)
type = Column(String)
enabled = Column(Boolean)
required = Column(Boolean)
multiple = Column(Boolean)
configuration = Column(JSONType)
workflows = relationship("Workflow", backref="plugin")
@property
def instance(self):
"""Fetches a plugin instance that matches this record."""
return plugins.get(self.slug)
search_vector = Column(TSVectorType("title"))
# Pydantic models...
class PluginBase(DispatchBase):
pass
class PluginCreate(PluginBase):
title: str
slug: str
author: str
author_url: str
type: str
enabled: Optional[bool]
required: Optional[bool] = True
multiple: Optional[bool] = False
description: Optional[str]
configuration: Optional[dict]
class PluginUpdate(PluginBase):
id: int
title: str
slug: str
author: str
author_url: str
type: str
enabled: Optional[bool]
required: Optional[bool] = True
multiple: Optional[bool] = False
description: Optional[str]
configuration: Optional[dict]
class PluginRead(PluginBase):
id: int
title: str
slug: str
author: str
author_url: str
type: str
enabled: bool
required: bool
multiple: bool
description: Optional[str]
configuration: Optional[dict]
class KeyValue(DispatchBase):
key: str
value: str
class PluginMetadata(DispatchBase):
slug: str
metadata: List[KeyValue] = []
class PluginPagination(DispatchBase):
total: int
items: List[PluginRead] = []