lumera 0.8.2__tar.gz → 0.9.0__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lumera
3
- Version: 0.8.2
3
+ Version: 0.9.0
4
4
  Summary: SDK for building on Lumera platform
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: requests
@@ -11,7 +11,7 @@ New code should use:
11
11
  """
12
12
 
13
13
  # Re-export everything from the new location
14
- from lumera.integrations.google import (
14
+ from .integrations.google import (
15
15
  MIME_EXCEL,
16
16
  MIME_GOOGLE_SHEET,
17
17
  delete_rows_api_call,
@@ -342,24 +342,28 @@ def bulk_delete(collection: str, record_ids: Sequence[str]) -> dict[str, Any]:
342
342
 
343
343
  def bulk_update(
344
344
  collection: str,
345
- record_ids: Sequence[str],
346
- data: dict[str, Any],
345
+ records: Sequence[dict[str, Any]],
347
346
  ) -> dict[str, Any]:
348
- """Update multiple records with the same data.
347
+ """Update multiple records with individual data per record.
348
+
349
+ Each record must have an 'id' field plus fields to update.
350
+ Records must exist (returns error if not found, does not create).
349
351
 
350
352
  Args:
351
353
  collection: Collection name or ID
352
- record_ids: List of record IDs to update (max 1000)
353
- data: Fields to update on all records
354
+ records: List of records to update (max 1000). Each must have 'id' field.
354
355
 
355
356
  Returns:
356
357
  Result with succeeded/failed counts
357
358
 
358
359
  Example:
359
- >>> result = pb.bulk_update("deposits", ["id1", "id2"], {"status": "processed"})
360
+ >>> result = pb.bulk_update("deposits", [
361
+ ... {"id": "rec1", "status": "approved", "amount": 100},
362
+ ... {"id": "rec2", "status": "rejected", "amount": 200},
363
+ ... ])
360
364
  >>> print(f"Updated {result['succeeded']} records")
361
365
  """
362
- return _bulk_update_records(collection, record_ids, data)
366
+ return _bulk_update_records(collection, records)
363
367
 
364
368
 
365
369
  def bulk_upsert(collection: str, records: Sequence[dict[str, Any]]) -> dict[str, Any]:
@@ -613,28 +613,24 @@ def bulk_delete_records(
613
613
 
614
614
  def bulk_update_records(
615
615
  collection_id_or_name: str,
616
- record_ids: Sequence[str],
617
- data: Mapping[str, Any],
616
+ records: Sequence[Mapping[str, Any]],
618
617
  ) -> dict[str, Any]:
619
- """Update multiple records with the same data.
618
+ """Update multiple records with individual data per record.
620
619
 
621
620
  Args:
622
621
  collection_id_or_name: Collection name or ID
623
- record_ids: List of record IDs to update (max 1000)
624
- data: Fields to update on all records
622
+ records: List of records to update (max 1000). Each record must have an 'id' field.
625
623
 
626
624
  Returns:
627
625
  Result with succeeded/failed counts
628
626
  """
629
627
  if not collection_id_or_name:
630
628
  raise ValueError("collection_id_or_name is required")
631
- if not record_ids:
632
- raise ValueError("record_ids is required")
633
- if not data:
634
- raise ValueError("data is required")
629
+ if not records:
630
+ raise ValueError("records is required")
635
631
 
636
632
  path = f"collections/{collection_id_or_name}/records/bulk/update"
637
- result = _api_request("POST", path, json_body={"ids": list(record_ids), "data": dict(data)})
633
+ result = _api_request("POST", path, json_body={"records": [dict(r) for r in records]})
638
634
  return result if isinstance(result, dict) else {}
639
635
 
640
636
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lumera
3
- Version: 0.8.2
3
+ Version: 0.9.0
4
4
  Summary: SDK for building on Lumera platform
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: requests
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lumera"
3
- version = "0.8.2"
3
+ version = "0.9.0"
4
4
  description = "SDK for building on Lumera platform"
5
5
  requires-python = ">=3.11"
6
6
  dependencies = [
@@ -852,3 +852,45 @@ def test_claim_locks_custom_provenance(monkeypatch: pytest.MonkeyPatch) -> None:
852
852
  body = captured.get("json_body")
853
853
  assert isinstance(body, dict)
854
854
  assert body["provenance"] == custom_prov
855
+
856
+
857
+ def test_bulk_update_records(monkeypatch: pytest.MonkeyPatch) -> None:
858
+ monkeypatch.setenv(sdk.TOKEN_ENV, "tok")
859
+
860
+ captured: dict[str, object] = {}
861
+
862
+ def fake_api(method: str, path: str, **kwargs: object) -> dict[str, object]:
863
+ captured["method"] = method
864
+ captured["path"] = path
865
+ captured["kwargs"] = kwargs
866
+ return {"succeeded": 2, "failed": 0, "errors": []}
867
+
868
+ monkeypatch.setattr(sdk, "_api_request", fake_api)
869
+
870
+ result = sdk.bulk_update_records(
871
+ "test_collection",
872
+ [
873
+ {"id": "rec1", "status": "approved", "amount": 100},
874
+ {"id": "rec2", "status": "rejected", "amount": 200},
875
+ ],
876
+ )
877
+
878
+ assert result["succeeded"] == 2
879
+ assert result["failed"] == 0
880
+ assert captured["method"] == "POST"
881
+ assert captured["path"] == "collections/test_collection/records/bulk/update"
882
+ kwargs = captured["kwargs"]
883
+ assert "json_body" in kwargs
884
+ body = kwargs["json_body"]
885
+ assert isinstance(body, dict)
886
+ assert "records" in body
887
+ assert len(body["records"]) == 2
888
+ assert body["records"][0]["id"] == "rec1"
889
+ assert body["records"][0]["status"] == "approved"
890
+ assert body["records"][1]["id"] == "rec2"
891
+ assert body["records"][1]["status"] == "rejected"
892
+
893
+
894
+ def test_bulk_update_records_requires_records() -> None:
895
+ with pytest.raises(ValueError, match="records is required"):
896
+ sdk.bulk_update_records("test_collection", [])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes