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.
- LOGS/Auxiliary/CheckClassName.py +1075 -0
- LOGS/Auxiliary/Constants.py +99 -0
- LOGS/Auxiliary/CustomEntityClassGenerator.py +254 -0
- LOGS/Auxiliary/CustomFieldClassGenerator.py +115 -0
- LOGS/Auxiliary/CustomFieldValueTypeChecker.py +168 -0
- LOGS/Auxiliary/CustomSectionClassGenerator.py +113 -0
- LOGS/Auxiliary/CustomTypeClassGenerator.py +147 -0
- LOGS/Auxiliary/DateTimeConverter.py +66 -0
- LOGS/Auxiliary/Decorators.py +109 -0
- LOGS/Auxiliary/Exceptions.py +341 -0
- LOGS/Auxiliary/LOGSErrorResponse.py +89 -0
- LOGS/Auxiliary/MinimalModelGenerator.py +236 -0
- LOGS/Auxiliary/ParameterHelper.py +56 -0
- LOGS/Auxiliary/ReplaceMessage.py +13 -0
- LOGS/Auxiliary/Tools.py +432 -0
- LOGS/Auxiliary/__init__.py +15 -0
- LOGS/Converter/Conversion.py +248 -0
- LOGS/Converter/Converter.py +96 -0
- LOGS/Converter/ConverterParameter.py +88 -0
- LOGS/Converter/DateTimeRange.py +58 -0
- LOGS/Converter/ExportParameters.py +89 -0
- LOGS/Converter/__init__.py +13 -0
- LOGS/Entities/Attachment.py +84 -0
- LOGS/Entities/AttachmentMinimal.py +8 -0
- LOGS/Entities/AttachmentRequestParameter.py +42 -0
- LOGS/Entities/Attachments.py +53 -0
- LOGS/Entities/AutoloadFileInfo.py +12 -0
- LOGS/Entities/AutoloadStatusError.py +7 -0
- LOGS/Entities/AxisNaming.py +33 -0
- LOGS/Entities/AxisZoom.py +33 -0
- LOGS/Entities/Bridge.py +165 -0
- LOGS/Entities/BridgeClientInfo.py +93 -0
- LOGS/Entities/BridgeMinimal.py +8 -0
- LOGS/Entities/BridgeRequestParameter.py +49 -0
- LOGS/Entities/BridgeType.py +7 -0
- LOGS/Entities/Bridges.py +12 -0
- LOGS/Entities/CustomField.py +243 -0
- LOGS/Entities/CustomFieldMinimal.py +8 -0
- LOGS/Entities/CustomFieldModels.py +111 -0
- LOGS/Entities/CustomFieldRequestParameter.py +69 -0
- LOGS/Entities/CustomFieldSearchQuery.py +40 -0
- LOGS/Entities/CustomFields.py +12 -0
- LOGS/Entities/CustomType.py +212 -0
- LOGS/Entities/CustomTypeMinimal.py +8 -0
- LOGS/Entities/CustomTypeRequestParameter.py +60 -0
- LOGS/Entities/CustomTypeSection.py +63 -0
- LOGS/Entities/CustomTypes.py +12 -0
- LOGS/Entities/DataFormat.py +97 -0
- LOGS/Entities/DataFormatInstrument.py +18 -0
- LOGS/Entities/DataFormatInstrumentMinimal.py +8 -0
- LOGS/Entities/DataFormatInstrumentRequestParameter.py +17 -0
- LOGS/Entities/DataFormatInstruments.py +16 -0
- LOGS/Entities/DataFormatMinimal.py +18 -0
- LOGS/Entities/DataFormatRequestParameter.py +21 -0
- LOGS/Entities/DataFormats.py +12 -0
- LOGS/Entities/DataSource.py +218 -0
- LOGS/Entities/DataSourceConnectionStatus.py +12 -0
- LOGS/Entities/DataSourceMinimal.py +8 -0
- LOGS/Entities/DataSourceRequestParameter.py +57 -0
- LOGS/Entities/DataSourceStatus.py +108 -0
- LOGS/Entities/DataSourceStatusIterator.py +16 -0
- LOGS/Entities/DataSourceStatusRequestParameter.py +31 -0
- LOGS/Entities/DataSources.py +12 -0
- LOGS/Entities/Dataset.py +439 -0
- LOGS/Entities/DatasetBase.py +196 -0
- LOGS/Entities/DatasetCreator.py +148 -0
- LOGS/Entities/DatasetInfo.py +147 -0
- LOGS/Entities/DatasetMatchTypes.py +157 -0
- LOGS/Entities/DatasetMatching.py +196 -0
- LOGS/Entities/DatasetMinimal.py +8 -0
- LOGS/Entities/DatasetModels.py +33 -0
- LOGS/Entities/DatasetRequestParameter.py +92 -0
- LOGS/Entities/DatasetTemplate.py +23 -0
- LOGS/Entities/DatasetUploadParameter.py +14 -0
- LOGS/Entities/Datasets.py +142 -0
- LOGS/Entities/Datatrack.py +179 -0
- LOGS/Entities/DatatrackFormattedTable.py +25 -0
- LOGS/Entities/DatatrackGeneric.py +34 -0
- LOGS/Entities/DatatrackImage.py +25 -0
- LOGS/Entities/DatatrackNumericArray.py +30 -0
- LOGS/Entities/DatatrackNumericMatrix.py +98 -0
- LOGS/Entities/Entities.py +71 -0
- LOGS/Entities/EntitiesRequestParameter.py +18 -0
- LOGS/Entities/EntityOriginWriteModelWithId.py +15 -0
- LOGS/Entities/FileEntry.py +138 -0
- LOGS/Entities/FileExcludePattern.py +8 -0
- LOGS/Entities/FormatMetaData.py +56 -0
- LOGS/Entities/FormattedTable/DatatypeFormattedTable.py +135 -0
- LOGS/Entities/FormattedTable/DatatypeFormattedTableCell.py +108 -0
- LOGS/Entities/FormattedTable/DatatypeFormattedTableSettings.py +11 -0
- LOGS/Entities/FormattedTable/__init__.py +9 -0
- LOGS/Entities/HierarchyLeaf.py +15 -0
- LOGS/Entities/HierarchyNode.py +40 -0
- LOGS/Entities/ILiteraryTypedEntity.py +19 -0
- LOGS/Entities/InventoryItem.py +102 -0
- LOGS/Entities/InventoryItemMinimal.py +25 -0
- LOGS/Entities/InventoryItemRequestParameter.py +58 -0
- LOGS/Entities/InventoryItems.py +12 -0
- LOGS/Entities/LabNotebook.py +33 -0
- LOGS/Entities/LabNotebookEntries.py +16 -0
- LOGS/Entities/LabNotebookEntry.py +106 -0
- LOGS/Entities/LabNotebookEntryContent/BasicAttribute.py +15 -0
- LOGS/Entities/LabNotebookEntryContent/EntityAttribute.py +85 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentBlockquote.py +13 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentBulletList.py +17 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentCallout.py +40 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentContentPlaceholderNode.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentConverter.py +207 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentDocument.py +8 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentEntity.py +13 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentEntityMention.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentHeading.py +33 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentHorizontalRule.py +12 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentItem.py +37 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentListItem.py +49 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentOrderedList.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentParagraph.py +13 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTable.py +17 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTableCell.py +40 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTableRow.py +8 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTaskList.py +17 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTaskListItem.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentText.py +33 -0
- LOGS/Entities/LabNotebookEntryContent/IEntryContentWithAttribute.py +23 -0
- LOGS/Entities/LabNotebookEntryContent/IEntryContentWithContent.py +38 -0
- LOGS/Entities/LabNotebookEntryContent/IEntryContentWithTextAttribute.py +16 -0
- LOGS/Entities/LabNotebookEntryContent/TextAttribute.py +46 -0
- LOGS/Entities/LabNotebookEntryContent/TextMarkAtributes.py +64 -0
- LOGS/Entities/LabNotebookEntryContent/TextMarkConverter.py +45 -0
- LOGS/Entities/LabNotebookEntryContent/TextMarks.py +71 -0
- LOGS/Entities/LabNotebookEntryContent/__init__.py +34 -0
- LOGS/Entities/LabNotebookEntryMinimal.py +8 -0
- LOGS/Entities/LabNotebookEntryRequestParameter.py +59 -0
- LOGS/Entities/LabNotebookExperiment.py +58 -0
- LOGS/Entities/LabNotebookExperimentMinimal.py +8 -0
- LOGS/Entities/LabNotebookExperimentRequestParameter.py +52 -0
- LOGS/Entities/LabNotebookExperiments.py +16 -0
- LOGS/Entities/LabNotebookMinimal.py +8 -0
- LOGS/Entities/LabNotebookModels.py +14 -0
- LOGS/Entities/LabNotebookRequestParameter.py +42 -0
- LOGS/Entities/LabNotebookTemplate.py +42 -0
- LOGS/Entities/LabNotebookTemplateMinimal.py +8 -0
- LOGS/Entities/LabNotebookTemplateRequestParameter.py +38 -0
- LOGS/Entities/LabNotebookTemplates.py +16 -0
- LOGS/Entities/LabNotebooks.py +12 -0
- LOGS/Entities/Method.py +66 -0
- LOGS/Entities/MethodMinimal.py +8 -0
- LOGS/Entities/MethodRequestParameter.py +16 -0
- LOGS/Entities/Methods.py +12 -0
- LOGS/Entities/Origin.py +53 -0
- LOGS/Entities/OriginMinimal.py +8 -0
- LOGS/Entities/OriginRequestParameter.py +28 -0
- LOGS/Entities/Origins.py +12 -0
- LOGS/Entities/ParserLog.py +49 -0
- LOGS/Entities/Permission.py +9 -0
- LOGS/Entities/Person.py +145 -0
- LOGS/Entities/PersonCategory.py +12 -0
- LOGS/Entities/PersonMinimal.py +8 -0
- LOGS/Entities/PersonRequestParameter.py +58 -0
- LOGS/Entities/Persons.py +12 -0
- LOGS/Entities/Project.py +52 -0
- LOGS/Entities/ProjectMinimal.py +8 -0
- LOGS/Entities/ProjectPersonPermission.py +102 -0
- LOGS/Entities/ProjectRequestParameter.py +58 -0
- LOGS/Entities/Projects.py +12 -0
- LOGS/Entities/Role.py +94 -0
- LOGS/Entities/RoleMinimal.py +8 -0
- LOGS/Entities/RoleRequestParameter.py +40 -0
- LOGS/Entities/Roles.py +12 -0
- LOGS/Entities/RunState.py +9 -0
- LOGS/Entities/Sample.py +53 -0
- LOGS/Entities/SampleMinimal.py +8 -0
- LOGS/Entities/SampleRequestParameter.py +54 -0
- LOGS/Entities/Samples.py +12 -0
- LOGS/Entities/SharedContent.py +87 -0
- LOGS/Entities/SharedContentMinimal.py +8 -0
- LOGS/Entities/SharedContentRequestParameter.py +38 -0
- LOGS/Entities/SharedContents.py +12 -0
- LOGS/Entities/Signature.py +60 -0
- LOGS/Entities/Track.py +93 -0
- LOGS/Entities/TrackData.py +20 -0
- LOGS/Entities/TrackImage.py +21 -0
- LOGS/Entities/TrackImageData.py +20 -0
- LOGS/Entities/TrackMatrix.py +28 -0
- LOGS/Entities/TrackMatrixData.py +22 -0
- LOGS/Entities/TrackSettings.py +55 -0
- LOGS/Entities/TrackTable.py +21 -0
- LOGS/Entities/TrackTableData.py +22 -0
- LOGS/Entities/TrackXY.py +40 -0
- LOGS/Entities/TrackXYComplex.py +51 -0
- LOGS/Entities/TrackXYComplexData.py +50 -0
- LOGS/Entities/TrackXYData.py +31 -0
- LOGS/Entities/Vendor.py +40 -0
- LOGS/Entities/VendorMinimal.py +8 -0
- LOGS/Entities/VendorRequestParameter.py +17 -0
- LOGS/Entities/Vendors.py +12 -0
- LOGS/Entities/__init__.py +118 -0
- LOGS/Entity/ConnectedEntity.py +170 -0
- LOGS/Entity/Entity.py +203 -0
- LOGS/Entity/EntityConnector.py +70 -0
- LOGS/Entity/EntityIterator.py +263 -0
- LOGS/Entity/EntityMinimal.py +141 -0
- LOGS/Entity/EntityMinimalWithIntId.py +36 -0
- LOGS/Entity/EntityMinimalWithStrId.py +36 -0
- LOGS/Entity/EntityMinimalWithType.py +47 -0
- LOGS/Entity/EntityRequestParameter.py +104 -0
- LOGS/Entity/EntitySortBy.py +69 -0
- LOGS/Entity/EntityWithIntId.py +26 -0
- LOGS/Entity/EntityWithStrId.py +26 -0
- LOGS/Entity/IGenericEntityOrderBy.py +55 -0
- LOGS/Entity/IdIterator.py +207 -0
- LOGS/Entity/SerializableContent.py +834 -0
- LOGS/Entity/__init__.py +23 -0
- LOGS/Interfaces/ICustomFieldValue.py +92 -0
- LOGS/Interfaces/ICustomSectionValue.py +161 -0
- LOGS/Interfaces/ICustomTypeValue.py +152 -0
- LOGS/Interfaces/ICustomValue.py +28 -0
- LOGS/Interfaces/IEntityInterface.py +7 -0
- LOGS/Interfaces/IEntryRecord.py +57 -0
- LOGS/Interfaces/IHierarchicalEntity.py +41 -0
- LOGS/Interfaces/IHierarchyType.py +63 -0
- LOGS/Interfaces/ILockableEntity.py +52 -0
- LOGS/Interfaces/IModificationRecord.py +56 -0
- LOGS/Interfaces/INamedEntity.py +25 -0
- LOGS/Interfaces/IOwnedEntity.py +27 -0
- LOGS/Interfaces/IPaginationRequest.py +11 -0
- LOGS/Interfaces/IPermissionedEntity.py +72 -0
- LOGS/Interfaces/IProjectBased.py +27 -0
- LOGS/Interfaces/ISessionedEntity.py +59 -0
- LOGS/Interfaces/ISignableEntity.py +49 -0
- LOGS/Interfaces/ISoftDeletable.py +28 -0
- LOGS/Interfaces/ITypedEntity.py +129 -0
- LOGS/Interfaces/IUniqueEntity.py +61 -0
- LOGS/Interfaces/IVersionedEntity.py +39 -0
- LOGS/Interfaces/__init__.py +7 -0
- LOGS/LOGS.py +1436 -0
- LOGS/LOGSConnection.py +647 -0
- LOGS/LOGSOptions.py +11 -0
- LOGS/Parameters/Color.py +92 -0
- LOGS/Parameters/ParameterBase.py +55 -0
- LOGS/Parameters/ParameterConverter.py +24 -0
- LOGS/Parameters/ParameterElement.py +99 -0
- LOGS/Parameters/ParameterList.py +52 -0
- LOGS/Parameters/ParameterTable.py +64 -0
- LOGS/Parameters/__init__.py +13 -0
- LOGS/ServerMetaData.py +120 -0
- LOGS/__init__.py +12 -0
- logs_py-4.0.7.dist-info/METADATA +51 -0
- logs_py-4.0.7.dist-info/RECORD +251 -0
- logs_py-4.0.7.dist-info/WHEEL +5 -0
- logs_py-4.0.7.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from LOGS.Auxiliary.Tools import Tools
|
|
4
|
+
from LOGS.Entity.Entity import Entity
|
|
5
|
+
from LOGS.LOGSConnection import LOGSConnection
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IEntityWithIntId(Entity):
|
|
9
|
+
_id: int = 0
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
ref=None,
|
|
14
|
+
id: Optional[int] = None,
|
|
15
|
+
connection: Optional[LOGSConnection] = None,
|
|
16
|
+
):
|
|
17
|
+
"""Represents a connected LOGS entity type"""
|
|
18
|
+
super().__init__(ref=ref, id=id, connection=connection)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def id(self) -> int:
|
|
22
|
+
return self._id
|
|
23
|
+
|
|
24
|
+
@id.setter
|
|
25
|
+
def id(self, value):
|
|
26
|
+
self._id = Tools.checkAndConvert(value, int, "id")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from LOGS.Auxiliary.Tools import Tools
|
|
4
|
+
from LOGS.Entity.Entity import Entity
|
|
5
|
+
from LOGS.LOGSConnection import LOGSConnection
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class EntityWithStrId(Entity):
|
|
9
|
+
_id: str = ""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
ref=None,
|
|
14
|
+
id: Optional[str] = None,
|
|
15
|
+
connection: Optional[LOGSConnection] = None,
|
|
16
|
+
):
|
|
17
|
+
"""Represents a connected LOGS entity type"""
|
|
18
|
+
super().__init__(ref=ref, id=id, connection=connection)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def id(self) -> str:
|
|
22
|
+
return self._id
|
|
23
|
+
|
|
24
|
+
@id.setter
|
|
25
|
+
def id(self, value):
|
|
26
|
+
self._id = Tools.checkAndConvert(value, str, "id")
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Optional, cast
|
|
2
|
+
|
|
3
|
+
from typing_extensions import Self
|
|
4
|
+
|
|
5
|
+
from LOGS.Auxiliary.Tools import Tools
|
|
6
|
+
from LOGS.Entity.SerializableContent import SerializableClass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class IBaseEntityOrderBy(SerializableClass):
|
|
10
|
+
_value: Optional[str] = None
|
|
11
|
+
_fieldNames: List[str] = []
|
|
12
|
+
|
|
13
|
+
def fromString(self, ref: str):
|
|
14
|
+
fieldNames = self._getAttrList()
|
|
15
|
+
if ref not in fieldNames:
|
|
16
|
+
raise ValueError(
|
|
17
|
+
f"Invalid value '{ref}' for {self.__class__.__name__}. (Expected one of {Tools.eclipsesJoin(', ', fieldNames, 5)})"
|
|
18
|
+
)
|
|
19
|
+
self._value = ref
|
|
20
|
+
|
|
21
|
+
def listOptions(self) -> List[str]:
|
|
22
|
+
return self._getAttrList()
|
|
23
|
+
|
|
24
|
+
def toDict(self) -> Dict[str, Any]:
|
|
25
|
+
if self._value is None:
|
|
26
|
+
return cast(Dict[str, None], None)
|
|
27
|
+
return cast(Dict[str, None], self._value)
|
|
28
|
+
|
|
29
|
+
def contentToString(self, indentation: int = 1, hideNone: bool = False) -> str:
|
|
30
|
+
return str(self.toDict())
|
|
31
|
+
|
|
32
|
+
CUSTOM_FIELD: Self = cast(Self, "CUSTOM_FIELD")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class IGenericEntitySortingOptions(IBaseEntityOrderBy):
|
|
36
|
+
ID: Self = cast(Self, "ID")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class INamedEntitySortingOptions(IBaseEntityOrderBy):
|
|
40
|
+
NAME: Self = cast(Self, "NAME")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class IEntryRecordSortingOptions(IBaseEntityOrderBy):
|
|
44
|
+
ENTERED_BY: Self = cast(Self, "ENTERED_BY")
|
|
45
|
+
ENTERED_ON: Self = cast(Self, "ENTERED_ON")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class IModificationRecordSortingOptions(IBaseEntityOrderBy):
|
|
49
|
+
MODIFIED_BY: Self = cast(Self, "MODIFIED_BY")
|
|
50
|
+
MODIFIED_ON: Self = cast(Self, "MODIFIED_ON")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ITypedEntitySortingOptions(IBaseEntityOrderBy):
|
|
54
|
+
CUSTOM_TYPE: Self = cast(Self, "CUSTOM_TYPE")
|
|
55
|
+
CUSTOM_FIELD: Self = cast(Self, "CUSTOM_FIELD")
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
from typing import Generic, List, Optional, Type, TypeVar, Union, cast
|
|
2
|
+
|
|
3
|
+
from LOGS.Auxiliary.Exceptions import LOGSException
|
|
4
|
+
from LOGS.Auxiliary.Tools import Tools
|
|
5
|
+
from LOGS.Entity.Entity import Entity
|
|
6
|
+
from LOGS.Entity.EntityConnector import EntityConnector
|
|
7
|
+
from LOGS.Entity.EntityRequestParameter import EntityRequestParameter
|
|
8
|
+
from LOGS.LOGSConnection import RESPONSE_TYPES, LOGSConnection, ResponseTypes
|
|
9
|
+
|
|
10
|
+
# SELF = TypeVar("SELF", bound="EntityConnector")
|
|
11
|
+
|
|
12
|
+
_idType = TypeVar("_idType", bound=Union[int, str])
|
|
13
|
+
REQUEST = TypeVar("REQUEST", bound=EntityRequestParameter)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class EmptyIdIterator(Generic[_idType]):
|
|
17
|
+
def __iter__(self):
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def __next__(self) -> _idType:
|
|
21
|
+
raise StopIteration
|
|
22
|
+
|
|
23
|
+
def first(self) -> Union[_idType, None]:
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
def toList(self, count: Optional[int] = None) -> List[_idType]:
|
|
27
|
+
return []
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def count(self) -> int:
|
|
31
|
+
return 0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class IdIterator(Generic[_idType, REQUEST], EntityConnector[Entity]):
|
|
35
|
+
"""Represents a connected LOGS entity id iterator"""
|
|
36
|
+
|
|
37
|
+
_entityIterator: int
|
|
38
|
+
_currentResults: Optional[RESPONSE_TYPES]
|
|
39
|
+
_generatorType: Optional[Type[_idType]] = None
|
|
40
|
+
_parameterType: Optional[Type[REQUEST]] = None
|
|
41
|
+
|
|
42
|
+
_parametersInput: Optional[REQUEST]
|
|
43
|
+
_parameters: REQUEST
|
|
44
|
+
_responseType: ResponseTypes = ResponseTypes.JSON
|
|
45
|
+
_includeUrl: bool = True
|
|
46
|
+
_connection: Optional[LOGSConnection]
|
|
47
|
+
_count: Optional[int]
|
|
48
|
+
|
|
49
|
+
def __init__(
|
|
50
|
+
self, connection: Optional[LOGSConnection], parameters: Optional[REQUEST] = None
|
|
51
|
+
):
|
|
52
|
+
super().__init__(connection=connection)
|
|
53
|
+
|
|
54
|
+
self._parametersInput = parameters
|
|
55
|
+
|
|
56
|
+
self._entityIterator = 0
|
|
57
|
+
self._currentResults = None
|
|
58
|
+
self._count = None
|
|
59
|
+
|
|
60
|
+
def __iter__(self):
|
|
61
|
+
self._initEntityIterator()
|
|
62
|
+
return self
|
|
63
|
+
|
|
64
|
+
def __next__(self) -> _idType:
|
|
65
|
+
if not self._generatorType:
|
|
66
|
+
raise NotImplementedError(
|
|
67
|
+
"Iterator cannot generate items without a specified 'generatorType' field in class %a"
|
|
68
|
+
% type(self).__name__
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return self._getNextEntity()
|
|
72
|
+
|
|
73
|
+
def _getNextPage(self, result):
|
|
74
|
+
if not self._connection:
|
|
75
|
+
raise LOGSException("Connection of %a is not defined" % type(self).__name__)
|
|
76
|
+
|
|
77
|
+
if "hasNext" not in result or not result["hasNext"]:
|
|
78
|
+
return None, None
|
|
79
|
+
|
|
80
|
+
url = result["url"]
|
|
81
|
+
|
|
82
|
+
page = 1
|
|
83
|
+
if "page" in result:
|
|
84
|
+
page = int(result["page"])
|
|
85
|
+
elif self._parameters.page:
|
|
86
|
+
page = self._parameters.page
|
|
87
|
+
self._parameters.page = page + 1
|
|
88
|
+
return self._connection.postUrl(
|
|
89
|
+
url=url,
|
|
90
|
+
data=self._parameters.toDict(),
|
|
91
|
+
responseType=self._responseType,
|
|
92
|
+
includeUrl=self._includeUrl,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def _checkParameterType(self):
|
|
96
|
+
if not self._parameterType:
|
|
97
|
+
raise NotImplementedError(
|
|
98
|
+
"Entity connection cannot be initialized without the request 'parameterType' field in class %a"
|
|
99
|
+
% type(self).__name__
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if not isinstance(self._parameterType, type):
|
|
103
|
+
raise NotImplementedError(
|
|
104
|
+
"The field 'parameterType' must be a 'type' got %a in class %a"
|
|
105
|
+
% (type(self._parameterType), type(self).__name__)
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
if self._parametersInput and not isinstance(
|
|
109
|
+
self._parametersInput, self._parameterType
|
|
110
|
+
):
|
|
111
|
+
raise LOGSException(
|
|
112
|
+
"Parameter for iterator %a must be of type %a. (Got %a)"
|
|
113
|
+
% (
|
|
114
|
+
type(self).__name__,
|
|
115
|
+
self._parameterType.__name__,
|
|
116
|
+
type(self._parametersInput).__name__,
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
self._parametersInput = Tools.checkAndConvert(
|
|
121
|
+
self._parametersInput, self._parameterType, "parameters", initOnNone=True
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def _initEntityIterator(self):
|
|
125
|
+
self._checkParameterType()
|
|
126
|
+
|
|
127
|
+
url = self.getBaseUrl()
|
|
128
|
+
self._entityIterator = 0
|
|
129
|
+
|
|
130
|
+
if not self._connection:
|
|
131
|
+
raise LOGSException(
|
|
132
|
+
"Entity connector %a is not connected" % type(self).__name__
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
tmp = False
|
|
136
|
+
if hasattr(self._parameters, "includeCount"):
|
|
137
|
+
tmp = self._parameters.includeCount
|
|
138
|
+
self._parameters.includeCount = True
|
|
139
|
+
|
|
140
|
+
self._currentResults, responseError = self._connection.postUrl(
|
|
141
|
+
url=url + "/ids_only",
|
|
142
|
+
data=self._parameters.toDict(),
|
|
143
|
+
responseType=self._responseType,
|
|
144
|
+
includeUrl=self._includeUrl,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
if hasattr(self._parameters, "includeCount"):
|
|
148
|
+
self._parameters.includeCount = tmp
|
|
149
|
+
|
|
150
|
+
if isinstance(self._currentResults, dict) and "count" in self._currentResults:
|
|
151
|
+
self._count = int(self._currentResults["count"])
|
|
152
|
+
|
|
153
|
+
if responseError:
|
|
154
|
+
raise LOGSException(responseError=responseError)
|
|
155
|
+
|
|
156
|
+
def _getNextEntity(self):
|
|
157
|
+
if not isinstance(self._currentResults, dict):
|
|
158
|
+
raise StopIteration
|
|
159
|
+
|
|
160
|
+
results = self._currentResults["results"]
|
|
161
|
+
if self._entityIterator < len(results):
|
|
162
|
+
result = results[self._entityIterator]
|
|
163
|
+
self._entityIterator += 1
|
|
164
|
+
return result
|
|
165
|
+
|
|
166
|
+
self._currentResults, error = self._getNextPage(self._currentResults)
|
|
167
|
+
if error:
|
|
168
|
+
raise Exception("Connection error: %a", error)
|
|
169
|
+
self._entityIterator = 0
|
|
170
|
+
|
|
171
|
+
if (
|
|
172
|
+
not self._currentResults
|
|
173
|
+
or not isinstance(self._currentResults, dict)
|
|
174
|
+
or len(self._currentResults["results"]) < 1
|
|
175
|
+
):
|
|
176
|
+
raise StopIteration
|
|
177
|
+
|
|
178
|
+
return self._getNextEntity()
|
|
179
|
+
|
|
180
|
+
def first(self):
|
|
181
|
+
i = iter(self)
|
|
182
|
+
try:
|
|
183
|
+
return cast(_idType, next(i))
|
|
184
|
+
except StopIteration:
|
|
185
|
+
return None
|
|
186
|
+
|
|
187
|
+
def toList(self, count: Optional[int] = None):
|
|
188
|
+
if count:
|
|
189
|
+
count = int(count)
|
|
190
|
+
if count < 0:
|
|
191
|
+
raise Exception("Invalid negative count %d" % count)
|
|
192
|
+
result = cast(List[_idType], [])
|
|
193
|
+
num = 0
|
|
194
|
+
for entity in self:
|
|
195
|
+
result.append(entity)
|
|
196
|
+
num += 1
|
|
197
|
+
if num >= count:
|
|
198
|
+
break
|
|
199
|
+
return result
|
|
200
|
+
|
|
201
|
+
return list(self)
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def count(self) -> int:
|
|
205
|
+
if self._count is None:
|
|
206
|
+
self._initEntityIterator()
|
|
207
|
+
return self._count if self._count else 0
|