unique_sdk 0.10.15__py3-none-any.whl → 0.10.17__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.
@@ -1,8 +1,18 @@
1
1
  from enum import Enum
2
- from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, cast
2
+ from typing import (
3
+ Any,
4
+ ClassVar,
5
+ Dict,
6
+ List,
7
+ Literal,
8
+ Optional,
9
+ TypedDict,
10
+ cast,
11
+ )
3
12
 
4
13
  from typing_extensions import NotRequired, Unpack
5
14
 
15
+ import unique_sdk
6
16
  from unique_sdk._api_resource import APIResource
7
17
  from unique_sdk._request_options import RequestOptions
8
18
 
@@ -75,6 +85,7 @@ class Content(APIResource["Content"]):
75
85
  metadataFilter: dict
76
86
  skip: NotRequired[int]
77
87
  take: NotRequired[int]
88
+ filePath: NotRequired[str]
78
89
 
79
90
  class CustomApiOptions(TypedDict):
80
91
  apiIdentifier: str
@@ -117,6 +128,13 @@ class Content(APIResource["Content"]):
117
128
  storeInternally: bool
118
129
  fileUrl: Optional[str]
119
130
 
131
+ class UpdateParams(RequestOptions):
132
+ contentId: str | None = None
133
+ filePath: str | None = None
134
+ ownerId: str | None = None
135
+ parentFolderPath: str | None = None
136
+ title: str | None = None
137
+
120
138
  class Chunk(TypedDict):
121
139
  id: str
122
140
  text: str
@@ -148,6 +166,14 @@ class Content(APIResource["Content"]):
148
166
  contentInfos: List["Content.ContentInfo"]
149
167
  totalCount: int
150
168
 
169
+ class DeleteParams(RequestOptions):
170
+ contentId: NotRequired[str]
171
+ filePath: NotRequired[str]
172
+ chatId: NotRequired[str]
173
+
174
+ class DeleteResponse(TypedDict):
175
+ id: str
176
+
151
177
  id: str
152
178
  key: str
153
179
  url: Optional[str]
@@ -372,3 +398,163 @@ class Content(APIResource["Content"]):
372
398
  params=params,
373
399
  ),
374
400
  )
