rdf4j-python 0.1.4__py3-none-any.whl → 0.1.5__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.
- rdf4j_python/_client/_client.py +24 -2
- rdf4j_python/_driver/_async_repository.py +2 -1
- rdf4j_python/model/repository_config.py +13 -926
- rdf4j_python-0.1.5.dist-info/METADATA +259 -0
- {rdf4j_python-0.1.4.dist-info → rdf4j_python-0.1.5.dist-info}/RECORD +8 -8
- rdf4j_python-0.1.4.dist-info/METADATA +0 -80
- {rdf4j_python-0.1.4.dist-info → rdf4j_python-0.1.5.dist-info}/WHEEL +0 -0
- {rdf4j_python-0.1.4.dist-info → rdf4j_python-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {rdf4j_python-0.1.4.dist-info → rdf4j_python-0.1.5.dist-info}/top_level.txt +0 -0
rdf4j_python/_client/_client.py
CHANGED
|
@@ -42,6 +42,17 @@ class BaseClient:
|
|
|
42
42
|
class SyncApiClient(BaseClient):
|
|
43
43
|
"""Synchronous API client using httpx.Client."""
|
|
44
44
|
|
|
45
|
+
def __init__(self, base_url: str, timeout: int = 10):
|
|
46
|
+
"""
|
|
47
|
+
Initializes the SyncApiClient.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
base_url (str): The base URL for the API endpoints.
|
|
51
|
+
timeout (int, optional): Request timeout in seconds. Defaults to 10.
|
|
52
|
+
"""
|
|
53
|
+
super().__init__(base_url, timeout)
|
|
54
|
+
self.client = httpx.Client(timeout=self.timeout)
|
|
55
|
+
|
|
45
56
|
def __enter__(self):
|
|
46
57
|
"""
|
|
47
58
|
Enters the context and initializes the HTTP client.
|
|
@@ -49,7 +60,7 @@ class SyncApiClient(BaseClient):
|
|
|
49
60
|
Returns:
|
|
50
61
|
SyncApiClient: The instance of the client.
|
|
51
62
|
"""
|
|
52
|
-
self.client
|
|
63
|
+
self.client.__enter__()
|
|
53
64
|
return self
|
|
54
65
|
|
|
55
66
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
@@ -142,6 +153,17 @@ class SyncApiClient(BaseClient):
|
|
|
142
153
|
class AsyncApiClient(BaseClient):
|
|
143
154
|
"""Asynchronous API client using httpx.AsyncClient."""
|
|
144
155
|
|
|
156
|
+
def __init__(self, base_url: str, timeout: int = 10):
|
|
157
|
+
"""
|
|
158
|
+
Initializes the AsyncApiClient.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
base_url (str): The base URL for the API endpoints.
|
|
162
|
+
timeout (int, optional): Request timeout in seconds. Defaults to 10.
|
|
163
|
+
"""
|
|
164
|
+
super().__init__(base_url, timeout)
|
|
165
|
+
self.client = httpx.AsyncClient(timeout=self.timeout)
|
|
166
|
+
|
|
145
167
|
async def __aenter__(self):
|
|
146
168
|
"""
|
|
147
169
|
Enters the async context and initializes the HTTP client.
|
|
@@ -149,7 +171,7 @@ class AsyncApiClient(BaseClient):
|
|
|
149
171
|
Returns:
|
|
150
172
|
AsyncApiClient: The instance of the client.
|
|
151
173
|
"""
|
|
152
|
-
|
|
174
|
+
await self.client.__aenter__()
|
|
153
175
|
return self
|
|
154
176
|
|
|
155
177
|
async def __aexit__(self, exc_type, exc_value, traceback):
|
|
@@ -100,7 +100,8 @@ class AsyncRdf4JRepository:
|
|
|
100
100
|
RepositoryNotFoundException: If the repository doesn't exist.
|
|
101
101
|
httpx.HTTPStatusError: If the update fails.
|
|
102
102
|
"""
|
|
103
|
-
#
|
|
103
|
+
# SPARQL UPDATE operations return HTTP 204 No Content on success.
|
|
104
|
+
# No result data is returned as per SPARQL 1.1 UPDATE specification.
|
|
104
105
|
path = f"/repositories/{self._repository_id}/statements"
|
|
105
106
|
headers = {"Content-Type": content_type}
|
|
106
107
|
response = await self._client.post(
|