albert 1.11.0__py3-none-any.whl → 1.11.2__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.
- albert/__init__.py +1 -1
- albert/collections/attachments.py +17 -11
- albert/resources/entity_types.py +15 -4
- {albert-1.11.0.dist-info → albert-1.11.2.dist-info}/METADATA +1 -1
- {albert-1.11.0.dist-info → albert-1.11.2.dist-info}/RECORD +7 -7
- {albert-1.11.0.dist-info → albert-1.11.2.dist-info}/WHEEL +0 -0
- {albert-1.11.0.dist-info → albert-1.11.2.dist-info}/licenses/LICENSE +0 -0
albert/__init__.py
CHANGED
|
@@ -152,20 +152,30 @@ class AttachmentCollection(BaseCollection):
|
|
|
152
152
|
The name of the file, by default ""
|
|
153
153
|
upload_key : str | None, optional
|
|
154
154
|
Override the storage key used when signing and uploading the file.
|
|
155
|
-
Defaults to
|
|
155
|
+
Defaults to ``{parent_id}/{note_id}/{file_name}``.
|
|
156
156
|
|
|
157
157
|
Returns
|
|
158
158
|
-------
|
|
159
159
|
Note
|
|
160
160
|
The created note.
|
|
161
161
|
"""
|
|
162
|
-
|
|
163
|
-
if not upload_name:
|
|
162
|
+
if not (upload_key or file_name):
|
|
164
163
|
raise ValueError("A file name or upload key must be provided for attachment upload.")
|
|
165
164
|
|
|
166
|
-
file_type = mimetypes.guess_type(file_name or upload_name)[0]
|
|
167
|
-
file_collection = self._get_file_collection()
|
|
168
165
|
note_collection = self._get_note_collection()
|
|
166
|
+
note = Note(
|
|
167
|
+
parent_id=parent_id,
|
|
168
|
+
note=note_text,
|
|
169
|
+
)
|
|
170
|
+
registered_note = note_collection.create(note=note)
|
|
171
|
+
if upload_key:
|
|
172
|
+
attachment_name = file_name or Path(upload_key).name
|
|
173
|
+
upload_name = upload_key
|
|
174
|
+
else:
|
|
175
|
+
attachment_name = file_name
|
|
176
|
+
upload_name = f"{parent_id}/{registered_note.id}/{file_name}"
|
|
177
|
+
file_type = mimetypes.guess_type(attachment_name or upload_name)[0]
|
|
178
|
+
file_collection = self._get_file_collection()
|
|
169
179
|
|
|
170
180
|
file_collection.sign_and_upload_file(
|
|
171
181
|
data=file_data,
|
|
@@ -176,16 +186,12 @@ class AttachmentCollection(BaseCollection):
|
|
|
176
186
|
file_info = file_collection.get_by_name(
|
|
177
187
|
name=upload_name, namespace=FileNamespace.RESULT.value
|
|
178
188
|
)
|
|
179
|
-
note = Note(
|
|
180
|
-
parent_id=parent_id,
|
|
181
|
-
note=note_text,
|
|
182
|
-
)
|
|
183
|
-
registered_note = note_collection.create(note=note)
|
|
184
189
|
self.attach_file_to_note(
|
|
185
190
|
note_id=registered_note.id,
|
|
186
|
-
file_name=
|
|
191
|
+
file_name=attachment_name,
|
|
187
192
|
file_key=file_info.name,
|
|
188
193
|
)
|
|
194
|
+
|
|
189
195
|
return note_collection.get_by_id(id=registered_note.id)
|
|
190
196
|
|
|
191
197
|
@validate_call
|
albert/resources/entity_types.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from enum import Enum
|
|
2
4
|
from typing import Any
|
|
3
5
|
|
|
4
|
-
from pydantic import Field
|
|
6
|
+
from pydantic import Field, model_validator
|
|
5
7
|
|
|
6
8
|
from albert.core.shared.identifiers import CustomFieldId, EntityTypeId, RuleId
|
|
7
9
|
from albert.core.shared.models.base import BaseAlbertModel, BaseResource, EntityLink
|
|
@@ -173,8 +175,8 @@ class EntityType(BaseResource):
|
|
|
173
175
|
----------
|
|
174
176
|
id : EntityTypeId
|
|
175
177
|
The unique identifier for the entity type.
|
|
176
|
-
category : EntityCategory
|
|
177
|
-
The category the entity type belongs to.
|
|
178
|
+
category : EntityCategory | None
|
|
179
|
+
The category the entity type belongs to. Required for tasks and inventories.
|
|
178
180
|
custom_category : str | None, optional
|
|
179
181
|
A custom category name for the entity type.
|
|
180
182
|
label : str
|
|
@@ -194,7 +196,7 @@ class EntityType(BaseResource):
|
|
|
194
196
|
"""
|
|
195
197
|
|
|
196
198
|
id: EntityTypeId | None = Field(alias="albertId", default=None)
|
|
197
|
-
category: EntityCategory
|
|
199
|
+
category: EntityCategory | None = None
|
|
198
200
|
custom_category: str | None = Field(
|
|
199
201
|
default=None, max_length=100, min_length=1, alias="customCategory"
|
|
200
202
|
)
|
|
@@ -215,6 +217,15 @@ class EntityType(BaseResource):
|
|
|
215
217
|
alias="searchQueryString", default=None
|
|
216
218
|
)
|
|
217
219
|
|
|
220
|
+
@model_validator(mode="after")
|
|
221
|
+
def validate_category(self) -> EntityType:
|
|
222
|
+
if (
|
|
223
|
+
self.service in {EntityServiceType.TASKS, EntityServiceType.INVENTORIES}
|
|
224
|
+
and self.category is None
|
|
225
|
+
):
|
|
226
|
+
raise ValueError("category is required for tasks and inventories entity types.")
|
|
227
|
+
return self
|
|
228
|
+
|
|
218
229
|
|
|
219
230
|
class EntityTypeOptionType(str, Enum):
|
|
220
231
|
"""Types of options that can be used in entity type fields.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: albert
|
|
3
|
-
Version: 1.11.
|
|
3
|
+
Version: 1.11.2
|
|
4
4
|
Summary: The official Python SDK for the Albert Invent platform.
|
|
5
5
|
Project-URL: Homepage, https://www.albertinvent.com/
|
|
6
6
|
Project-URL: Documentation, https://docs.developer.albertinvent.com/albert-python
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
albert/__init__.py,sha256=
|
|
1
|
+
albert/__init__.py,sha256=w6OATl6C5XTZwB_fGPlL2-I1i3fMb3WkBFdxI2uKTSc,239
|
|
2
2
|
albert/client.py,sha256=9SUy9AJpnFEUlSfxvbP1gJI776WcOoZykgPHx0EcF8g,12038
|
|
3
3
|
albert/exceptions.py,sha256=-oxOJGE0A__aPUhri3qqb5YQ5qanECcTqamS73vGajM,3172
|
|
4
4
|
albert/collections/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
albert/collections/activities.py,sha256=vvV5-f9KH52HarVSzUNAL7o4hz9mKWEZiE1MreqiH1g,3373
|
|
6
|
-
albert/collections/attachments.py,sha256=
|
|
6
|
+
albert/collections/attachments.py,sha256=Lq5q2sMUKMBargfCM7xqFMbaZLRNRvyhjCUT5sWdhUk,10169
|
|
7
7
|
albert/collections/base.py,sha256=MwBHndy5mXHvieozseaT1YF_RDevJWYu4IFGpLCBfww,8590
|
|
8
8
|
albert/collections/batch_data.py,sha256=esMttDTCY8TqSEOfMFQQ6Um_77Mf-SY3g75t1b6THjQ,3388
|
|
9
9
|
albert/collections/btdataset.py,sha256=rhjO4RtGSzAZj4hgA4M9BKG-eyhl111IDwZr_JW4t_E,4461
|
|
@@ -76,7 +76,7 @@ albert/resources/custom_fields.py,sha256=spu5S32wFQ-ifKh-6QKjmSFz5HawAYaEM9EeA7P
|
|
|
76
76
|
albert/resources/custom_templates.py,sha256=iglIlk4WYgvYkaCcQ8W_qZjDROyKAFC-7Fib_RFY-48,9710
|
|
77
77
|
albert/resources/data_columns.py,sha256=y9-14lF3ncvJ4ut7TxSz2Wp6tw96o578aVUYh7CBDT4,345
|
|
78
78
|
albert/resources/data_templates.py,sha256=Wf1iyKFNDV-vuEHUNjYBL-gMYYaHfmjE82TgcHe0LxA,7009
|
|
79
|
-
albert/resources/entity_types.py,sha256=
|
|
79
|
+
albert/resources/entity_types.py,sha256=7lessP8StBDfi4DZMifvRNN4lspdQ5X0olBIu7lT_AI,11244
|
|
80
80
|
albert/resources/facet.py,sha256=tjm6CsOL7T5LSV4G9406C1c5mpzY1gpfQYAttP6Hckw,372
|
|
81
81
|
albert/resources/files.py,sha256=0q5H6rJ9il0Oy1FnwxVo3otq_w8YQeQjo29DgsTY8JQ,1067
|
|
82
82
|
albert/resources/hazards.py,sha256=ltlbYct3PhvpTojqic0OcfJVKd2s6m59XqszzZZAuWo,375
|
|
@@ -117,7 +117,7 @@ albert/utils/data_template.py,sha256=AUwzfQ-I2HY-osq_Tme5KLwXfMzW2pJpiud7HAMh148
|
|
|
117
117
|
albert/utils/inventory.py,sha256=ViHxb62DVxniEJqOfD7Gf8HltLeCbq21y4rS1xkVRnY,5349
|
|
118
118
|
albert/utils/property_data.py,sha256=US_5PYZu2Yv3CmAuWMQfYztjSIgNaRrCz9SsVzLOGcw,22906
|
|
119
119
|
albert/utils/tasks.py,sha256=ejhXD9yQR_ReDKLJ3k8ZxWxkYl-Mta_4OPXrz_lQiBI,19878
|
|
120
|
-
albert-1.11.
|
|
121
|
-
albert-1.11.
|
|
122
|
-
albert-1.11.
|
|
123
|
-
albert-1.11.
|
|
120
|
+
albert-1.11.2.dist-info/METADATA,sha256=zBwfJkO8ubUMm-06Wj3wA8c4eE97E_LbUj5K03bEKY4,15427
|
|
121
|
+
albert-1.11.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
122
|
+
albert-1.11.2.dist-info/licenses/LICENSE,sha256=S7_vRdIhQmG7PmTlU8-BCCveuEcFZ6_3IUVdcoaJMuA,11348
|
|
123
|
+
albert-1.11.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|