401
+
402
+ @classmethod
403
+ def update(
404
+ cls,
405
+ user_id: str,
406
+ company_id: str,
407
+ **params: Unpack["Content.UpdateParams"],
408
+ ) -> "Content.ContentInfo":
409
+ content_id = cls.resolve_content_id_from_file_path(
410
+ user_id,
411
+ company_id,
412
+ params.get("contentId"),
413
+ params.get("filePath"),
414
+ )
415
+ owner_id = unique_sdk.Folder.resolve_scope_id_from_folder_path(
416
+ user_id,
417
+ company_id,
418
+ params.get("ownerId"),
419
+ params.get("parentFolderPath"),
420
+ )
421
+ params.pop("contentId", None)
422
+ params.pop("filePath", None)
423
+ params.pop("parentFolderPath", None)
424
+ params["ownerId"] = owner_id
425
+
426
+ return cast(
427
+ "Content.ContentInfo",
428
+ cls._static_request(
429
+ "patch",
430
+ f"/content/{content_id}",
431
+ user_id,
432
+ company_id,
433
+ params=params,
434
+ ),
435
+ )
436
+
437
+ @classmethod
438
+ async def update_async(
439
+ cls,
440
+ user_id: str,
441
+ company_id: str,
442
+ **params: Unpack["Content.UpdateParams"],
443
+ ) -> "Content.ContentInfo":
444
+ content_id = cls.resolve_content_id_from_file_path(
445
+ user_id,
446
+ company_id,
447
+ params.get("contentId"),
448
+ params.get("filePath"),
449
+ )
450
+ owner_id = unique_sdk.Folder.resolve_scope_id_from_folder_path(
451
+ user_id,
452
+ company_id,
453
+ params.get("ownerId"),
454
+ params.get("parentFolderPath"),
455
+ )
456
+ params.pop("contentId", None)
457
+ params.pop("filePath", None)
458
+ params.pop("parentFolderPath", None)
459
+ params["ownerId"] = owner_id
460
+
461
+ return cast(
462
+ "Content.ContentInfo",
463
+ await cls._static_request_async(
464
+ "patch",
465
+ f"/content/{content_id}",
466
+ user_id,
467
+ company_id,
468
+ params=params,
469
+ ),
470
+ )
471
+
472
+ @classmethod
473
+ def delete(
474
+ cls,
475
+ user_id: str,
476
+ company_id: str,
477
+ **params: "Content.DeleteParams",
478
+ ) -> "Content.DeleteResponse":
479
+ """
480
+ Deletes a content by its id or file path.
481
+ """
482
+ content_id = cls.resolve_content_id_from_file_path(
483
+ user_id,
484
+ company_id,
485
+ params.get("contentId"),
486
+ params.get("filePath"),
487
+ )
488
+ params.pop("contentId", None)
489
+ params.pop("filePath", None)
490
+
491
+ return cast(
492
+ "Content.DeleteResponse",
493
+ cls._static_request(
494
+ "delete",
495
+ f"/content/{content_id}",
496
+ user_id,
497
+ company_id,
498
+ params=params,
499
+ ),
500
+ )
501
+
502
+ @classmethod
503
+ async def delete_async(
504
+ cls,
505
+ user_id: str,
506
+ company_id: str,
507
+ **params: "Content.DeleteParams",
508
+ ) -> "Content.DeleteResponse":
509
+ """
510
+ Async deletes a content by its id or file path.
511
+ """
512
+ content_id = cls.resolve_content_id_from_file_path(
513
+ user_id,
514
+ company_id,
515
+ params.get("contentId"),
516
+ params.get("filePath"),
517
+ )
518
+ params.pop("contentId", None)
519
+ params.pop("filePath", None)
520
+
521
+ return cast(
522
+ "Content.DeleteResponse",
523
+ await cls._static_request_async(
524
+ "delete",
525
+ f"/content/{content_id}",
526
+ user_id,
527
+ company_id,
528
+ params=params,
529
+ ),
530
+ )
531
+
532
+ @classmethod
533
+ def resolve_content_id_from_file_path(
534
+ cls,
535
+ user_id: str,
536
+ company_id: str,
537
+ content_id: str | None = None,
538
+ file_path: str | None = None,
539
+ ) -> str:
540
+ """
541
+ Returns the contentId to use: if content_id is provided, returns it;
542
+ if not, but file_path is provided, resolves and returns the id for that file path.
543
+ """
544
+ if content_id:
545
+ return content_id
546
+ if file_path:
547
+ file_info = cls.get_info(
548
+ user_id=user_id,
549
+ company_id=company_id,
550
+ filePath=file_path,
551
+ )
552
+ resolved_id = (
553
+ file_info.get("contentInfo")[0].get("id")
554
+ if file_info.get("totalCount", 0) > 0
555
+ else None
556
+ )
557
+ if not resolved_id:
558
+ raise ValueError(f"Could not find file with filePath: {file_path}")
559
+ return resolved_id
560
+ return None
@@ -418,7 +418,7 @@ class Folder(APIResource["Folder"]):
418
418
  Delete a folder by its ID or path.
419
419
  """
420
420
 
421
- scopeId = cls.resolve_scope_id(
421
+ scopeId = cls.resolve_scope_id_from_folder_path(
422
422
  user_id, company_id, params.get("scopeId"), params.get("folderPath")
423
423
  )
424
424
  params.pop("scopeId", None)
@@ -445,7 +445,7 @@ class Folder(APIResource["Folder"]):
445
445
  """
446
446
  Async delete a folder by its ID or path.
