splight-lib 5.11.4__tar.gz → 5.11.5.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/PKG-INFO +1 -1
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/pyproject.toml +1 -1
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/component/spec.py +1 -4
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/constants.py +0 -1
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/alert.py +1 -4
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/asset.py +1 -4
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/component.py +56 -56
- splight_lib-5.11.5.dev0/splight_lib/models/dashboard.py +307 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/datalake.py +5 -33
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/file.py +1 -4
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/function.py +1 -5
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/hub.py +2 -11
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/hub_server.py +1 -4
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/hub_solution.py +1 -4
- splight_lib-5.11.4/splight_lib/models/dashboard.py +0 -126
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/LICENSE.txt +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/README.md +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/abstract/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/abstract/client.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/auth/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/auth/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/auth/mac_auth.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/auth/token.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/database/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/database/abstract.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/database/builder.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/database/classmap.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/database/remote_client.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/abstract.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/buffer.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/builder.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/constants.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/datalake/remote_client.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/file_handler.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/filter.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/hub/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/hub/abstract.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/hub/client.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/tests/test_database.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/client/tests/test_datalake.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/component/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/component/abstract.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/component/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/component/tests/test_abstract.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/component/tests/test_spec.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/conftest.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/encryption.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/engine.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/scheduling.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/task.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/tests/test_execution.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/tests/test_scheduling.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/execution/trigger.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/logging/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/logging/_internal.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/logging/component.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/logging/constants.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/logging/logging.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/logging/tests/test_logging.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/actions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/attribute.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/data_address.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/database_base.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/datalake_base.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/generic.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/metadata.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/native.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/secret.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/server.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/solution.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/tag.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/tests/models.json +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/tests/test_component_object_instance.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/tests/test_database_model.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/tests/test_metadata.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/tests/test_models.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/models/variable_types.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/restclient/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/restclient/client.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/restclient/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/restclient/tests/test_restclient.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/restclient/types.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/server/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/server/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/server/server.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/settings.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/solution/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/solution/exceptions.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/solution/solution.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/stringcase.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/testing/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/tests/FakeProc.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/tests/asset_geometries.json +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/tests/test_api_contracts.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/tests/test_encryption.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/utils/__init__.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/utils/custom_model.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/utils/hub.py +0 -0
- {splight_lib-5.11.4 → splight_lib-5.11.5.dev0}/splight_lib/version.py +0 -0
|
@@ -8,7 +8,6 @@ from splight_lib.component.exceptions import (
|
|
|
8
8
|
DuplicatedValuesError,
|
|
9
9
|
ParameterDependencyError,
|
|
10
10
|
)
|
|
11
|
-
from splight_lib.constants import DESCRIPTION_MAX_LENGTH
|
|
12
11
|
from splight_lib.models.component import (
|
|
13
12
|
Component,
|
|
14
13
|
ComponentObjectInstance,
|
|
@@ -84,9 +83,7 @@ class Spec(BaseModel):
|
|
|
84
83
|
splight_cli_version: Optional[str] = Field(
|
|
85
84
|
None, pattern=r"^(\d+)\.(\d+)\.(\d+)(\.dev[0-9]+)?$"
|
|
86
85
|
)
|
|
87
|
-
description:
|
|
88
|
-
default=None, max_length=DESCRIPTION_MAX_LENGTH
|
|
89
|
-
)
|
|
86
|
+
description: str | None = None
|
|
90
87
|
privacy_policy: PrivacyPolicy = PrivacyPolicy.PUBLIC
|
|
91
88
|
tags: Set[str] = set()
|
|
92
89
|
component_type: ComponentType = ComponentType.CONNECTOR
|
|
@@ -13,7 +13,6 @@ from pydantic import (
|
|
|
13
13
|
from strenum import LowercaseStrEnum, UppercaseStrEnum
|
|
14
14
|
from typing_extensions import TypedDict
|
|
15
15
|
|
|
16
|
-
from splight_lib.constants import DESCRIPTION_MAX_LENGTH
|
|
17
16
|
from splight_lib.models.database_base import SplightDatabaseBaseModel
|
|
18
17
|
from splight_lib.models.exceptions import (
|
|
19
18
|
InvalidAlertConfiguration,
|
|
@@ -209,9 +208,7 @@ class StatementAggregation(LowercaseStrEnum):
|
|
|
209
208
|
class Alert(SplightDatabaseBaseModel):
|
|
210
209
|
id: Optional[str] = Field(None, max_length=100)
|
|
211
210
|
name: str
|
|
212
|
-
description:
|
|
213
|
-
default=None, max_length=DESCRIPTION_MAX_LENGTH
|
|
214
|
-
)
|
|
211
|
+
description: str | None = None
|
|
215
212
|
|
|
216
213
|
assets: List[QueryFilter] = []
|
|
217
214
|
alert_items: List[AlertItem] = []
|
|
@@ -4,7 +4,6 @@ from typing import Any, List, Optional, Tuple
|
|
|
4
4
|
from geojson_pydantic import GeometryCollection
|
|
5
5
|
from pydantic import Field
|
|
6
6
|
|
|
7
|
-
from splight_lib.constants import DESCRIPTION_MAX_LENGTH
|
|
8
7
|
from splight_lib.models.attribute import Attribute
|
|
9
8
|
from splight_lib.models.database_base import (
|
|
10
9
|
ResourceSummary,
|
|
@@ -40,9 +39,7 @@ class AssetRelationship(SplightDatabaseBaseModel):
|
|
|
40
39
|
class Asset(SplightDatabaseBaseModel):
|
|
41
40
|
id: Optional[str] = None
|
|
42
41
|
name: str
|
|
43
|
-
description:
|
|
44
|
-
default=None, max_length=DESCRIPTION_MAX_LENGTH
|
|
45
|
-
)
|
|
42
|
+
description: str | None = None
|
|
46
43
|
tags: List[Tag] = []
|
|
47
44
|
attributes: List[Attribute] = []
|
|
48
45
|
metadata: List[Metadata] = []
|
|
@@ -2,7 +2,7 @@ import re
|
|
|
2
2
|
import warnings
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
4
|
from enum import auto
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Any, ClassVar, Dict, List, Literal, Optional, Type, Union
|
|
6
6
|
|
|
7
7
|
from pydantic import (
|
|
8
8
|
BaseModel,
|
|
@@ -14,7 +14,6 @@ from pydantic import (
|
|
|
14
14
|
)
|
|
15
15
|
from strenum import LowercaseStrEnum, PascalCaseStrEnum
|
|
16
16
|
|
|
17
|
-
from splight_lib.constants import DESCRIPTION_MAX_LENGTH
|
|
18
17
|
from splight_lib.models.asset import Asset
|
|
19
18
|
from splight_lib.models.attribute import Attribute
|
|
20
19
|
from splight_lib.models.data_address import DataAddresses as DLDataAddress
|
|
@@ -63,17 +62,17 @@ class ValueType(PascalCaseStrEnum):
|
|
|
63
62
|
|
|
64
63
|
class Parameter(BaseModel):
|
|
65
64
|
name: str
|
|
66
|
-
description: str = ""
|
|
65
|
+
description: str = Field(default="")
|
|
67
66
|
type: str = "str"
|
|
68
67
|
required: bool = False
|
|
69
68
|
multiple: bool = False
|
|
70
69
|
sensitive: bool = False
|
|
71
|
-
choices:
|
|
72
|
-
depends_on: str
|
|
70
|
+
choices: Optional[List[Any]] = None
|
|
71
|
+
depends_on: Optional[str] = None
|
|
73
72
|
|
|
74
73
|
|
|
75
74
|
class InputParameter(Parameter):
|
|
76
|
-
value: Any
|
|
75
|
+
value: Optional[Any] = None
|
|
77
76
|
|
|
78
77
|
|
|
79
78
|
class DataAddress(Parameter):
|
|
@@ -91,7 +90,7 @@ class DataAddress(Parameter):
|
|
|
91
90
|
|
|
92
91
|
|
|
93
92
|
class InputDataAddress(DataAddress):
|
|
94
|
-
value:
|
|
93
|
+
value: Optional[Union[List[DLDataAddress], DLDataAddress]] = None
|
|
95
94
|
|
|
96
95
|
# NOTE: this is a patch.
|
|
97
96
|
# API returns [] as default for InputDataAddress with multiple set
|
|
@@ -100,51 +99,52 @@ class InputDataAddress(DataAddress):
|
|
|
100
99
|
def validate_file(self):
|
|
101
100
|
if self.multiple and self.value is None:
|
|
102
101
|
self.value = []
|
|
102
|
+
|
|
103
103
|
return self
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
class OutputParameter(BaseModel):
|
|
107
107
|
name: str
|
|
108
|
-
description: str = ""
|
|
108
|
+
description: str = Field(default="")
|
|
109
109
|
type: str
|
|
110
|
-
choices:
|
|
111
|
-
depends_on: str
|
|
110
|
+
choices: Optional[List[Any]] = None
|
|
111
|
+
depends_on: Optional[str] = None
|
|
112
112
|
filterable: bool = False
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
class Output(BaseModel):
|
|
116
116
|
name: str
|
|
117
|
-
fields:
|
|
117
|
+
fields: List[OutputParameter]
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
class CustomType(BaseModel):
|
|
121
121
|
name: str
|
|
122
|
-
fields:
|
|
122
|
+
fields: List[Parameter]
|
|
123
123
|
|
|
124
|
-
_reserved_names: ClassVar[
|
|
124
|
+
_reserved_names: ClassVar[List[str]] = ["id", "name", "description"]
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
class Routine(BaseModel):
|
|
128
128
|
name: str
|
|
129
|
-
max_instances: int
|
|
129
|
+
max_instances: Optional[int] = None
|
|
130
130
|
|
|
131
|
-
config:
|
|
132
|
-
input:
|
|
133
|
-
output:
|
|
131
|
+
config: Optional[List[InputParameter]] = []
|
|
132
|
+
input: List[DataAddress] = []
|
|
133
|
+
output: List[DataAddress] = []
|
|
134
134
|
|
|
135
|
-
_reserved_names: ClassVar[
|
|
135
|
+
_reserved_names: ClassVar[List[str]] = ["id", "name", "description"]
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
class Endpoint(BaseModel):
|
|
139
|
-
name: str
|
|
140
|
-
port: int
|
|
139
|
+
name: Optional[str]
|
|
140
|
+
port: Union[int, str]
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
class SplightObject(SplightDatabaseBaseModel):
|
|
144
|
-
id: str
|
|
144
|
+
id: Optional[str] = None
|
|
145
145
|
name: str
|
|
146
|
-
component_id: str
|
|
147
|
-
description: str = ""
|
|
146
|
+
component_id: Optional[str] = None
|
|
147
|
+
description: str = Field(default="")
|
|
148
148
|
type: str
|
|
149
149
|
|
|
150
150
|
def save(self):
|
|
@@ -154,7 +154,7 @@ class SplightObject(SplightDatabaseBaseModel):
|
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
class ComponentObject(SplightObject):
|
|
157
|
-
data:
|
|
157
|
+
data: List[InputParameter] = []
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
class RoutineEvaluation(SplightDatalakeBaseModel):
|
|
@@ -162,18 +162,18 @@ class RoutineEvaluation(SplightDatalakeBaseModel):
|
|
|
162
162
|
|
|
163
163
|
routine: str
|
|
164
164
|
status: RoutineStatus
|
|
165
|
-
status_text: str
|
|
165
|
+
status_text: Optional[str]
|
|
166
166
|
|
|
167
167
|
|
|
168
168
|
class RoutineObject(SplightObject):
|
|
169
169
|
status: RoutineStatus = RoutineStatus.RUNNING
|
|
170
170
|
|
|
171
|
-
config:
|
|
172
|
-
input:
|
|
173
|
-
output:
|
|
171
|
+
config: Optional[List[InputParameter]] = []
|
|
172
|
+
input: List[InputDataAddress] = []
|
|
173
|
+
output: List[InputDataAddress] = []
|
|
174
174
|
|
|
175
175
|
def report_status(
|
|
176
|
-
self, status: RoutineStatus, status_text: str
|
|
176
|
+
self, status: RoutineStatus, status_text: Optional[str] = None
|
|
177
177
|
):
|
|
178
178
|
evaluation_status = RoutineEvaluation(
|
|
179
179
|
routine=str(self.id),
|
|
@@ -197,15 +197,15 @@ class RoutineObject(SplightObject):
|
|
|
197
197
|
|
|
198
198
|
|
|
199
199
|
class Component(SplightDatabaseBaseModel):
|
|
200
|
-
id: str
|
|
201
|
-
name: str
|
|
200
|
+
id: Optional[str] = None
|
|
201
|
+
name: Optional[str] = None
|
|
202
202
|
version: str
|
|
203
|
-
custom_types:
|
|
203
|
+
custom_types: List[CustomType] = []
|
|
204
204
|
component_type: ComponentType = ComponentType.CONNECTOR
|
|
205
|
-
input:
|
|
206
|
-
output:
|
|
207
|
-
endpoints:
|
|
208
|
-
routines:
|
|
205
|
+
input: List[InputParameter] = []
|
|
206
|
+
output: List[Output] = []
|
|
207
|
+
endpoints: List[Endpoint] = []
|
|
208
|
+
routines: List[Routine] = []
|
|
209
209
|
|
|
210
210
|
|
|
211
211
|
DATABASE_TYPES = {
|
|
@@ -227,7 +227,7 @@ DB_MODEL_TYPE_MAPPING = {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
def parse_variable_string(raw_value: str
|
|
230
|
+
def parse_variable_string(raw_value: Optional[str]) -> Any:
|
|
231
231
|
if raw_value is None:
|
|
232
232
|
return ""
|
|
233
233
|
pattern = re.compile(r"^\$\{\{(\w+)\.(\w+)\}\}$")
|
|
@@ -240,7 +240,7 @@ def parse_variable_string(raw_value: str | None) -> Any:
|
|
|
240
240
|
return secret.value
|
|
241
241
|
|
|
242
242
|
|
|
243
|
-
def get_field_value(field: InputParameter
|
|
243
|
+
def get_field_value(field: Union[InputParameter, List[InputParameter]]):
|
|
244
244
|
multiple = field.multiple
|
|
245
245
|
|
|
246
246
|
value = field.value
|
|
@@ -289,16 +289,16 @@ def get_field_value(field: InputParameter | list[InputParameter]):
|
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
class AbstractObjectInstance(ABC, SplightDatabaseBaseModel):
|
|
292
|
-
id: str
|
|
292
|
+
id: Optional[str] = None
|
|
293
293
|
name: str = ""
|
|
294
|
-
description:
|
|
294
|
+
description: str = ""
|
|
295
295
|
|
|
296
|
-
_default_attrs:
|
|
296
|
+
_default_attrs: List[str] = PrivateAttr(
|
|
297
297
|
["id", "name", "component_id", "description"]
|
|
298
298
|
)
|
|
299
|
-
_schema: ClassVar[BaseModel
|
|
300
|
-
_database_class: ClassVar[Type[SplightDatabaseBaseModel]
|
|
301
|
-
_component_id: ClassVar[str
|
|
299
|
+
_schema: ClassVar[Optional[BaseModel]] = None
|
|
300
|
+
_database_class: ClassVar[Optional[Type[SplightDatabaseBaseModel]]] = None
|
|
301
|
+
_component_id: ClassVar[Optional[str]] = None
|
|
302
302
|
|
|
303
303
|
def save(self):
|
|
304
304
|
component_obj = self.to_object()
|
|
@@ -311,7 +311,7 @@ class AbstractObjectInstance(ABC, SplightDatabaseBaseModel):
|
|
|
311
311
|
component_obj.delete()
|
|
312
312
|
|
|
313
313
|
@classmethod
|
|
314
|
-
def list(cls, **params:
|
|
314
|
+
def list(cls, **params: Dict) -> List["AbstractObjectInstance"]:
|
|
315
315
|
if not cls._schema or not cls._component_id:
|
|
316
316
|
raise InvalidObjectInstance(
|
|
317
317
|
(
|
|
@@ -406,7 +406,7 @@ class AbstractObjectInstance(ABC, SplightDatabaseBaseModel):
|
|
|
406
406
|
|
|
407
407
|
|
|
408
408
|
class ComponentObjectInstance(AbstractObjectInstance):
|
|
409
|
-
_schema: ClassVar[CustomType
|
|
409
|
+
_schema: ClassVar[Optional[CustomType]] = None
|
|
410
410
|
_database_class: ClassVar[Type[SplightDatabaseBaseModel]] = ComponentObject
|
|
411
411
|
|
|
412
412
|
def to_object(self) -> ComponentObject:
|
|
@@ -431,13 +431,13 @@ class ComponentObjectInstance(AbstractObjectInstance):
|
|
|
431
431
|
def from_custom_type(
|
|
432
432
|
cls,
|
|
433
433
|
custom_type: CustomType,
|
|
434
|
-
component_id: str
|
|
434
|
+
component_id: Optional[str] = None,
|
|
435
435
|
) -> Type["ComponentObjectInstance"]:
|
|
436
436
|
fields = {}
|
|
437
437
|
|
|
438
438
|
for field in custom_type.fields:
|
|
439
439
|
field_type = DB_MODEL_TYPE_MAPPING.get(field.type, cls)
|
|
440
|
-
field_type =
|
|
440
|
+
field_type = List[field_type] if field.multiple else field_type
|
|
441
441
|
field_type = (
|
|
442
442
|
Optional[field_type] if not field.required else field_type
|
|
443
443
|
)
|
|
@@ -486,7 +486,7 @@ class ComponentObjectInstance(AbstractObjectInstance):
|
|
|
486
486
|
def from_component(
|
|
487
487
|
cls,
|
|
488
488
|
component: Component,
|
|
489
|
-
) ->
|
|
489
|
+
) -> Dict[str, "ComponentObjectInstance"]:
|
|
490
490
|
return {
|
|
491
491
|
ct.name: cls.from_custom_type(ct, component.id)
|
|
492
492
|
for ct in component.custom_types
|
|
@@ -564,13 +564,13 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
564
564
|
return model_class
|
|
565
565
|
|
|
566
566
|
@classmethod
|
|
567
|
-
def _create_config_model(cls, parameters:
|
|
567
|
+
def _create_config_model(cls, parameters: List[Parameter]) -> Type:
|
|
568
568
|
fields = {}
|
|
569
569
|
for field in parameters:
|
|
570
570
|
field_type = DB_MODEL_TYPE_MAPPING.get(
|
|
571
571
|
field.type, ComponentObjectInstance
|
|
572
572
|
)
|
|
573
|
-
field_type =
|
|
573
|
+
field_type = List[field_type] if field.multiple else field_type
|
|
574
574
|
field_type = field_type if field.required else Optional[field_type]
|
|
575
575
|
field_value = ... if field.required else None
|
|
576
576
|
fields.update({field.name: (field_type, field_value)})
|
|
@@ -578,11 +578,11 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
578
578
|
return create_model("Config", **fields)
|
|
579
579
|
|
|
580
580
|
@classmethod
|
|
581
|
-
def _create_input_model(cls, parameters:
|
|
581
|
+
def _create_input_model(cls, parameters: List[DataAddress]) -> Type:
|
|
582
582
|
fields = {}
|
|
583
583
|
for field in parameters:
|
|
584
584
|
field_type = (
|
|
585
|
-
|
|
585
|
+
List[DLDataAddress] if field.multiple else DLDataAddress
|
|
586
586
|
)
|
|
587
587
|
field_type = field_type if field.required else Optional[field_type]
|
|
588
588
|
field_value = ... if field.required else None
|
|
@@ -590,11 +590,11 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
590
590
|
return create_model("Input", **fields)
|
|
591
591
|
|
|
592
592
|
@classmethod
|
|
593
|
-
def _create_output_model(cls, parameters:
|
|
593
|
+
def _create_output_model(cls, parameters: List[DataAddress]) -> Type:
|
|
594
594
|
fields = {}
|
|
595
595
|
for field in parameters:
|
|
596
596
|
field_type = (
|
|
597
|
-
|
|
597
|
+
List[DLDataAddress] if field.multiple else DLDataAddress
|
|
598
598
|
)
|
|
599
599
|
field_type = field_type if field.required else Optional[field_type]
|
|
600
600
|
field_value = ... if field.required else None
|
|
@@ -631,7 +631,7 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
631
631
|
return cls.model_validate(params_dict)
|
|
632
632
|
|
|
633
633
|
def report_status(
|
|
634
|
-
self, status: RoutineStatus, status_text: str
|
|
634
|
+
self, status: RoutineStatus, status_text: Optional[str] = None
|
|
635
635
|
):
|
|
636
636
|
routine_object = self.to_object()
|
|
637
637
|
routine_object.report_status(status=status, status_text=status_text)
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# TODO: set types fixed values
|
|
2
|
+
import json
|
|
3
|
+
import re
|
|
4
|
+
from enum import auto
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, ValidationError, model_validator
|
|
7
|
+
from strenum import UppercaseStrEnum
|
|
8
|
+
|
|
9
|
+
from splight_lib.models.alert import AlertItemType
|
|
10
|
+
from splight_lib.models.database_base import (
|
|
11
|
+
ResourceSummary,
|
|
12
|
+
SplightDatabaseBaseModel,
|
|
13
|
+
)
|
|
14
|
+
from splight_lib.models.exceptions import MissingAlertItemExpression
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ChartItemType(UppercaseStrEnum):
|
|
18
|
+
QUERY = auto()
|
|
19
|
+
EXPRESSION = auto()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Threshold(BaseModel):
|
|
23
|
+
color: str | None = None
|
|
24
|
+
display_text: str | None = None
|
|
25
|
+
value: float | None = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ValueMapping(BaseModel):
|
|
29
|
+
display_text: str | None = None
|
|
30
|
+
order: int = 0
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ExactMatchValueMapping(ValueMapping):
|
|
34
|
+
match_value: str | None = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class RangeValueMapping(ValueMapping):
|
|
38
|
+
range_start: float | None = None
|
|
39
|
+
range_end: float | None = None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RegexMatchValueMapping(ValueMapping):
|
|
43
|
+
regular_expression: str | None = None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class Filter(SplightDatabaseBaseModel):
|
|
47
|
+
id: str | None = None
|
|
48
|
+
chart_item: str
|
|
49
|
+
operator: str | None = None
|
|
50
|
+
key: str | None = None
|
|
51
|
+
value: str | None = None
|
|
52
|
+
label: str | None = None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class AdvancedFilter(SplightDatabaseBaseModel):
|
|
56
|
+
id: str | None = None
|
|
57
|
+
chart_item: str
|
|
58
|
+
operator: str | None = None
|
|
59
|
+
key: str | None = None
|
|
60
|
+
field: str | None = None
|
|
61
|
+
value: str | None = None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ChartItem(BaseModel):
|
|
65
|
+
color: str | None = None
|
|
66
|
+
ref_id: str
|
|
67
|
+
type: ChartItemType = ChartItemType.QUERY
|
|
68
|
+
label: str
|
|
69
|
+
hidden: bool = False
|
|
70
|
+
expression: str | None = None
|
|
71
|
+
expression_plain: str | None = None
|
|
72
|
+
query_filter_asset: ResourceSummary | None = None
|
|
73
|
+
query_filter_attribute: ResourceSummary | None = None
|
|
74
|
+
query_plain: str = ""
|
|
75
|
+
query_group_unit: str | None = None
|
|
76
|
+
query_group_function: str | None = None
|
|
77
|
+
query_sort_direction: int | None = -1
|
|
78
|
+
query_limit: int = 10000
|
|
79
|
+
|
|
80
|
+
@model_validator(mode="after")
|
|
81
|
+
def validate_expression(self):
|
|
82
|
+
if self.type == AlertItemType.EXPRESSION:
|
|
83
|
+
if self.expression is None:
|
|
84
|
+
raise MissingAlertItemExpression(
|
|
85
|
+
"Parameter 'expression' is required for expression type alert items"
|
|
86
|
+
)
|
|
87
|
+
self.expression_plain = (
|
|
88
|
+
self._get_expression_plain()
|
|
89
|
+
if self.expression_plain is None
|
|
90
|
+
else self.expression_plain
|
|
91
|
+
)
|
|
92
|
+
return self
|
|
93
|
+
|
|
94
|
+
@model_validator(mode="after")
|
|
95
|
+
def validate_query(self):
|
|
96
|
+
if self.type == AlertItemType.QUERY:
|
|
97
|
+
for attr in [
|
|
98
|
+
("query_filter_asset", self.query_filter_asset),
|
|
99
|
+
("query_filter_attribute", self.query_filter_attribute),
|
|
100
|
+
]:
|
|
101
|
+
if attr is None:
|
|
102
|
+
raise ValidationError(
|
|
103
|
+
(
|
|
104
|
+
f"Parameter '{attr}' is required for query type "
|
|
105
|
+
"alert items"
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
self.query_plain = (
|
|
109
|
+
self._get_query_plain()
|
|
110
|
+
if self.query_plain is None
|
|
111
|
+
else self.query_plain
|
|
112
|
+
)
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
def _get_expression_plain(self):
|
|
116
|
+
pattern = r"\$\w+"
|
|
117
|
+
args = re.findall(pattern, self.expression)
|
|
118
|
+
str_args = ", ".join(args)
|
|
119
|
+
body = f"function ({str_args}) {{ return {self.expression} }}"
|
|
120
|
+
expression_plain = {
|
|
121
|
+
"$function": {"body": body, "args": args, "lang": "js"}
|
|
122
|
+
}
|
|
123
|
+
return json.dumps(expression_plain)
|
|
124
|
+
|
|
125
|
+
def _get_query_plain(self):
|
|
126
|
+
query_plain = [
|
|
127
|
+
{
|
|
128
|
+
"$match": {
|
|
129
|
+
"asset": self.query_filter_asset["id"],
|
|
130
|
+
"attribute": self.query_filter_attribute["id"],
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
]
|
|
134
|
+
if self.query_group_unit and self.query_group_function:
|
|
135
|
+
query_plain.extend(
|
|
136
|
+
[
|
|
137
|
+
{
|
|
138
|
+
"$addFields": {
|
|
139
|
+
"timestamp": {
|
|
140
|
+
"$dateTrunc": {
|
|
141
|
+
"date": "$timestamp",
|
|
142
|
+
"unit": self.query_group_unit,
|
|
143
|
+
"binSize": 1,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"$group": {
|
|
150
|
+
"_id": "$timestamp",
|
|
151
|
+
"value": {
|
|
152
|
+
f"${self.query_group_function}": "$value"
|
|
153
|
+
},
|
|
154
|
+
"timestamp": {"$last": "$timestamp"},
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
]
|
|
158
|
+
)
|
|
159
|
+
return json.dumps(query_plain)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class Dashboard(SplightDatabaseBaseModel):
|
|
163
|
+
id: str | None = None
|
|
164
|
+
name: str
|
|
165
|
+
description: str | None = None
|
|
166
|
+
related_assets: list(ResourceSummary)
|
|
167
|
+
tags: list(ResourceSummary)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class Tab(SplightDatabaseBaseModel):
|
|
171
|
+
id: str | None = None
|
|
172
|
+
name: str
|
|
173
|
+
order: int | None = None
|
|
174
|
+
dashboard: str
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class Chart(SplightDatabaseBaseModel):
|
|
178
|
+
id: str | None = None
|
|
179
|
+
name: str
|
|
180
|
+
tab: str
|
|
181
|
+
description: str | None = None
|
|
182
|
+
position_x: int | None = None
|
|
183
|
+
position_y: int | None = None
|
|
184
|
+
min_height: int | None = None
|
|
185
|
+
min_width: int | None = None
|
|
186
|
+
display_time_range: bool
|
|
187
|
+
labels_display: bool
|
|
188
|
+
labels_aggregation: str
|
|
189
|
+
labels_placement: str
|
|
190
|
+
refresh_interval: str
|
|
191
|
+
relative_window_time: str
|
|
192
|
+
show_beyond_data: bool
|
|
193
|
+
timezone: str
|
|
194
|
+
timestamp_gte: str
|
|
195
|
+
timestamp_lte: str
|
|
196
|
+
height: int
|
|
197
|
+
width: int
|
|
198
|
+
collection: str
|
|
199
|
+
chart_items: list[ChartItem]
|
|
200
|
+
thresholds: list[Threshold]
|
|
201
|
+
value_mappings: list[
|
|
202
|
+
ExactMatchValueMapping | RangeValueMapping | RegexMatchValueMapping
|
|
203
|
+
] = []
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class DashboardActionListChart(Chart):
|
|
207
|
+
type: str = "actionlist"
|
|
208
|
+
action_list_type: str
|
|
209
|
+
filter_name: str
|
|
210
|
+
filter_asset_name: str | None = None
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class DashboardAlertEventsChart(Chart):
|
|
214
|
+
type: str = "alertevents"
|
|
215
|
+
filter_name: str
|
|
216
|
+
filter_old_status: str
|
|
217
|
+
filter_new_status: str
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class DashboardAlertListChart(Chart):
|
|
221
|
+
type: str = "alertlist"
|
|
222
|
+
filter_name: str
|
|
223
|
+
filter_status: list(str)
|
|
224
|
+
alert_list_type: str | None = None
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class DashboardAssetListChart(Chart):
|
|
228
|
+
type: str = "assetlist"
|
|
229
|
+
filter_name: str
|
|
230
|
+
filter_status: list(str)
|
|
231
|
+
asset_list_type: str | None = None
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class DashboardBarChart(Chart):
|
|
235
|
+
type: str = "bar"
|
|
236
|
+
y_axis_unit: str | None = None
|
|
237
|
+
number_of_decimals: int | None = None
|
|
238
|
+
orientation: int | None = None
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class DashboardBarGaugeChart(Chart):
|
|
242
|
+
type: str = "bargauge"
|
|
243
|
+
max_limit: int | None = None
|
|
244
|
+
number_of_decimals: int | None = None
|
|
245
|
+
orientation: str | None = None
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class DashboardCommandListChart(Chart):
|
|
249
|
+
type: str = "commandlist"
|
|
250
|
+
command_list_type: str
|
|
251
|
+
filter_name: str
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class DashboardGaugeChart(Chart):
|
|
255
|
+
type: str = "gauge"
|
|
256
|
+
max_limit: int | None = None
|
|
257
|
+
number_of_decimals: int | None = None
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class DashboardHistogramChart(Chart):
|
|
261
|
+
type: str = "histogram"
|
|
262
|
+
number_of_decimals: int | None = None
|
|
263
|
+
bucket_count: int
|
|
264
|
+
bucket_size: int
|
|
265
|
+
histogram_type: str
|
|
266
|
+
sorting: str
|
|
267
|
+
stacked: bool
|
|
268
|
+
categories_top_max_limit: int | None = None
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class DashboardImageChart(Chart):
|
|
272
|
+
type: str = "image"
|
|
273
|
+
image_url: str | None = None
|
|
274
|
+
image_file: str | None = None
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class DashboardStatChart(Chart):
|
|
278
|
+
type: str = "stat"
|
|
279
|
+
y_axis_unit: str
|
|
280
|
+
border: bool
|
|
281
|
+
number_of_decimals: int | None = None
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
class DashboardTableChart(Chart):
|
|
285
|
+
type: str = "table"
|
|
286
|
+
y_axis_unit: str
|
|
287
|
+
number_of_decimals: int
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class DashboardTextChart(Chart):
|
|
291
|
+
type: str = "text"
|
|
292
|
+
text: str | None = None
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class DashboardTimeseriesChart(Chart):
|
|
296
|
+
type: str = "timeseries"
|
|
297
|
+
y_axis_max_limit: int | None = None
|
|
298
|
+
y_axis_min_limit: int | None = None
|
|
299
|
+
y_axis_unit: str | None = None
|
|
300
|
+
number_of_decimals: int | None = None
|
|
301
|
+
x_axis_format: str
|
|
302
|
+
x_axis_auto_skip: bool
|
|
303
|
+
x_axis_max_ticks_limit: int | None = None
|
|
304
|
+
line_interpolation_style: str | None = None
|
|
305
|
+
timeseries_type: str | None = None
|
|
306
|
+
fill: bool
|
|
307
|
+
show_line: bool
|