scope-client 1.4.912__py3-none-any.whl → 1.4.914__py3-none-any.whl
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.
- scope_client/api_bindings/__init__.py +19 -0
- scope_client/api_bindings/api/__init__.py +1 -0
- scope_client/api_bindings/api/models_v1_api.py +17 -0
- scope_client/api_bindings/api/tasks_v1_api.py +1757 -0
- scope_client/api_bindings/models/__init__.py +18 -0
- scope_client/api_bindings/models/config.py +185 -0
- scope_client/api_bindings/models/config1.py +185 -0
- scope_client/api_bindings/models/example_config.py +89 -0
- scope_client/api_bindings/models/examples_config.py +102 -0
- scope_client/api_bindings/models/keywords_config.py +87 -0
- scope_client/api_bindings/models/metrics_query_result.py +2 -2
- scope_client/api_bindings/models/model.py +8 -1
- scope_client/api_bindings/models/new_rule_request.py +104 -0
- scope_client/api_bindings/models/patch_task_request.py +101 -0
- scope_client/api_bindings/models/permission_name.py +6 -0
- scope_client/api_bindings/models/pii_config.py +106 -0
- scope_client/api_bindings/models/post_model.py +9 -1
- scope_client/api_bindings/models/post_task_request.py +105 -0
- scope_client/api_bindings/models/put_task_state_cache_request.py +91 -0
- scope_client/api_bindings/models/regex_config.py +87 -0
- scope_client/api_bindings/models/rule_response.py +121 -0
- scope_client/api_bindings/models/rule_scope.py +37 -0
- scope_client/api_bindings/models/rule_type.py +44 -0
- scope_client/api_bindings/models/task_mutation_response.py +87 -0
- scope_client/api_bindings/models/task_read_response.py +106 -0
- scope_client/api_bindings/models/task_response.py +103 -0
- scope_client/api_bindings/models/toxicity_config.py +100 -0
- {scope_client-1.4.912.dist-info → scope_client-1.4.914.dist-info}/METADATA +1 -1
- {scope_client-1.4.912.dist-info → scope_client-1.4.914.dist-info}/RECORD +31 -12
- {scope_client-1.4.912.dist-info → scope_client-1.4.914.dist-info}/WHEEL +0 -0
- {scope_client-1.4.912.dist-info → scope_client-1.4.914.dist-info}/top_level.txt +0 -0
|
@@ -35,6 +35,8 @@ from scope_client.api_bindings.models.bound_member_kind import BoundMemberKind
|
|
|
35
35
|
from scope_client.api_bindings.models.bound_resource import BoundResource
|
|
36
36
|
from scope_client.api_bindings.models.bound_resource_kind import BoundResourceKind
|
|
37
37
|
from scope_client.api_bindings.models.bound_role import BoundRole
|
|
38
|
+
from scope_client.api_bindings.models.config import Config
|
|
39
|
+
from scope_client.api_bindings.models.config1 import Config1
|
|
38
40
|
from scope_client.api_bindings.models.conflict_error import ConflictError
|
|
39
41
|
from scope_client.api_bindings.models.connector_check_job_spec import ConnectorCheckJobSpec
|
|
40
42
|
from scope_client.api_bindings.models.connector_check_outcome import ConnectorCheckOutcome
|
|
@@ -79,6 +81,8 @@ from scope_client.api_bindings.models.datasets_sort import DatasetsSort
|
|
|
79
81
|
from scope_client.api_bindings.models.definition import Definition
|
|
80
82
|
from scope_client.api_bindings.models.delete_group_membership import DeleteGroupMembership
|
|
81
83
|
from scope_client.api_bindings.models.dimension import Dimension
|
|
84
|
+
from scope_client.api_bindings.models.example_config import ExampleConfig
|
|
85
|
+
from scope_client.api_bindings.models.examples_config import ExamplesConfig
|
|
82
86
|
from scope_client.api_bindings.models.extended_role import ExtendedRole
|
|
83
87
|
from scope_client.api_bindings.models.fetch_data_job_spec import FetchDataJobSpec
|
|
84
88
|
from scope_client.api_bindings.models.generate_metrics_spec_request import GenerateMetricsSpecRequest
|
|
@@ -109,6 +113,7 @@ from scope_client.api_bindings.models.job_trigger import JobTrigger
|
|
|
109
113
|
from scope_client.api_bindings.models.jobs_batch import JobsBatch
|
|
110
114
|
from scope_client.api_bindings.models.jobs_sort import JobsSort
|
|
111
115
|
from scope_client.api_bindings.models.joined_dataset import JoinedDataset
|
|
116
|
+
from scope_client.api_bindings.models.keywords_config import KeywordsConfig
|
|
112
117
|
from scope_client.api_bindings.models.list_datasets_job_spec import ListDatasetsJobSpec
|
|
113
118
|
from scope_client.api_bindings.models.list_type import ListType
|
|
114
119
|
from scope_client.api_bindings.models.metrics_arg_spec import MetricsArgSpec
|
|
@@ -130,6 +135,7 @@ from scope_client.api_bindings.models.model_metric_spec import ModelMetricSpec
|
|
|
130
135
|
from scope_client.api_bindings.models.model_metrics_schedule import ModelMetricsSchedule
|
|
131
136
|
from scope_client.api_bindings.models.model_problem_type import ModelProblemType
|
|
132
137
|
from scope_client.api_bindings.models.models_sort import ModelsSort
|
|
138
|
+
from scope_client.api_bindings.models.new_rule_request import NewRuleRequest
|
|
133
139
|
from scope_client.api_bindings.models.not_found_error import NotFoundError
|
|
134
140
|
from scope_client.api_bindings.models.numeric_metric import NumericMetric
|
|
135
141
|
from scope_client.api_bindings.models.numeric_point import NumericPoint
|
|
@@ -137,6 +143,7 @@ from scope_client.api_bindings.models.numeric_time_series import NumericTimeSeri
|
|
|
137
143
|
from scope_client.api_bindings.models.object_type import ObjectType
|
|
138
144
|
from scope_client.api_bindings.models.object_value import ObjectValue
|
|
139
145
|
from scope_client.api_bindings.models.organization import Organization
|
|
146
|
+
from scope_client.api_bindings.models.pii_config import PIIConfig
|
|
140
147
|
from scope_client.api_bindings.models.pagination import Pagination
|
|
141
148
|
from scope_client.api_bindings.models.patch_alert_rule import PatchAlertRule
|
|
142
149
|
from scope_client.api_bindings.models.patch_connector_spec import PatchConnectorSpec
|
|
@@ -148,6 +155,7 @@ from scope_client.api_bindings.models.patch_job import PatchJob
|
|
|
148
155
|
from scope_client.api_bindings.models.patch_model import PatchModel
|
|
149
156
|
from scope_client.api_bindings.models.patch_project import PatchProject
|
|
150
157
|
from scope_client.api_bindings.models.patch_service_account_user import PatchServiceAccountUser
|
|
158
|
+
from scope_client.api_bindings.models.patch_task_request import PatchTaskRequest
|
|
151
159
|
from scope_client.api_bindings.models.patch_user import PatchUser
|
|
152
160
|
from scope_client.api_bindings.models.patch_webhook import PatchWebhook
|
|
153
161
|
from scope_client.api_bindings.models.patch_workspace import PatchWorkspace
|
|
@@ -183,6 +191,7 @@ from scope_client.api_bindings.models.post_model import PostModel
|
|
|
183
191
|
from scope_client.api_bindings.models.post_project import PostProject
|
|
184
192
|
from scope_client.api_bindings.models.post_role_binding import PostRoleBinding
|
|
185
193
|
from scope_client.api_bindings.models.post_service_account import PostServiceAccount
|
|
194
|
+
from scope_client.api_bindings.models.post_task_request import PostTaskRequest
|
|
186
195
|
from scope_client.api_bindings.models.post_upsolve_tenant import PostUpsolveTenant
|
|
187
196
|
from scope_client.api_bindings.models.post_webhook import PostWebhook
|
|
188
197
|
from scope_client.api_bindings.models.post_workspace import PostWorkspace
|
|
@@ -196,6 +205,8 @@ from scope_client.api_bindings.models.put_job_state import PutJobState
|
|
|
196
205
|
from scope_client.api_bindings.models.put_model_metric_spec import PutModelMetricSpec
|
|
197
206
|
from scope_client.api_bindings.models.put_model_metrics_schedule import PutModelMetricsSchedule
|
|
198
207
|
from scope_client.api_bindings.models.put_retrieved_data import PutRetrievedData
|
|
208
|
+
from scope_client.api_bindings.models.put_task_state_cache_request import PutTaskStateCacheRequest
|
|
209
|
+
from scope_client.api_bindings.models.regex_config import RegexConfig
|
|
199
210
|
from scope_client.api_bindings.models.register_user import RegisterUser
|
|
200
211
|
from scope_client.api_bindings.models.resource_kind import ResourceKind
|
|
201
212
|
from scope_client.api_bindings.models.resource_list_aggregation_spec_schema import ResourceListAggregationSpecSchema
|
|
@@ -224,6 +235,9 @@ from scope_client.api_bindings.models.result_filter import ResultFilter
|
|
|
224
235
|
from scope_client.api_bindings.models.role import Role
|
|
225
236
|
from scope_client.api_bindings.models.role_binding import RoleBinding
|
|
226
237
|
from scope_client.api_bindings.models.role_sort import RoleSort
|
|
238
|
+
from scope_client.api_bindings.models.rule_response import RuleResponse
|
|
239
|
+
from scope_client.api_bindings.models.rule_scope import RuleScope
|
|
240
|
+
from scope_client.api_bindings.models.rule_type import RuleType
|
|
227
241
|
from scope_client.api_bindings.models.scalar_type import ScalarType
|
|
228
242
|
from scope_client.api_bindings.models.schedule_jobs_job_spec import ScheduleJobsJobSpec
|
|
229
243
|
from scope_client.api_bindings.models.schema_inspection_job_spec import SchemaInspectionJobSpec
|
|
@@ -235,6 +249,10 @@ from scope_client.api_bindings.models.sketch_metric import SketchMetric
|
|
|
235
249
|
from scope_client.api_bindings.models.sketch_point import SketchPoint
|
|
236
250
|
from scope_client.api_bindings.models.sketch_time_series import SketchTimeSeries
|
|
237
251
|
from scope_client.api_bindings.models.sort_order import SortOrder
|
|
252
|
+
from scope_client.api_bindings.models.task_mutation_response import TaskMutationResponse
|
|
253
|
+
from scope_client.api_bindings.models.task_read_response import TaskReadResponse
|
|
254
|
+
from scope_client.api_bindings.models.task_response import TaskResponse
|
|
255
|
+
from scope_client.api_bindings.models.toxicity_config import ToxicityConfig
|
|
238
256
|
from scope_client.api_bindings.models.upsolve_token import UpsolveToken
|
|
239
257
|
from scope_client.api_bindings.models.user import User
|
|
240
258
|
from scope_client.api_bindings.models.user_credentials import UserCredentials
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Arthur Scope
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
from inspect import getfullargspec
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
import re # noqa: F401
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
21
|
+
from typing import Optional
|
|
22
|
+
from scope_client.api_bindings.models.examples_config import ExamplesConfig
|
|
23
|
+
from scope_client.api_bindings.models.keywords_config import KeywordsConfig
|
|
24
|
+
from scope_client.api_bindings.models.pii_config import PIIConfig
|
|
25
|
+
from scope_client.api_bindings.models.regex_config import RegexConfig
|
|
26
|
+
from scope_client.api_bindings.models.toxicity_config import ToxicityConfig
|
|
27
|
+
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
|
|
28
|
+
from typing_extensions import Literal, Self
|
|
29
|
+
from pydantic import Field
|
|
30
|
+
|
|
31
|
+
CONFIG_ANY_OF_SCHEMAS = ["ExamplesConfig", "KeywordsConfig", "PIIConfig", "RegexConfig", "ToxicityConfig"]
|
|
32
|
+
|
|
33
|
+
class Config(BaseModel):
|
|
34
|
+
"""
|
|
35
|
+
Config for the rule
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
# data type: KeywordsConfig
|
|
39
|
+
anyof_schema_1_validator: Optional[KeywordsConfig] = None
|
|
40
|
+
# data type: RegexConfig
|
|
41
|
+
anyof_schema_2_validator: Optional[RegexConfig] = None
|
|
42
|
+
# data type: ExamplesConfig
|
|
43
|
+
anyof_schema_3_validator: Optional[ExamplesConfig] = None
|
|
44
|
+
# data type: ToxicityConfig
|
|
45
|
+
anyof_schema_4_validator: Optional[ToxicityConfig] = None
|
|
46
|
+
# data type: PIIConfig
|
|
47
|
+
anyof_schema_5_validator: Optional[PIIConfig] = None
|
|
48
|
+
if TYPE_CHECKING:
|
|
49
|
+
actual_instance: Optional[Union[ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig]] = None
|
|
50
|
+
else:
|
|
51
|
+
actual_instance: Any = None
|
|
52
|
+
any_of_schemas: Set[str] = { "ExamplesConfig", "KeywordsConfig", "PIIConfig", "RegexConfig", "ToxicityConfig" }
|
|
53
|
+
|
|
54
|
+
model_config = {
|
|
55
|
+
"validate_assignment": True,
|
|
56
|
+
"protected_namespaces": (),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
60
|
+
if args:
|
|
61
|
+
if len(args) > 1:
|
|
62
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
63
|
+
if kwargs:
|
|
64
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
65
|
+
super().__init__(actual_instance=args[0])
|
|
66
|
+
else:
|
|
67
|
+
super().__init__(**kwargs)
|
|
68
|
+
|
|
69
|
+
@field_validator('actual_instance')
|
|
70
|
+
def actual_instance_must_validate_anyof(cls, v):
|
|
71
|
+
if v is None:
|
|
72
|
+
return v
|
|
73
|
+
|
|
74
|
+
instance = Config.model_construct()
|
|
75
|
+
error_messages = []
|
|
76
|
+
# validate data type: KeywordsConfig
|
|
77
|
+
if not isinstance(v, KeywordsConfig):
|
|
78
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `KeywordsConfig`")
|
|
79
|
+
else:
|
|
80
|
+
return v
|
|
81
|
+
|
|
82
|
+
# validate data type: RegexConfig
|
|
83
|
+
if not isinstance(v, RegexConfig):
|
|
84
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `RegexConfig`")
|
|
85
|
+
else:
|
|
86
|
+
return v
|
|
87
|
+
|
|
88
|
+
# validate data type: ExamplesConfig
|
|
89
|
+
if not isinstance(v, ExamplesConfig):
|
|
90
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ExamplesConfig`")
|
|
91
|
+
else:
|
|
92
|
+
return v
|
|
93
|
+
|
|
94
|
+
# validate data type: ToxicityConfig
|
|
95
|
+
if not isinstance(v, ToxicityConfig):
|
|
96
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ToxicityConfig`")
|
|
97
|
+
else:
|
|
98
|
+
return v
|
|
99
|
+
|
|
100
|
+
# validate data type: PIIConfig
|
|
101
|
+
if not isinstance(v, PIIConfig):
|
|
102
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `PIIConfig`")
|
|
103
|
+
else:
|
|
104
|
+
return v
|
|
105
|
+
|
|
106
|
+
if error_messages:
|
|
107
|
+
# no match
|
|
108
|
+
raise ValueError("No match found when setting the actual_instance in Config with anyOf schemas: ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig. Details: " + ", ".join(error_messages))
|
|
109
|
+
else:
|
|
110
|
+
return v
|
|
111
|
+
|
|
112
|
+
@classmethod
|
|
113
|
+
def from_dict(cls, obj: Dict[str, Any]) -> Self:
|
|
114
|
+
return cls.from_json(json.dumps(obj))
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def from_json(cls, json_str: str) -> Self:
|
|
118
|
+
"""Returns the object represented by the json string"""
|
|
119
|
+
instance = cls.model_construct()
|
|
120
|
+
if json_str is None:
|
|
121
|
+
return instance
|
|
122
|
+
|
|
123
|
+
error_messages = []
|
|
124
|
+
# anyof_schema_1_validator: Optional[KeywordsConfig] = None
|
|
125
|
+
try:
|
|
126
|
+
instance.actual_instance = KeywordsConfig.from_json(json_str)
|
|
127
|
+
return instance
|
|
128
|
+
except (ValidationError, ValueError) as e:
|
|
129
|
+
error_messages.append(str(e))
|
|
130
|
+
# anyof_schema_2_validator: Optional[RegexConfig] = None
|
|
131
|
+
try:
|
|
132
|
+
instance.actual_instance = RegexConfig.from_json(json_str)
|
|
133
|
+
return instance
|
|
134
|
+
except (ValidationError, ValueError) as e:
|
|
135
|
+
error_messages.append(str(e))
|
|
136
|
+
# anyof_schema_3_validator: Optional[ExamplesConfig] = None
|
|
137
|
+
try:
|
|
138
|
+
instance.actual_instance = ExamplesConfig.from_json(json_str)
|
|
139
|
+
return instance
|
|
140
|
+
except (ValidationError, ValueError) as e:
|
|
141
|
+
error_messages.append(str(e))
|
|
142
|
+
# anyof_schema_4_validator: Optional[ToxicityConfig] = None
|
|
143
|
+
try:
|
|
144
|
+
instance.actual_instance = ToxicityConfig.from_json(json_str)
|
|
145
|
+
return instance
|
|
146
|
+
except (ValidationError, ValueError) as e:
|
|
147
|
+
error_messages.append(str(e))
|
|
148
|
+
# anyof_schema_5_validator: Optional[PIIConfig] = None
|
|
149
|
+
try:
|
|
150
|
+
instance.actual_instance = PIIConfig.from_json(json_str)
|
|
151
|
+
return instance
|
|
152
|
+
except (ValidationError, ValueError) as e:
|
|
153
|
+
error_messages.append(str(e))
|
|
154
|
+
|
|
155
|
+
if error_messages:
|
|
156
|
+
# no match
|
|
157
|
+
raise ValueError("No match found when deserializing the JSON string into Config with anyOf schemas: ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig. Details: " + ", ".join(error_messages))
|
|
158
|
+
else:
|
|
159
|
+
return instance
|
|
160
|
+
|
|
161
|
+
def to_json(self) -> str:
|
|
162
|
+
"""Returns the JSON representation of the actual instance"""
|
|
163
|
+
if self.actual_instance is None:
|
|
164
|
+
return "null"
|
|
165
|
+
|
|
166
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
167
|
+
return self.actual_instance.to_json()
|
|
168
|
+
else:
|
|
169
|
+
return json.dumps(self.actual_instance)
|
|
170
|
+
|
|
171
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig]]:
|
|
172
|
+
"""Returns the dict representation of the actual instance"""
|
|
173
|
+
if self.actual_instance is None:
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
177
|
+
return self.actual_instance.to_dict()
|
|
178
|
+
else:
|
|
179
|
+
return self.actual_instance
|
|
180
|
+
|
|
181
|
+
def to_str(self) -> str:
|
|
182
|
+
"""Returns the string representation of the actual instance"""
|
|
183
|
+
return pprint.pformat(self.model_dump())
|
|
184
|
+
|
|
185
|
+
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Arthur Scope
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
from inspect import getfullargspec
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
import re # noqa: F401
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
21
|
+
from typing import Optional
|
|
22
|
+
from scope_client.api_bindings.models.examples_config import ExamplesConfig
|
|
23
|
+
from scope_client.api_bindings.models.keywords_config import KeywordsConfig
|
|
24
|
+
from scope_client.api_bindings.models.pii_config import PIIConfig
|
|
25
|
+
from scope_client.api_bindings.models.regex_config import RegexConfig
|
|
26
|
+
from scope_client.api_bindings.models.toxicity_config import ToxicityConfig
|
|
27
|
+
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
|
|
28
|
+
from typing_extensions import Literal, Self
|
|
29
|
+
from pydantic import Field
|
|
30
|
+
|
|
31
|
+
CONFIG1_ANY_OF_SCHEMAS = ["ExamplesConfig", "KeywordsConfig", "PIIConfig", "RegexConfig", "ToxicityConfig"]
|
|
32
|
+
|
|
33
|
+
class Config1(BaseModel):
|
|
34
|
+
"""
|
|
35
|
+
Config of the rule
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
# data type: KeywordsConfig
|
|
39
|
+
anyof_schema_1_validator: Optional[KeywordsConfig] = None
|
|
40
|
+
# data type: RegexConfig
|
|
41
|
+
anyof_schema_2_validator: Optional[RegexConfig] = None
|
|
42
|
+
# data type: ExamplesConfig
|
|
43
|
+
anyof_schema_3_validator: Optional[ExamplesConfig] = None
|
|
44
|
+
# data type: ToxicityConfig
|
|
45
|
+
anyof_schema_4_validator: Optional[ToxicityConfig] = None
|
|
46
|
+
# data type: PIIConfig
|
|
47
|
+
anyof_schema_5_validator: Optional[PIIConfig] = None
|
|
48
|
+
if TYPE_CHECKING:
|
|
49
|
+
actual_instance: Optional[Union[ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig]] = None
|
|
50
|
+
else:
|
|
51
|
+
actual_instance: Any = None
|
|
52
|
+
any_of_schemas: Set[str] = { "ExamplesConfig", "KeywordsConfig", "PIIConfig", "RegexConfig", "ToxicityConfig" }
|
|
53
|
+
|
|
54
|
+
model_config = {
|
|
55
|
+
"validate_assignment": True,
|
|
56
|
+
"protected_namespaces": (),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
60
|
+
if args:
|
|
61
|
+
if len(args) > 1:
|
|
62
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
63
|
+
if kwargs:
|
|
64
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
65
|
+
super().__init__(actual_instance=args[0])
|
|
66
|
+
else:
|
|
67
|
+
super().__init__(**kwargs)
|
|
68
|
+
|
|
69
|
+
@field_validator('actual_instance')
|
|
70
|
+
def actual_instance_must_validate_anyof(cls, v):
|
|
71
|
+
if v is None:
|
|
72
|
+
return v
|
|
73
|
+
|
|
74
|
+
instance = Config1.model_construct()
|
|
75
|
+
error_messages = []
|
|
76
|
+
# validate data type: KeywordsConfig
|
|
77
|
+
if not isinstance(v, KeywordsConfig):
|
|
78
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `KeywordsConfig`")
|
|
79
|
+
else:
|
|
80
|
+
return v
|
|
81
|
+
|
|
82
|
+
# validate data type: RegexConfig
|
|
83
|
+
if not isinstance(v, RegexConfig):
|
|
84
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `RegexConfig`")
|
|
85
|
+
else:
|
|
86
|
+
return v
|
|
87
|
+
|
|
88
|
+
# validate data type: ExamplesConfig
|
|
89
|
+
if not isinstance(v, ExamplesConfig):
|
|
90
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ExamplesConfig`")
|
|
91
|
+
else:
|
|
92
|
+
return v
|
|
93
|
+
|
|
94
|
+
# validate data type: ToxicityConfig
|
|
95
|
+
if not isinstance(v, ToxicityConfig):
|
|
96
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `ToxicityConfig`")
|
|
97
|
+
else:
|
|
98
|
+
return v
|
|
99
|
+
|
|
100
|
+
# validate data type: PIIConfig
|
|
101
|
+
if not isinstance(v, PIIConfig):
|
|
102
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `PIIConfig`")
|
|
103
|
+
else:
|
|
104
|
+
return v
|
|
105
|
+
|
|
106
|
+
if error_messages:
|
|
107
|
+
# no match
|
|
108
|
+
raise ValueError("No match found when setting the actual_instance in Config1 with anyOf schemas: ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig. Details: " + ", ".join(error_messages))
|
|
109
|
+
else:
|
|
110
|
+
return v
|
|
111
|
+
|
|
112
|
+
@classmethod
|
|
113
|
+
def from_dict(cls, obj: Dict[str, Any]) -> Self:
|
|
114
|
+
return cls.from_json(json.dumps(obj))
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def from_json(cls, json_str: str) -> Self:
|
|
118
|
+
"""Returns the object represented by the json string"""
|
|
119
|
+
instance = cls.model_construct()
|
|
120
|
+
if json_str is None:
|
|
121
|
+
return instance
|
|
122
|
+
|
|
123
|
+
error_messages = []
|
|
124
|
+
# anyof_schema_1_validator: Optional[KeywordsConfig] = None
|
|
125
|
+
try:
|
|
126
|
+
instance.actual_instance = KeywordsConfig.from_json(json_str)
|
|
127
|
+
return instance
|
|
128
|
+
except (ValidationError, ValueError) as e:
|
|
129
|
+
error_messages.append(str(e))
|
|
130
|
+
# anyof_schema_2_validator: Optional[RegexConfig] = None
|
|
131
|
+
try:
|
|
132
|
+
instance.actual_instance = RegexConfig.from_json(json_str)
|
|
133
|
+
return instance
|
|
134
|
+
except (ValidationError, ValueError) as e:
|
|
135
|
+
error_messages.append(str(e))
|
|
136
|
+
# anyof_schema_3_validator: Optional[ExamplesConfig] = None
|
|
137
|
+
try:
|
|
138
|
+
instance.actual_instance = ExamplesConfig.from_json(json_str)
|
|
139
|
+
return instance
|
|
140
|
+
except (ValidationError, ValueError) as e:
|
|
141
|
+
error_messages.append(str(e))
|
|
142
|
+
# anyof_schema_4_validator: Optional[ToxicityConfig] = None
|
|
143
|
+
try:
|
|
144
|
+
instance.actual_instance = ToxicityConfig.from_json(json_str)
|
|
145
|
+
return instance
|
|
146
|
+
except (ValidationError, ValueError) as e:
|
|
147
|
+
error_messages.append(str(e))
|
|
148
|
+
# anyof_schema_5_validator: Optional[PIIConfig] = None
|
|
149
|
+
try:
|
|
150
|
+
instance.actual_instance = PIIConfig.from_json(json_str)
|
|
151
|
+
return instance
|
|
152
|
+
except (ValidationError, ValueError) as e:
|
|
153
|
+
error_messages.append(str(e))
|
|
154
|
+
|
|
155
|
+
if error_messages:
|
|
156
|
+
# no match
|
|
157
|
+
raise ValueError("No match found when deserializing the JSON string into Config1 with anyOf schemas: ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig. Details: " + ", ".join(error_messages))
|
|
158
|
+
else:
|
|
159
|
+
return instance
|
|
160
|
+
|
|
161
|
+
def to_json(self) -> str:
|
|
162
|
+
"""Returns the JSON representation of the actual instance"""
|
|
163
|
+
if self.actual_instance is None:
|
|
164
|
+
return "null"
|
|
165
|
+
|
|
166
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
167
|
+
return self.actual_instance.to_json()
|
|
168
|
+
else:
|
|
169
|
+
return json.dumps(self.actual_instance)
|
|
170
|
+
|
|
171
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], ExamplesConfig, KeywordsConfig, PIIConfig, RegexConfig, ToxicityConfig]]:
|
|
172
|
+
"""Returns the dict representation of the actual instance"""
|
|
173
|
+
if self.actual_instance is None:
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
177
|
+
return self.actual_instance.to_dict()
|
|
178
|
+
else:
|
|
179
|
+
return self.actual_instance
|
|
180
|
+
|
|
181
|
+
def to_str(self) -> str:
|
|
182
|
+
"""Returns the string representation of the actual instance"""
|
|
183
|
+
return pprint.pformat(self.model_dump())
|
|
184
|
+
|
|
185
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Arthur Scope
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class ExampleConfig(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
ExampleConfig
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
example: StrictStr = Field(description="Custom example for the sensitive data")
|
|
30
|
+
result: StrictBool = Field(description="Boolean value representing if the example passes or fails the the sensitive data rule ")
|
|
31
|
+
__properties: ClassVar[List[str]] = ["example", "result"]
|
|
32
|
+
|
|
33
|
+
model_config = ConfigDict(
|
|
34
|
+
populate_by_name=True,
|
|
35
|
+
validate_assignment=True,
|
|
36
|
+
protected_namespaces=(),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def to_str(self) -> str:
|
|
41
|
+
"""Returns the string representation of the model using alias"""
|
|
42
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
43
|
+
|
|
44
|
+
def to_json(self) -> str:
|
|
45
|
+
"""Returns the JSON representation of the model using alias"""
|
|
46
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
47
|
+
return json.dumps(self.to_dict())
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
51
|
+
"""Create an instance of ExampleConfig from a JSON string"""
|
|
52
|
+
return cls.from_dict(json.loads(json_str))
|
|
53
|
+
|
|
54
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
55
|
+
"""Return the dictionary representation of the model using alias.
|
|
56
|
+
|
|
57
|
+
This has the following differences from calling pydantic's
|
|
58
|
+
`self.model_dump(by_alias=True)`:
|
|
59
|
+
|
|
60
|
+
* `None` is only added to the output dict for nullable fields that
|
|
61
|
+
were set at model initialization. Other fields with value `None`
|
|
62
|
+
are ignored.
|
|
63
|
+
"""
|
|
64
|
+
excluded_fields: Set[str] = set([
|
|
65
|
+
])
|
|
66
|
+
|
|
67
|
+
_dict = self.model_dump(
|
|
68
|
+
by_alias=True,
|
|
69
|
+
exclude=excluded_fields,
|
|
70
|
+
exclude_none=True,
|
|
71
|
+
)
|
|
72
|
+
return _dict
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
76
|
+
"""Create an instance of ExampleConfig from a dict"""
|
|
77
|
+
if obj is None:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
if not isinstance(obj, dict):
|
|
81
|
+
return cls.model_validate(obj)
|
|
82
|
+
|
|
83
|
+
_obj = cls.model_validate({
|
|
84
|
+
"example": obj.get("example"),
|
|
85
|
+
"result": obj.get("result")
|
|
86
|
+
})
|
|
87
|
+
return _obj
|
|
88
|
+
|
|
89
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Arthur Scope
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from scope_client.api_bindings.models.example_config import ExampleConfig
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class ExamplesConfig(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
ExamplesConfig
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
examples: List[ExampleConfig] = Field(description="List of all the examples for Sensitive Data Rule")
|
|
31
|
+
hint: Optional[StrictStr] = None
|
|
32
|
+
__properties: ClassVar[List[str]] = ["examples", "hint"]
|
|
33
|
+
|
|
34
|
+
model_config = ConfigDict(
|
|
35
|
+
populate_by_name=True,
|
|
36
|
+
validate_assignment=True,
|
|
37
|
+
protected_namespaces=(),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def to_str(self) -> str:
|
|
42
|
+
"""Returns the string representation of the model using alias"""
|
|
43
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> str:
|
|
46
|
+
"""Returns the JSON representation of the model using alias"""
|
|
47
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
48
|
+
return json.dumps(self.to_dict())
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
52
|
+
"""Create an instance of ExamplesConfig from a JSON string"""
|
|
53
|
+
return cls.from_dict(json.loads(json_str))
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
"""Return the dictionary representation of the model using alias.
|
|
57
|
+
|
|
58
|
+
This has the following differences from calling pydantic's
|
|
59
|
+
`self.model_dump(by_alias=True)`:
|
|
60
|
+
|
|
61
|
+
* `None` is only added to the output dict for nullable fields that
|
|
62
|
+
were set at model initialization. Other fields with value `None`
|
|
63
|
+
are ignored.
|
|
64
|
+
"""
|
|
65
|
+
excluded_fields: Set[str] = set([
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
_dict = self.model_dump(
|
|
69
|
+
by_alias=True,
|
|
70
|
+
exclude=excluded_fields,
|
|
71
|
+
exclude_none=True,
|
|
72
|
+
)
|
|
73
|
+
# override the default output from pydantic by calling `to_dict()` of each item in examples (list)
|
|
74
|
+
_items = []
|
|
75
|
+
if self.examples:
|
|
76
|
+
for _item_examples in self.examples:
|
|
77
|
+
if _item_examples:
|
|
78
|
+
_items.append(_item_examples.to_dict())
|
|
79
|
+
_dict['examples'] = _items
|
|
80
|
+
# set to None if hint (nullable) is None
|
|
81
|
+
# and model_fields_set contains the field
|
|
82
|
+
if self.hint is None and "hint" in self.model_fields_set:
|
|
83
|
+
_dict['hint'] = None
|
|
84
|
+
|
|
85
|
+
return _dict
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
89
|
+
"""Create an instance of ExamplesConfig from a dict"""
|
|
90
|
+
if obj is None:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
if not isinstance(obj, dict):
|
|
94
|
+
return cls.model_validate(obj)
|
|
95
|
+
|
|
96
|
+
_obj = cls.model_validate({
|
|
97
|
+
"examples": [ExampleConfig.from_dict(_item) for _item in obj["examples"]] if obj.get("examples") is not None else None,
|
|
98
|
+
"hint": obj.get("hint")
|
|
99
|
+
})
|
|
100
|
+
return _obj
|
|
101
|
+
|
|
102
|
+
|