447
447
  """
448
- scopeId = cls.resolve_scope_id(
448
+ scopeId = cls.resolve_scope_id_from_folder_path(
449
449
  user_id, company_id, params.get("scopeId"), params.get("folderPath")
450
450
  )
451
451
  params.pop("scopeId", None)
@@ -463,7 +463,7 @@ class Folder(APIResource["Folder"]):
463
463
  )
464
464
 
465
465
  @classmethod
466
- def resolve_scope_id(
466
+ def resolve_scope_id_from_folder_path(
467
467
  cls,
468
468
  user_id: str,
469
469
  company_id: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_sdk
3
- Version: 0.10.15
3
+ Version: 0.10.17
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Martin Fadler
@@ -554,6 +554,98 @@ Allows you to ingest a magic table sheet, each row is processed and converted in
554
554
  unique_sdk.Content.ingest_magic_table_sheets(**params)
555
555
  ```
556
556
 
557
+ #### `unique_sdk.Content.update` (Compatible with release >.36)
558
+
559
+ Allows you to update a file specified by its `contentId` or by its `filePath`.
560
+
561
+ - `contentId` optional if `filePath` is provided, the id of the file to be updated
562
+ - `filePath` optional if `contentId` is provided, the absolute path of the file to be updated
563
+
564
+ Currently, the following updates are supported:
565
+
566
+ Title update:
567
+ - `title` optional, allows updating the title of the folder
568
+
569
+ Move the file to a different folder. this can be done by specifying either the `ownerId` or the `parentFolderPath`.
570
+ - `ownerId` optional, allows moving the file to a different folder. Represents the new folder for the file and it should be the id of a folder e.g.: `scope_dhjfieurfloakmdle`.
571
+ - `parentFolderPath` optional, allows moving the file to a different folder. Represents the path new folder for the file.
572
+
573
+
574
+ Example of updating the title of a file specified by its path.
575
+
576
+ ```python
577
+ unique_sdk.Content.update(
578
+ user_id=user_id,
579
+ company_id=company_id,
580
+ filePath="/Company/finance/january.xls",
581
+ title="Revision Deck"
582
+ )
583
+ ```
584
+
585
+ Example of moving a file specified by its content id.
586
+
587
+ ```python
588
+ unique_sdk.Content.update(
589
+ user_id=user_id,
590
+ company_id=company_id,
591
+ contentId="cont_ok2343q5owbce80w78hudawu5",
592
+ ownerId="scope_e68yz5asho7glfh7c7d041el"
593
+ )
594
+ ```
595
+
596
+ Example of moving a file and updating its title.
597
+
598
+ ```python
599
+ unique_sdk.Content.update(
600
+ user_id=user_id,
601
+ company_id=company_id,
602
+ contentId="cont_ok2343q5owbce80w78hudawu5",
603
+ ownerId="scope_e68yz5asho7glfh7c7d041el",
604
+ title="Revision Deck (1)"
605
+ )
606
+ ```
607
+
608
+ Example of moving a file to a folder specified by its path.
609
+
610
+ ```python
611
+ unique_sdk.Content.update(
612
+ user_id=user_id,
613
+ company_id=company_id,
614
+ contentId="cont_ok2343q5owbce80w78hudawu5",
615
+ ownerId="scope_e68yz5asho7glfh7c7d041el",
616
+ parentFolderPath="/Company/Revisions"
617
+ )
618
+ ```
619
+
620
+ #### `unique_sdk.Content.delete` (Compatible with release >.36)
621
+
622
+ Allows you to delete a file by its `contentId` or by its `filePath`. When deleting by `id`, if the file is part of a chat, the `chatId` also needs do be set. If both `contentId` and `filePath` are provided, `filePath` is ignored.
623
+
624
+ - `contentId` optional if `filePath` is provided, the id of the file to be deleted
625
+ - `chatId` optional, the id of the chat where the file is. Only needed if the file is part of a chat
626
+ - `filePath` optional if `contentId` is provided, the absolute path of the file to be deleted
627
+
628
+ Example of deleting a file from a chat.
629
+
630
+ ```python
631
+ unique_sdk.Content.delete(
632
+ user_id=user_id,
633
+ company_id=company_id,
634
+ contentId="cont_ok2343q5owbce80w78hudawu5",
635
+ chatId="chat_v3xfa7liv876h89vuiibus1"
636
+ )
637
+ ```
638
+
639
+ Example of deleting a file by its path.
640
+
641
+ ```python
642
+ unique_sdk.Content.delete(
643
+ user_id=user_id,
644
+ company_id=company_id,
645
+ filePath="/Company/finance/january.xls",
646
+ )
647
+ ```
648
+
557
649
  ### Message
558
650
 
559
651
  #### `unique_sdk.Message.list`
@@ -1516,6 +1608,12 @@ All notable changes to this project will be documented in this file.
1516
1608
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1517
1609
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1518
1610
 
1611
+ ## [0.10.17] - 2025-09-01
1612
+ - Add function to update a file
1613
+
1614
+ ## [0.10.16] - 2025-08-31
1615
+ - Add function to delete a content.
1616
+
1519
1617
  ## [0.10.15] - 2025-08-28
1520
1618
  - Add default values for message log types
1521
1619
 
@@ -17,10 +17,10 @@ unique_sdk/api_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
17
17
  unique_sdk/api_resources/_acronyms.py,sha256=GIU1XH1flGWQYcpsFqTYwg4ioIGxVmb15tux84nmhEg,891
18
18
  unique_sdk/api_resources/_agentic_table.py,sha256=8-_f7t-m_iiiOj2835iESoxz91YRxl4-tkxpzQbgdcI,9958
19
19
  unique_sdk/api_resources/_chat_completion.py,sha256=ILCAffxkbkfh2iV9L4KKnfe80gZmT9pWfkNmf3mq68U,2172
20
- unique_sdk/api_resources/_content.py,sha256=WQiNdBSE7pe9QV15NXy_kqhEHCqrjH7Xzk3eSK-456c,10723
20
+ unique_sdk/api_resources/_content.py,sha256=rjpTnDXJFw1EGP2n57WLlO_7fO6z8ykrnySkGXpYUEs,15820
21
21
  unique_sdk/api_resources/_embedding.py,sha256=C6qak7cCUBMBINfPhgH8taCJZ9n6w1MUElqDJJ8dG10,1281
22
22
  unique_sdk/api_resources/_event.py,sha256=bpWF9vstdoAWbUzr-iiGP713ceP0zPk77GJXiImf9zg,374
23
- unique_sdk/api_resources/_folder.py,sha256=u_x6g8g_LQsRiJm7ExYuFBxNywfbhOtnSIVK0HwcDws,12820
23
+ unique_sdk/api_resources/_folder.py,sha256=mIyWaxJtIHlDLPFZ0FY1U9b3dmtmIcjDEbgOZtLA-DI,12871
24
24
  unique_sdk/api_resources/_integrated.py,sha256=z_DrftwjgVCi10QQqRYnG5_-95kD7Kfjogbb-dmnJuA,5854
25
25
  unique_sdk/api_resources/_mcp.py,sha256=zKh0dyn0QnkKk57N2zlGVN_GQoxEp5T2CS38vVm6jQY,3341
26
26
  unique_sdk/api_resources/_message.py,sha256=gEDIzg3METZU2k7m69meAuf0IWmZxnYOjbBKPRMwPYE,7688
@@ -36,7 +36,7 @@ unique_sdk/utils/chat_in_space.py,sha256=3NeBjOu7p43V_6PrjwxyaTkgknUS10KE4QRuTlF
36
36
  unique_sdk/utils/file_io.py,sha256=YY8B7VJcTLOPmCXByiOfNerXGlAtjCC5EVNmAbQJ3dQ,4306
37
37
  unique_sdk/utils/sources.py,sha256=DoxxhMLcLhmDfNarjXa41H4JD2GSSDywr71hiC-4pYc,4952
38
38
  unique_sdk/utils/token.py,sha256=AzKuAA1AwBtnvSFxGcsHLpxXr_wWE5Mj4jYBbOz2ljA,1740
39
- unique_sdk-0.10.15.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
40
- unique_sdk-0.10.15.dist-info/METADATA,sha256=u4BkT3XbxcWZ6d0Em3QtURDWrdo85KfHWGqhTvfJ3sA,52058
41
- unique_sdk-0.10.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
42
- unique_sdk-0.10.15.dist-info/RECORD,,
39
+ unique_sdk-0.10.17.dist-info/LICENSE,sha256=EJCWoHgrXVBUb47PnjeV4MFIEOR71MAdCOIgv61J-4k,1065
40
+ unique_sdk-0.10.17.dist-info/METADATA,sha256=kqPSSpUqlgzvlDeR_-9bfF2LXNVtMv4WSCZZYtkht60,55043
41
+ unique_sdk-0.10.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
42
+ unique_sdk-0.10.17.dist-info/RECORD,,