Skip to content

Commit 84f0276

Browse files
authored
Merge pull request #8 from rush-db/feature/post-release-cleanups
Feature/post release cleanups
2 parents a3d01b9 + b345250 commit 84f0276

File tree

9 files changed

+170
-173
lines changed

9 files changed

+170
-173
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Searches for records matching specified criteria.
203203
```python
204204
def find(
205205
self,
206-
query: Optional[SearchQuery] = None,
206+
search_query: Optional[SearchQuery] = None,
207207
record_id: Optional[str] = None,
208208
transaction: Optional[Transaction] = None
209209
) -> List[Record]
@@ -830,7 +830,7 @@ Retrieves a list of properties based on optional search criteria.
830830
```python
831831
def find(
832832
self,
833-
query: Optional[SearchQuery] = None,
833+
search_query: Optional[SearchQuery] = None,
834834
transaction: Optional[Transaction] = None
835835
) -> List[Property]
836836
```

poetry.lock

Lines changed: 120 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "rushdb"
3-
version = "1.0.0"
3+
version = "1.2.0"
44
description = "RushDB Python SDK"
55
authors = ["RushDB Team <hi@rushdb.com>"]
66
license = "Apache-2.0"

src/rushdb/api/labels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class LabelsAPI(BaseAPI):
1111

1212
def list(
1313
self,
14-
query: Optional[SearchQuery] = None,
14+
search_query: Optional[SearchQuery] = None,
1515
transaction: Optional[Transaction] = None,
1616
) -> List[str]:
1717
"""List all labels."""
1818
headers = Transaction._build_transaction_header(transaction)
1919

2020
return self.client._make_request(
2121
"POST",
22-
"/api/v1/labels/search",
23-
data=typing.cast(typing.Dict[str, typing.Any], query or {}),
22+
"/labels/search",
23+
data=typing.cast(typing.Dict[str, typing.Any], search_query or {}),
2424
headers=headers,
2525
)

src/rushdb/api/properties.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
import typing
2-
from typing import List, Literal, Optional
2+
from typing import List, Optional
33

44
from ..models.property import Property, PropertyValuesData
55
from ..models.search_query import SearchQuery
66
from ..models.transaction import Transaction
77
from .base import BaseAPI
88

99

10+
class PropertyValuesQuery(SearchQuery, total=False):
11+
"""Extended SearchQuery for property values endpoint with text search support."""
12+
13+
query: Optional[str] # For text search among values
14+
15+
1016
class PropertiesAPI(BaseAPI):
1117
"""API for managing properties in RushDB."""
1218

1319
def find(
1420
self,
15-
query: Optional[SearchQuery] = None,
21+
search_query: Optional[SearchQuery] = None,
1622
transaction: Optional[Transaction] = None,
1723
) -> List[Property]:
1824
"""List all properties."""
1925
headers = Transaction._build_transaction_header(transaction)
2026

2127
return self.client._make_request(
2228
"POST",
23-
"/api/v1/properties/search",
24-
typing.cast(typing.Dict[str, typing.Any], query or {}),
29+
"/properties/search",
30+
typing.cast(typing.Dict[str, typing.Any], search_query or {}),
2531
headers,
2632
)
2733

@@ -32,7 +38,7 @@ def find_by_id(
3238
headers = Transaction._build_transaction_header(transaction)
3339

3440
return self.client._make_request(
35-
"GET", f"/api/v1/properties/{property_id}", headers=headers
41+
"GET", f"/properties/{property_id}", headers=headers
3642
)
3743

3844
def delete(
@@ -42,24 +48,21 @@ def delete(
4248
headers = Transaction._build_transaction_header(transaction)
4349

4450
return self.client._make_request(
45-
"DELETE", f"/api/v1/properties/{property_id}", headers=headers
51+
"DELETE", f"/properties/{property_id}", headers=headers
4652
)
4753

4854
def values(
4955
self,
5056
property_id: str,
51-
sort: Optional[Literal["asc", "desc"]],
52-
query: Optional[str],
53-
skip: Optional[int],
54-
limit: Optional[int],
57+
search_query: Optional[PropertyValuesQuery] = None,
5558
transaction: Optional[Transaction] = None,
5659
) -> PropertyValuesData:
5760
"""Get values data for a property."""
5861
headers = Transaction._build_transaction_header(transaction)
5962

6063
return self.client._make_request(
61-
"GET",
62-
f"/api/v1/properties/{property_id}/values",
63-
headers=headers,
64-
params={"sort": sort, "skip": skip, "limit": limit, "query": query},
64+
"POST",
65+
f"/properties/{property_id}/values",
66+
typing.cast(typing.Dict[str, typing.Any], search_query or {}),
67+
headers,
6568
)

src/rushdb/api/records.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ def set(
1919
) -> Dict[str, str]:
2020
"""Update a record by ID."""
2121
headers = Transaction._build_transaction_header(transaction)
22-
return self.client._make_request(
23-
"PUT", f"/api/v1/records/{record_id}", data, headers
24-
)
22+
return self.client._make_request("PUT", f"/records/{record_id}", data, headers)
2523

2624
def update(
2725
self,
@@ -33,7 +31,7 @@ def update(
3331
headers = Transaction._build_transaction_header(transaction)
3432

3533
return self.client._make_request(
36-
"PATCH", f"/api/v1/records/{record_id}", data, headers
34+
"PATCH", f"/records/{record_id}", data, headers
3735
)
3836

3937
def create(
@@ -62,9 +60,7 @@ def create(
6260
"data": data,
6361
"options": options or {"returnResult": True, "suggestTypes": True},
6462
}
65-
response = self.client._make_request(
66-
"POST", "/api/v1/records", payload, headers
67-
)
63+
response = self.client._make_request("POST", "/records", payload, headers)
6864
return Record(self.client, response.get("data"))
6965

7066
def create_many(
@@ -93,7 +89,7 @@ def create_many(
9389
"options": options or {"returnResult": True, "suggestTypes": True},
9490
}
9591
response = self.client._make_request(
96-
"POST", "/api/v1/records/import/json", payload, headers
92+
"POST", "/records/import/json", payload, headers
9793
)
9894
return [Record(self.client, record) for record in response.get("data")]
9995

@@ -120,7 +116,7 @@ def attach(
120116
if options:
121117
payload.update(typing.cast(typing.Dict[str, typing.Any], options))
122118
return self.client._make_request(
123-
"POST", f"/api/v1/relationships/{source_id}", payload, headers
119+
"POST", f"/relationships/{source_id}", payload, headers
124120
)
125121

126122
def detach(
@@ -146,19 +142,19 @@ def detach(
146142
if options:
147143
payload.update(typing.cast(typing.Dict[str, typing.Any], options))
148144
return self.client._make_request(
149-
"PUT", f"/api/v1/relationships/{source_id}", payload, headers
145+
"PUT", f"/relationships/{source_id}", payload, headers
150146
)
151147

152148
def delete(
153-
self, query: SearchQuery, transaction: Optional[Transaction] = None
149+
self, search_query: SearchQuery, transaction: Optional[Transaction] = None
154150
) -> Dict[str, str]:
155151
"""Delete records matching the query."""
156152
headers = Transaction._build_transaction_header(transaction)
157153

158154
return self.client._make_request(
159-
"PUT",
160-
"/api/v1/records/delete",
161-
typing.cast(typing.Dict[str, typing.Any], query or {}),
155+
"POST",
156+
"/records/delete",
157+
typing.cast(typing.Dict[str, typing.Any], search_query or {}),
162158
headers,
163159
)
164160

@@ -172,18 +168,18 @@ def delete_by_id(
172168

173169
if isinstance(id_or_ids, list):
174170
return self.client._make_request(
175-
"PUT",
176-
"/api/v1/records/delete",
171+
"POST",
172+
"/records/delete",
177173
{"limit": 1000, "where": {"$id": {"$in": id_or_ids}}},
178174
headers,
179175
)
180176
return self.client._make_request(
181-
"DELETE", f"/api/v1/records/{id_or_ids}", None, headers
177+
"DELETE", f"/records/{id_or_ids}", None, headers
182178
)
183179

184180
def find(
185181
self,
186-
query: Optional[SearchQuery] = None,
182+
search_query: Optional[SearchQuery] = None,
187183
record_id: Optional[str] = None,
188184
transaction: Optional[Transaction] = None,
189185
) -> List[Record]:
@@ -192,15 +188,11 @@ def find(
192188
try:
193189
headers = Transaction._build_transaction_header(transaction)
194190

195-
path = (
196-
f"/api/v1/records/{record_id}/search"
197-
if record_id
198-
else "/api/v1/records/search"
199-
)
191+
path = f"/records/{record_id}/search" if record_id else "/records/search"
200192
response = self.client._make_request(
201193
"POST",
202194
path,
203-
data=typing.cast(typing.Dict[str, typing.Any], query or {}),
195+
data=typing.cast(typing.Dict[str, typing.Any], search_query or {}),
204196
headers=headers,
205197
)
206198
return [Record(self.client, record) for record in response.get("data")]
@@ -224,7 +216,7 @@ def import_csv(
224216
}
225217

226218
return self.client._make_request(
227-
"POST", "/api/v1/records/import/csv", payload, headers
219+
"POST", "/records/import/csv", payload, headers
228220
)
229221

230222
@staticmethod

src/rushdb/api/relationships.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RelationsAPI(BaseAPI):
2020

2121
async def find(
2222
self,
23-
query: Optional[SearchQuery] = None,
23+
search_query: Optional[SearchQuery] = None,
2424
pagination: Optional[PaginationParams] = None,
2525
transaction: Optional[Union[Transaction, str]] = None,
2626
) -> List[Relationship]:
@@ -33,6 +33,9 @@ async def find(
3333
3434
Returns:
3535
List of matching relations
36+
:param transaction:
37+
:param pagination:
38+
:param search_query:
3639
"""
3740
# Build query string for pagination
3841
query_params = {}
@@ -53,7 +56,7 @@ async def find(
5356
response = self.client._make_request(
5457
method="POST",
5558
path=path,
56-
data=typing.cast(typing.Dict[str, typing.Any], query or {}),
59+
data=typing.cast(typing.Dict[str, typing.Any], search_query or {}),
5760
headers=headers,
5861
)
5962

src/rushdb/api/transactions.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ def begin(self, ttl: Optional[int] = None) -> Transaction:
1313
Returns:
1414
Transaction object
1515
"""
16-
response = self.client._make_request("POST", "/api/v1/tx", {"ttl": ttl or 5000})
16+
response = self.client._make_request("POST", "/tx", {"ttl": ttl or 5000})
1717
return Transaction(self.client, response.get("data")["id"])
1818

1919
def _commit(self, transaction_id: str) -> None:
2020
"""Internal method to commit a transaction."""
21-
return self.client._make_request(
22-
"POST", f"/api/v1/tx/{transaction_id}/commit", {}
23-
)
21+
return self.client._make_request("POST", f"/tx/{transaction_id}/commit", {})
2422

2523
def _rollback(self, transaction_id: str) -> None:
2624
"""Internal method to rollback a transaction."""
27-
return self.client._make_request(
28-
"POST", f"/api/v1/tx/{transaction_id}/rollback", {}
29-
)
25+
return self.client._make_request("POST", f"/tx/{transaction_id}/rollback", {})

src/rushdb/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
class RushDB:
1717
"""Main client for interacting with RushDB."""
1818

19-
DEFAULT_BASE_URL = "https://api.rushdb.com"
19+
DEFAULT_BASE_URL = "https://api.rushdb.com/api/v1"
2020

2121
def __init__(self, api_key: str, base_url: Optional[str] = None):
2222
"""Initialize the RushDB client.
2323
2424
Args:
2525
api_key: The API key for authentication
26-
base_url: Optional base URL for the RushDB server (default: https://api.rushdb.com)
26+
base_url: Optional base URL for the RushDB server (default: https://api.rushdb.com/api/v1)
2727
"""
2828
self.base_url = (base_url or self.DEFAULT_BASE_URL).rstrip("/")
2929
self.api_key = api_key

0 commit comments

Comments
 (0)