logs-py 4.0.7__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.
Files changed (251) hide show
  1. LOGS/Auxiliary/CheckClassName.py +1075 -0
  2. LOGS/Auxiliary/Constants.py +99 -0
  3. LOGS/Auxiliary/CustomEntityClassGenerator.py +254 -0
  4. LOGS/Auxiliary/CustomFieldClassGenerator.py +115 -0
  5. LOGS/Auxiliary/CustomFieldValueTypeChecker.py +168 -0
  6. LOGS/Auxiliary/CustomSectionClassGenerator.py +113 -0
  7. LOGS/Auxiliary/CustomTypeClassGenerator.py +147 -0
  8. LOGS/Auxiliary/DateTimeConverter.py +66 -0
  9. LOGS/Auxiliary/Decorators.py +109 -0
  10. LOGS/Auxiliary/Exceptions.py +341 -0
  11. LOGS/Auxiliary/LOGSErrorResponse.py +89 -0
  12. LOGS/Auxiliary/MinimalModelGenerator.py +236 -0
  13. LOGS/Auxiliary/ParameterHelper.py +56 -0
  14. LOGS/Auxiliary/ReplaceMessage.py +13 -0
  15. LOGS/Auxiliary/Tools.py +432 -0
  16. LOGS/Auxiliary/__init__.py +15 -0
  17. LOGS/Converter/Conversion.py +248 -0
  18. LOGS/Converter/Converter.py +96 -0
  19. LOGS/Converter/ConverterParameter.py +88 -0
  20. LOGS/Converter/DateTimeRange.py +58 -0
  21. LOGS/Converter/ExportParameters.py +89 -0
  22. LOGS/Converter/__init__.py +13 -0
  23. LOGS/Entities/Attachment.py +84 -0
  24. LOGS/Entities/AttachmentMinimal.py +8 -0
  25. LOGS/Entities/AttachmentRequestParameter.py +42 -0
  26. LOGS/Entities/Attachments.py +53 -0
  27. LOGS/Entities/AutoloadFileInfo.py +12 -0
  28. LOGS/Entities/AutoloadStatusError.py +7 -0
  29. LOGS/Entities/AxisNaming.py +33 -0
  30. LOGS/Entities/AxisZoom.py +33 -0
  31. LOGS/Entities/Bridge.py +165 -0
  32. LOGS/Entities/BridgeClientInfo.py +93 -0
  33. LOGS/Entities/BridgeMinimal.py +8 -0
  34. LOGS/Entities/BridgeRequestParameter.py +49 -0
  35. LOGS/Entities/BridgeType.py +7 -0
  36. LOGS/Entities/Bridges.py +12 -0
  37. LOGS/Entities/CustomField.py +243 -0
  38. LOGS/Entities/CustomFieldMinimal.py +8 -0
  39. LOGS/Entities/CustomFieldModels.py +111 -0
  40. LOGS/Entities/CustomFieldRequestParameter.py +69 -0
  41. LOGS/Entities/CustomFieldSearchQuery.py +40 -0
  42. LOGS/Entities/CustomFields.py +12 -0
  43. LOGS/Entities/CustomType.py +212 -0
  44. LOGS/Entities/CustomTypeMinimal.py +8 -0
  45. LOGS/Entities/CustomTypeRequestParameter.py +60 -0
  46. LOGS/Entities/CustomTypeSection.py +63 -0
  47. LOGS/Entities/CustomTypes.py +12 -0
  48. LOGS/Entities/DataFormat.py +97 -0
  49. LOGS/Entities/DataFormatInstrument.py +18 -0
  50. LOGS/Entities/DataFormatInstrumentMinimal.py +8 -0
  51. LOGS/Entities/DataFormatInstrumentRequestParameter.py +17 -0
  52. LOGS/Entities/DataFormatInstruments.py +16 -0
  53. LOGS/Entities/DataFormatMinimal.py +18 -0
  54. LOGS/Entities/DataFormatRequestParameter.py +21 -0
  55. LOGS/Entities/DataFormats.py +12 -0
  56. LOGS/Entities/DataSource.py +218 -0
  57. LOGS/Entities/DataSourceConnectionStatus.py +12 -0
  58. LOGS/Entities/DataSourceMinimal.py +8 -0
  59. LOGS/Entities/DataSourceRequestParameter.py +57 -0
  60. LOGS/Entities/DataSourceStatus.py +108 -0
  61. LOGS/Entities/DataSourceStatusIterator.py +16 -0
  62. LOGS/Entities/DataSourceStatusRequestParameter.py +31 -0
  63. LOGS/Entities/DataSources.py +12 -0
  64. LOGS/Entities/Dataset.py +439 -0
  65. LOGS/Entities/DatasetBase.py +196 -0
  66. LOGS/Entities/DatasetCreator.py +148 -0
  67. LOGS/Entities/DatasetInfo.py +147 -0
  68. LOGS/Entities/DatasetMatchTypes.py +157 -0
  69. LOGS/Entities/DatasetMatching.py +196 -0
  70. LOGS/Entities/DatasetMinimal.py +8 -0
  71. LOGS/Entities/DatasetModels.py +33 -0
  72. LOGS/Entities/DatasetRequestParameter.py +92 -0
  73. LOGS/Entities/DatasetTemplate.py +23 -0
  74. LOGS/Entities/DatasetUploadParameter.py +14 -0
  75. LOGS/Entities/Datasets.py +142 -0
  76. LOGS/Entities/Datatrack.py +179 -0
  77. LOGS/Entities/DatatrackFormattedTable.py +25 -0
  78. LOGS/Entities/DatatrackGeneric.py +34 -0
  79. LOGS/Entities/DatatrackImage.py +25 -0
  80. LOGS/Entities/DatatrackNumericArray.py +30 -0
  81. LOGS/Entities/DatatrackNumericMatrix.py +98 -0
  82. LOGS/Entities/Entities.py +71 -0
  83. LOGS/Entities/EntitiesRequestParameter.py +18 -0
  84. LOGS/Entities/EntityOriginWriteModelWithId.py +15 -0
  85. LOGS/Entities/FileEntry.py +138 -0
  86. LOGS/Entities/FileExcludePattern.py +8 -0
  87. LOGS/Entities/FormatMetaData.py +56 -0
  88. LOGS/Entities/FormattedTable/DatatypeFormattedTable.py +135 -0
  89. LOGS/Entities/FormattedTable/DatatypeFormattedTableCell.py +108 -0
  90. LOGS/Entities/FormattedTable/DatatypeFormattedTableSettings.py +11 -0
  91. LOGS/Entities/FormattedTable/__init__.py +9 -0
  92. LOGS/Entities/HierarchyLeaf.py +15 -0
  93. LOGS/Entities/HierarchyNode.py +40 -0
  94. LOGS/Entities/ILiteraryTypedEntity.py +19 -0
  95. LOGS/Entities/InventoryItem.py +102 -0
  96. LOGS/Entities/InventoryItemMinimal.py +25 -0
  97. LOGS/Entities/InventoryItemRequestParameter.py +58 -0
  98. LOGS/Entities/InventoryItems.py +12 -0
  99. LOGS/Entities/LabNotebook.py +33 -0
  100. LOGS/Entities/LabNotebookEntries.py +16 -0
  101. LOGS/Entities/LabNotebookEntry.py +106 -0
  102. LOGS/Entities/LabNotebookEntryContent/BasicAttribute.py +15 -0
  103. LOGS/Entities/LabNotebookEntryContent/EntityAttribute.py +85 -0
  104. LOGS/Entities/LabNotebookEntryContent/EntryContentBlockquote.py +13 -0
  105. LOGS/Entities/LabNotebookEntryContent/EntryContentBulletList.py +17 -0
  106. LOGS/Entities/LabNotebookEntryContent/EntryContentCallout.py +40 -0
  107. LOGS/Entities/LabNotebookEntryContent/EntryContentContentPlaceholderNode.py +31 -0
  108. LOGS/Entities/LabNotebookEntryContent/EntryContentConverter.py +207 -0
  109. LOGS/Entities/LabNotebookEntryContent/EntryContentDocument.py +8 -0
  110. LOGS/Entities/LabNotebookEntryContent/EntryContentEntity.py +13 -0
  111. LOGS/Entities/LabNotebookEntryContent/EntryContentEntityMention.py +31 -0
  112. LOGS/Entities/LabNotebookEntryContent/EntryContentHeading.py +33 -0
  113. LOGS/Entities/LabNotebookEntryContent/EntryContentHorizontalRule.py +12 -0
  114. LOGS/Entities/LabNotebookEntryContent/EntryContentItem.py +37 -0
  115. LOGS/Entities/LabNotebookEntryContent/EntryContentListItem.py +49 -0
  116. LOGS/Entities/LabNotebookEntryContent/EntryContentOrderedList.py +31 -0
  117. LOGS/Entities/LabNotebookEntryContent/EntryContentParagraph.py +13 -0
  118. LOGS/Entities/LabNotebookEntryContent/EntryContentTable.py +17 -0
  119. LOGS/Entities/LabNotebookEntryContent/EntryContentTableCell.py +40 -0
  120. LOGS/Entities/LabNotebookEntryContent/EntryContentTableRow.py +8 -0
  121. LOGS/Entities/LabNotebookEntryContent/EntryContentTaskList.py +17 -0
  122. LOGS/Entities/LabNotebookEntryContent/EntryContentTaskListItem.py +31 -0
  123. LOGS/Entities/LabNotebookEntryContent/EntryContentText.py +33 -0
  124. LOGS/Entities/LabNotebookEntryContent/IEntryContentWithAttribute.py +23 -0
  125. LOGS/Entities/LabNotebookEntryContent/IEntryContentWithContent.py +38 -0
  126. LOGS/Entities/LabNotebookEntryContent/IEntryContentWithTextAttribute.py +16 -0
  127. LOGS/Entities/LabNotebookEntryContent/TextAttribute.py +46 -0
  128. LOGS/Entities/LabNotebookEntryContent/TextMarkAtributes.py +64 -0
  129. LOGS/Entities/LabNotebookEntryContent/TextMarkConverter.py +45 -0
  130. LOGS/Entities/LabNotebookEntryContent/TextMarks.py +71 -0
  131. LOGS/Entities/LabNotebookEntryContent/__init__.py +34 -0
  132. LOGS/Entities/LabNotebookEntryMinimal.py +8 -0
  133. LOGS/Entities/LabNotebookEntryRequestParameter.py +59 -0
  134. LOGS/Entities/LabNotebookExperiment.py +58 -0
  135. LOGS/Entities/LabNotebookExperimentMinimal.py +8 -0
  136. LOGS/Entities/LabNotebookExperimentRequestParameter.py +52 -0
  137. LOGS/Entities/LabNotebookExperiments.py +16 -0
  138. LOGS/Entities/LabNotebookMinimal.py +8 -0
  139. LOGS/Entities/LabNotebookModels.py +14 -0
  140. LOGS/Entities/LabNotebookRequestParameter.py +42 -0
  141. LOGS/Entities/LabNotebookTemplate.py +42 -0
  142. LOGS/Entities/LabNotebookTemplateMinimal.py +8 -0
  143. LOGS/Entities/LabNotebookTemplateRequestParameter.py +38 -0
  144. LOGS/Entities/LabNotebookTemplates.py +16 -0
  145. LOGS/Entities/LabNotebooks.py +12 -0
  146. LOGS/Entities/Method.py +66 -0
  147. LOGS/Entities/MethodMinimal.py +8 -0
  148. LOGS/Entities/MethodRequestParameter.py +16 -0
  149. LOGS/Entities/Methods.py +12 -0
  150. LOGS/Entities/Origin.py +53 -0
  151. LOGS/Entities/OriginMinimal.py +8 -0
  152. LOGS/Entities/OriginRequestParameter.py +28 -0
  153. LOGS/Entities/Origins.py +12 -0
  154. LOGS/Entities/ParserLog.py +49 -0
  155. LOGS/Entities/Permission.py +9 -0
  156. LOGS/Entities/Person.py +145 -0
  157. LOGS/Entities/PersonCategory.py +12 -0
  158. LOGS/Entities/PersonMinimal.py +8 -0
  159. LOGS/Entities/PersonRequestParameter.py +58 -0
  160. LOGS/Entities/Persons.py +12 -0
  161. LOGS/Entities/Project.py +52 -0
  162. LOGS/Entities/ProjectMinimal.py +8 -0
  163. LOGS/Entities/ProjectPersonPermission.py +102 -0
  164. LOGS/Entities/ProjectRequestParameter.py +58 -0
  165. LOGS/Entities/Projects.py +12 -0
  166. LOGS/Entities/Role.py +94 -0
  167. LOGS/Entities/RoleMinimal.py +8 -0
  168. LOGS/Entities/RoleRequestParameter.py +40 -0
  169. LOGS/Entities/Roles.py +12 -0
  170. LOGS/Entities/RunState.py +9 -0
  171. LOGS/Entities/Sample.py +53 -0
  172. LOGS/Entities/SampleMinimal.py +8 -0
  173. LOGS/Entities/SampleRequestParameter.py +54 -0
  174. LOGS/Entities/Samples.py +12 -0
  175. LOGS/Entities/SharedContent.py +87 -0
  176. LOGS/Entities/SharedContentMinimal.py +8 -0
  177. LOGS/Entities/SharedContentRequestParameter.py +38 -0
  178. LOGS/Entities/SharedContents.py +12 -0
  179. LOGS/Entities/Signature.py +60 -0
  180. LOGS/Entities/Track.py +93 -0
  181. LOGS/Entities/TrackData.py +20 -0
  182. LOGS/Entities/TrackImage.py +21 -0
  183. LOGS/Entities/TrackImageData.py +20 -0
  184. LOGS/Entities/TrackMatrix.py +28 -0
  185. LOGS/Entities/TrackMatrixData.py +22 -0
  186. LOGS/Entities/TrackSettings.py +55 -0
  187. LOGS/Entities/TrackTable.py +21 -0
  188. LOGS/Entities/TrackTableData.py +22 -0
  189. LOGS/Entities/TrackXY.py +40 -0
  190. LOGS/Entities/TrackXYComplex.py +51 -0
  191. LOGS/Entities/TrackXYComplexData.py +50 -0
  192. LOGS/Entities/TrackXYData.py +31 -0
  193. LOGS/Entities/Vendor.py +40 -0
  194. LOGS/Entities/VendorMinimal.py +8 -0
  195. LOGS/Entities/VendorRequestParameter.py +17 -0
  196. LOGS/Entities/Vendors.py +12 -0
  197. LOGS/Entities/__init__.py +118 -0
  198. LOGS/Entity/ConnectedEntity.py +170 -0
  199. LOGS/Entity/Entity.py +203 -0
  200. LOGS/Entity/EntityConnector.py +70 -0
  201. LOGS/Entity/EntityIterator.py +263 -0
  202. LOGS/Entity/EntityMinimal.py +141 -0
  203. LOGS/Entity/EntityMinimalWithIntId.py +36 -0
  204. LOGS/Entity/EntityMinimalWithStrId.py +36 -0
  205. LOGS/Entity/EntityMinimalWithType.py +47 -0
  206. LOGS/Entity/EntityRequestParameter.py +104 -0
  207. LOGS/Entity/EntitySortBy.py +69 -0
  208. LOGS/Entity/EntityWithIntId.py +26 -0
  209. LOGS/Entity/EntityWithStrId.py +26 -0
  210. LOGS/Entity/IGenericEntityOrderBy.py +55 -0
  211. LOGS/Entity/IdIterator.py +207 -0
  212. LOGS/Entity/SerializableContent.py +834 -0
  213. LOGS/Entity/__init__.py +23 -0
  214. LOGS/Interfaces/ICustomFieldValue.py +92 -0
  215. LOGS/Interfaces/ICustomSectionValue.py +161 -0
  216. LOGS/Interfaces/ICustomTypeValue.py +152 -0
  217. LOGS/Interfaces/ICustomValue.py +28 -0
  218. LOGS/Interfaces/IEntityInterface.py +7 -0
  219. LOGS/Interfaces/IEntryRecord.py +57 -0
  220. LOGS/Interfaces/IHierarchicalEntity.py +41 -0
  221. LOGS/Interfaces/IHierarchyType.py +63 -0
  222. LOGS/Interfaces/ILockableEntity.py +52 -0
  223. LOGS/Interfaces/IModificationRecord.py +56 -0
  224. LOGS/Interfaces/INamedEntity.py +25 -0
  225. LOGS/Interfaces/IOwnedEntity.py +27 -0
  226. LOGS/Interfaces/IPaginationRequest.py +11 -0
  227. LOGS/Interfaces/IPermissionedEntity.py +72 -0
  228. LOGS/Interfaces/IProjectBased.py +27 -0
  229. LOGS/Interfaces/ISessionedEntity.py +59 -0
  230. LOGS/Interfaces/ISignableEntity.py +49 -0
  231. LOGS/Interfaces/ISoftDeletable.py +28 -0
  232. LOGS/Interfaces/ITypedEntity.py +129 -0
  233. LOGS/Interfaces/IUniqueEntity.py +61 -0
  234. LOGS/Interfaces/IVersionedEntity.py +39 -0
  235. LOGS/Interfaces/__init__.py +7 -0
  236. LOGS/LOGS.py +1436 -0
  237. LOGS/LOGSConnection.py +647 -0
  238. LOGS/LOGSOptions.py +11 -0
  239. LOGS/Parameters/Color.py +92 -0
  240. LOGS/Parameters/ParameterBase.py +55 -0
  241. LOGS/Parameters/ParameterConverter.py +24 -0
  242. LOGS/Parameters/ParameterElement.py +99 -0
  243. LOGS/Parameters/ParameterList.py +52 -0
  244. LOGS/Parameters/ParameterTable.py +64 -0
  245. LOGS/Parameters/__init__.py +13 -0
  246. LOGS/ServerMetaData.py +120 -0
  247. LOGS/__init__.py +12 -0
  248. logs_py-4.0.7.dist-info/METADATA +51 -0
  249. logs_py-4.0.7.dist-info/RECORD +251 -0
  250. logs_py-4.0.7.dist-info/WHEEL +5 -0
  251. logs_py-4.0.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,118 @@
1
+ """
2
+ This package is written for the LOGS Repository.
3
+
4
+ It's objects can be used to write your own dataset parser.
5
+
6
+ License:
7
+ Permission to use this library and all of its contents is
8
+ strictly permitted to the Signals Company.
9
+ """
10
+
11
+ from .Attachment import *
12
+ from .AttachmentRequestParameter import *
13
+ from .Attachments import *
14
+ from .AxisNaming import *
15
+ from .Bridge import *
16
+ from .BridgeClientInfo import *
17
+ from .BridgeMinimal import *
18
+ from .BridgeRequestParameter import *
19
+ from .BridgeType import *
20
+ from .CustomField import *
21
+ from .CustomFieldModels import *
22
+ from .CustomFieldRequestParameter import *
23
+ from .CustomType import *
24
+ from .CustomTypeMinimal import *
25
+ from .CustomTypeRequestParameter import *
26
+ from .DataFormat import *
27
+ from .DataFormatInstrumentMinimal import *
28
+ from .DataFormatInstrumentRequestParameter import *
29
+ from .DataFormatMinimal import *
30
+ from .DataFormatRequestParameter import *
31
+ from .Dataset import *
32
+ from .DatasetCreator import *
33
+ from .DatasetInfo import *
34
+ from .DatasetMatching import *
35
+ from .DatasetMatchTypes import *
36
+ from .DatasetMinimal import *
37
+ from .DatasetRequestParameter import *
38
+ from .Datasets import *
39
+ from .DatasetUploadParameter import *
40
+ from .DataSource import *
41
+ from .DataSourceMinimal import *
42
+ from .DataSourceRequestParameter import *
43
+ from .DataSourceStatus import *
44
+ from .DataSourceStatusIterator import *
45
+ from .DataSourceStatusRequestParameter import *
46
+ from .Datatrack import *
47
+ from .DatatrackFormattedTable import *
48
+ from .DatatrackImage import *
49
+ from .DatatrackNumericArray import *
50
+ from .DatatrackNumericMatrix import *
51
+ from .Entities import *
52
+ from .EntitiesRequestParameter import *
53
+ from .EntityOriginWriteModelWithId import *
54
+ from .FileEntry import *
55
+ from .HierarchyLeaf import *
56
+ from .HierarchyNode import *
57
+ from .InventoryItem import *
58
+ from .InventoryItemMinimal import *
59
+ from .InventoryItemRequestParameter import *
60
+ from .LabNotebook import *
61
+ from .LabNotebookEntries import *
62
+ from .LabNotebookEntryContent import *
63
+ from .LabNotebookEntryMinimal import *
64
+ from .LabNotebookEntryRequestParameter import *
65
+ from .LabNotebookExperiment import *
66
+ from .LabNotebookExperimentMinimal import *
67
+ from .LabNotebookExperimentRequestParameter import *
68
+ from .LabNotebookExperiments import *
69
+ from .LabNotebookMinimal import *
70
+ from .LabNotebookModels import *
71
+ from .LabNotebookRequestParameter import *
72
+ from .LabNotebooks import *
73
+ from .LabNotebookTemplate import *
74
+ from .LabNotebookTemplateMinimal import *
75
+ from .LabNotebookTemplateRequestParameter import *
76
+ from .LabNotebookTemplates import *
77
+ from .Method import *
78
+ from .MethodMinimal import *
79
+ from .MethodRequestParameter import *
80
+ from .Origin import *
81
+ from .OriginMinimal import *
82
+ from .OriginRequestParameter import *
83
+ from .Origins import *
84
+ from .ParserLog import *
85
+ from .Person import *
86
+ from .PersonCategory import *
87
+ from .PersonMinimal import *
88
+ from .PersonRequestParameter import *
89
+ from .Persons import *
90
+ from .Project import *
91
+ from .ProjectMinimal import *
92
+ from .ProjectPersonPermission import *
93
+ from .ProjectRequestParameter import *
94
+ from .Projects import *
95
+ from .Role import *
96
+ from .RoleRequestParameter import *
97
+ from .Sample import *
98
+ from .SampleMinimal import *
99
+ from .SampleRequestParameter import *
100
+ from .Samples import *
101
+ from .SharedContent import *
102
+ from .SharedContentRequestParameter import *
103
+ from .SharedContents import *
104
+ from .Track import *
105
+ from .TrackData import *
106
+ from .TrackImage import *
107
+ from .TrackImageData import *
108
+ from .TrackMatrix import *
109
+ from .TrackMatrixData import *
110
+ from .TrackSettings import *
111
+ from .TrackXY import *
112
+ from .TrackXYComplex import *
113
+ from .TrackXYComplexData import *
114
+ from .TrackXYData import *
115
+ from .Vendor import *
116
+ from .VendorMinimal import *
117
+ from .VendorRequestParameter import *
118
+ from .Vendors import *
@@ -0,0 +1,170 @@
1
+ import inspect
2
+ from typing import Any, Callable, List, Optional, Type, TypeVar, Union, cast
3
+
4
+ from LOGS.Auxiliary.Exceptions import EntityNotConnectedException
5
+ from LOGS.Auxiliary.Tools import Tools
6
+ from LOGS.Entity.SerializableContent import SerializableContent
7
+ from LOGS.LOGSConnection import LOGSConnection
8
+
9
+ _T = TypeVar("_T")
10
+
11
+
12
+ class ConnectedEntity(SerializableContent):
13
+ _connection: Optional[LOGSConnection] = None
14
+ _endpoint: Optional[List[str]] = None
15
+ _uiEndpoint: Optional[List[str]] = None
16
+ _noSerialize = ["connection", "cachePath", "cacheId", "cacheDir"]
17
+ _cacheDir: Optional[str] = None
18
+ _cacheId: str = cast(str, None)
19
+
20
+ def __init__(self, ref=None, connection: Optional[LOGSConnection] = None):
21
+ self._connection = connection
22
+
23
+ if not self._uiEndpoint and self._endpoint and len(self._endpoint) == 1:
24
+ self._uiEndpoint = ["#" + self._endpoint[0]]
25
+
26
+ super().__init__(ref=ref)
27
+
28
+ def _getConnection(self):
29
+ if not self._connection:
30
+ raise EntityNotConnectedException(self)
31
+ return self._connection
32
+
33
+ def _getConnectionData(self):
34
+ if not self._endpoint:
35
+ raise NotImplementedError(
36
+ "Endpoint missing for of entity type %a."
37
+ % (
38
+ type(self).__name__
39
+ if type(self).__name__ != ConnectedEntity.__name__
40
+ else "unknown"
41
+ )
42
+ )
43
+
44
+ return self._getConnection(), self._endpoint
45
+
46
+ def _setConnection(self, value):
47
+ self._connection = Tools.checkAndConvert(
48
+ value, LOGSConnection, "connection", allowNone=True
49
+ )
50
+ for k in self.__dict__:
51
+ a = getattr(self, k)
52
+ if issubclass(type(a), ConnectedEntity):
53
+ cast(ConnectedEntity, a)._setConnection(self._connection)
54
+
55
+ def clearCache(self):
56
+ raise NotImplementedError(
57
+ "Clearing cache of %a class is not implemented." % type(self).__name__
58
+ )
59
+
60
+ @classmethod
61
+ def checkAndConvertWithConnection(
62
+ cls,
63
+ value: Any,
64
+ fieldType: Type[_T],
65
+ fieldName: Optional[str] = None,
66
+ converter: Optional[Callable[[Any], _T]] = None,
67
+ allowNone=False,
68
+ connection: Optional[LOGSConnection] = None,
69
+ ) -> _T:
70
+ if (
71
+ inspect.isclass(fieldType)
72
+ and issubclass(fieldType, ConnectedEntity)
73
+ and isinstance(value, dict)
74
+ ):
75
+ return cast(Any, fieldType)(ref=value, connection=connection)
76
+
77
+ return Tools.checkAndConvert(value, fieldType, fieldName, converter, allowNone)
78
+
79
+ @classmethod
80
+ def checkListAndConvertWithConnection(
81
+ cls,
82
+ value: Any,
83
+ fieldType: Type[_T],
84
+ fieldName: Optional[str] = None,
85
+ converter: Optional[Callable[[Any], _T]] = None,
86
+ allowNone: bool = False,
87
+ connection: Optional[LOGSConnection] = None,
88
+ ) -> List[_T]:
89
+ if isinstance(value, (list, tuple)):
90
+ value = [
91
+ cls.checkAndConvertWithConnection(
92
+ v, fieldType, fieldName, converter, allowNone, connection
93
+ )
94
+ for v in value
95
+ ]
96
+
97
+ return Tools.checkListAndConvert(
98
+ value=value,
99
+ fieldType=fieldType,
100
+ fieldName=fieldName,
101
+ converter=converter,
102
+ allowNone=allowNone,
103
+ )
104
+
105
+ def checkAndConvert(
106
+ self,
107
+ value: Any,
108
+ fieldType: Union[Type[_T], List[Type[_T]]],
109
+ fieldName: Optional[str] = None,
110
+ converter: Optional[Callable[[Any], _T]] = None,
111
+ allowNone=False,
112
+ ) -> _T:
113
+ if (
114
+ inspect.isclass(fieldType)
115
+ and issubclass(fieldType, ConnectedEntity)
116
+ and isinstance(value, dict)
117
+ ):
118
+ return cast(Any, fieldType)(ref=value, connection=self._connection)
119
+
120
+ return super().checkAndConvert(
121
+ value, fieldType, fieldName, converter, allowNone
122
+ )
123
+
124
+ def checkListAndConvert(
125
+ self,
126
+ value: Any,
127
+ fieldType: Type[_T],
128
+ fieldName: Optional[str] = None,
129
+ converter: Optional[Callable[[Any], _T]] = None,
130
+ allowNone: bool = False,
131
+ singleToList: bool = False,
132
+ length: int = -1,
133
+ ) -> List[_T]:
134
+ if isinstance(value, (list, tuple)):
135
+ value = [
136
+ self.checkAndConvert(v, fieldType, fieldName, converter, allowNone)
137
+ for v in value
138
+ ]
139
+
140
+ return super().checkListAndConvert(
141
+ value=value,
142
+ fieldType=fieldType,
143
+ fieldName=fieldName,
144
+ converter=converter,
145
+ allowNone=allowNone,
146
+ singleToList=singleToList,
147
+ length=length,
148
+ )
149
+
150
+ @property
151
+ def identifier(self):
152
+ return "%s" % (type(self).__name__)
153
+
154
+ @property
155
+ def cacheDir(self) -> Optional[str]:
156
+ return self._cacheDir
157
+
158
+ @cacheDir.setter
159
+ def cacheDir(self, value):
160
+ self._cacheDir = Tools.checkAndConvert(value, str, "cacheDir", allowNone=True)
161
+
162
+ @property
163
+ def cacheId(self) -> str:
164
+ if self._cacheId is None:
165
+ if not hasattr(self, "id"):
166
+ setattr(self, "id", Tools.generateRandomString())
167
+
168
+ return f"{type(self).__name__}_{str(getattr(self, 'id'))}"
169
+ else:
170
+ return self._cacheId
LOGS/Entity/Entity.py ADDED
@@ -0,0 +1,203 @@
1
+ from typing import Any, Optional, cast
2
+
3
+ from LOGS.Auxiliary import MinimalModelGenerator, Tools
4
+ from LOGS.Auxiliary.Constants import Constants
5
+ from LOGS.Auxiliary.Exceptions import (
6
+ EntityDeletingException,
7
+ EntityFetchingException,
8
+ EntityNotFoundException,
9
+ EntityUpdatingException,
10
+ )
11
+ from LOGS.Entity.ConnectedEntity import ConnectedEntity
12
+ from LOGS.Entity.EntityRequestParameter import EntityRequestParameter
13
+ from LOGS.LOGSConnection import LOGSConnection
14
+
15
+ # SELF = TypeVar("SELF", bound="Entity")
16
+
17
+
18
+ class Entity(ConnectedEntity):
19
+ _id: Constants.ID_TYPE
20
+ _defaultRequestParameter: dict = EntityRequestParameter().toDict()
21
+
22
+ def __init__(
23
+ self,
24
+ ref=None,
25
+ id: Optional[Constants.ID_TYPE] = None,
26
+ connection: Optional[LOGSConnection] = None,
27
+ ):
28
+ """Represents a connected LOGS entity type"""
29
+ if id:
30
+ self._id = id
31
+
32
+ super().__init__(ref=ref, connection=connection)
33
+
34
+ def _getConnectionData(self):
35
+ (connection, endpoint) = super()._getConnectionData()
36
+
37
+ if not self.id:
38
+ raise EntityNotFoundException(self)
39
+
40
+ return connection, endpoint, self.id
41
+
42
+ def __str__(self):
43
+ return Tools.ObjectToString(self)
44
+
45
+ def getUIUrl(self) -> str:
46
+ uiEndpoint = self._uiEndpoint
47
+ if not uiEndpoint:
48
+ raise NotImplementedError(
49
+ "No UI endpoint specified for entity type %a."
50
+ % (
51
+ type(self).__name__
52
+ if type(self).__name__ != Entity.__name__
53
+ else "unknown"
54
+ )
55
+ )
56
+ connection = self._getConnection()
57
+
58
+ return connection.getUIEndpointUrl(uiEndpoint + [str(self.id)])
59
+
60
+ def _fetchEntity(self, connection: LOGSConnection):
61
+ if not self._endpoint:
62
+ raise NotImplementedError(
63
+ "Fetching of entity type %a is not implemented."
64
+ % (
65
+ type(self).__name__
66
+ if type(self).__name__ != Entity.__name__
67
+ else "unknown"
68
+ )
69
+ )
70
+
71
+ ref, responseError = connection.getEndpoint(
72
+ cast(Any, self._endpoint + [str(self.id)]), self._defaultRequestParameter
73
+ )
74
+ if responseError:
75
+ raise EntityFetchingException(entity=self, responseError=responseError)
76
+
77
+ if isinstance(ref, dict) and "url" in ref:
78
+ del ref["url"]
79
+ self._fromRef(ref, type(self))
80
+ self._setConnection(connection)
81
+
82
+ def fetch(self):
83
+ self._fetchEntity(self._getConnection())
84
+
85
+ def _restoreEntity(self, connection: LOGSConnection):
86
+ if not self._endpoint:
87
+ raise NotImplementedError(
88
+ "Updating of entity type %a is not implemented."
89
+ % (
90
+ type(self).__name__
91
+ if type(self).__name__ != Entity.__name__
92
+ else "unknown"
93
+ )
94
+ )
95
+
96
+ if not self.id:
97
+ raise EntityNotFoundException(self)
98
+
99
+ data, responseError = connection.postEndpoint(
100
+ self._endpoint + ["restore", self.id], data=self.toDict()
101
+ )
102
+ if responseError:
103
+ raise EntityUpdatingException(entity=self, responseError=responseError)
104
+
105
+ self.override(data)
106
+
107
+ def _updateEntity(self, connection: LOGSConnection):
108
+ if not self._endpoint:
109
+ raise NotImplementedError(
110
+ "Updating of entity type %a is not implemented."
111
+ % (
112
+ type(self).__name__
113
+ if type(self).__name__ != Entity.__name__
114
+ else "unknown"
115
+ )
116
+ )
117
+
118
+ if not self.id:
119
+ raise EntityNotFoundException(self)
120
+
121
+ data, responseError = connection.putEndpoint(
122
+ self._endpoint + [self.id], data=self.toDict()
123
+ )
124
+ if responseError:
125
+ raise EntityUpdatingException(entity=self, responseError=responseError)
126
+
127
+ self.override(data)
128
+
129
+ def _deleteEntity(self, connection: LOGSConnection, permanently: bool = False):
130
+ if not self._endpoint:
131
+ raise NotImplementedError(
132
+ "Deleting of entity type %a is not implemented."
133
+ % (
134
+ type(self).__name__
135
+ if type(self).__name__ != Entity.__name__
136
+ else "unknown"
137
+ )
138
+ )
139
+
140
+ if not self.id:
141
+ raise EntityNotFoundException(self)
142
+
143
+ _, responseError = connection.deleteEndpoint(
144
+ self._endpoint + [self.id], parameters={"deletePermanently": permanently}
145
+ )
146
+ if hasattr(self, "isDeleted"):
147
+ setattr(self, "isDeleted", True)
148
+
149
+ if permanently:
150
+ self._connection = None
151
+
152
+ if responseError:
153
+ if [
154
+ e
155
+ for e in responseError.errorStringList
156
+ if "Soft-Delete is not supported" in e
157
+ ]:
158
+ raise EntityDeletingException(
159
+ entityIds=self.id,
160
+ errors=[
161
+ "This entity cannot be trashed.",
162
+ "Please use 'permanently = true' parameter.",
163
+ ],
164
+ )
165
+ else:
166
+ raise EntityDeletingException(
167
+ entityIds=self.id, responseError=responseError
168
+ )
169
+
170
+ def update(self):
171
+ self._updateEntity(self._getConnection())
172
+
173
+ def restore(self):
174
+ self._restoreEntity(self._getConnection())
175
+
176
+ def delete(self, permanently: bool = False):
177
+ self._deleteEntity(self._getConnection(), permanently=permanently)
178
+
179
+ def toMinimal(self):
180
+ return MinimalModelGenerator.MinimalFromSingle(
181
+ self.toDict(), type(self).__name__, None, self._getConnection()
182
+ )
183
+
184
+ @property
185
+ def identifier(self):
186
+ name = (
187
+ f" '{getattr(self, 'name')}'"
188
+ if hasattr(self, "name") and getattr(self, "name")
189
+ else ""
190
+ )
191
+ return "%s(id:%s)%s" % (
192
+ type(self).__name__,
193
+ str(self.id),
194
+ name,
195
+ )
196
+
197
+ @property
198
+ def id(self):
199
+ return self._id
200
+
201
+ @id.setter
202
+ def id(self, value):
203
+ self._id = value
@@ -0,0 +1,70 @@
1
+ from typing import Generic, List, Optional, TypeVar
2
+
3
+ from LOGS.Auxiliary.Exceptions import NotConnectedException
4
+ from LOGS.Auxiliary.Tools import Tools
5
+ from LOGS.Entity.Entity import Entity
6
+ from LOGS.Entity.SerializableContent import SerializableContent
7
+ from LOGS.LOGSConnection import LOGSConnection, ResponseTypes
8
+
9
+ # SELF = TypeVar("SELF", bound="EntityConnector")
10
+
11
+ _T = TypeVar("_T", bound=Entity)
12
+
13
+
14
+ class EntityConnector(Generic[_T]):
15
+ """Represents a connected LOGS entity iterator"""
16
+
17
+ _endpoint: Optional[List[str]] = None
18
+ _firstUrl: Optional[str] = None
19
+
20
+ _parameters: SerializableContent
21
+ _responseType: ResponseTypes = ResponseTypes.JSON
22
+ _includeUrl: bool = True
23
+ _connection: Optional[LOGSConnection] = None
24
+
25
+ def __init__(self, connection: Optional[LOGSConnection]):
26
+ self._connection = connection
27
+
28
+ def _getConnection(self):
29
+ if not self._connection:
30
+ raise NotConnectedException(
31
+ "%s iterator not connected." % type(self).__name__
32
+ )
33
+ return self._connection
34
+
35
+ def _getConnectionData(self):
36
+ if not self._endpoint:
37
+ raise NotImplementedError(
38
+ "Endpoint missing for %s iterator." % (type(self).__name__.lower())
39
+ )
40
+
41
+ return self._getConnection(), self._endpoint
42
+
43
+ def __str__(self):
44
+ s = ""
45
+ if self._endpoint:
46
+ s = "/" + "/".join(self._endpoint)
47
+ return "<%s %a>" % (type(self).__name__, s)
48
+
49
+ def getBaseUrl(self):
50
+ return (
51
+ self._firstUrl
52
+ if self._firstUrl
53
+ else (
54
+ self._connection.getEndpointUrl(
55
+ endpoint=self._endpoint if self._endpoint else ""
56
+ )
57
+ if self._connection
58
+ else ""
59
+ )
60
+ )
61
+
62
+ @property
63
+ def connection(self) -> Optional[LOGSConnection]:
64
+ return self._connection
65
+
66
+ @connection.setter
67
+ def connection(self, value):
68
+ self._connection = Tools.checkAndConvert(
69
+ value, LOGSConnection, "connection", allowNone=True
70
+ )