Skip to content

Remove KV store functionality #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 150,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": true
}
}
}
38 changes: 7 additions & 31 deletions jigsawstack/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,22 @@
from .request import Request, RequestConfig
from .async_request import AsyncRequest, AsyncRequestConfig
from ._config import ClientConfig
from typing import Any, Dict, List, cast
from typing_extensions import NotRequired, TypedDict


class FileDeleteResponse(TypedDict):
success: bool


class KVGetParams(TypedDict):
key: str


class KVGetResponse(TypedDict):
class FileDeleteResponse(TypedDict):
success: bool
value: str


class KVAddParams(TypedDict):
key: str
value: str
encrypt: NotRequired[bool]
byo_secret: NotRequired[str]


class KVAddResponse(TypedDict):
success: bool


class FileUploadParams(TypedDict):
overwrite: bool
filename: str
content_type: NotRequired[str]


class KV(ClientConfig):


config: RequestConfig

Expand Down Expand Up @@ -83,7 +64,6 @@ def delete(self, key: str) -> KVGetResponse:
class Store(ClientConfig):

config: RequestConfig
kv: KV

def __init__(
self,
Expand All @@ -98,8 +78,6 @@ def __init__(
disable_request_logging=disable_request_logging,
)

self.kv = KV(api_key, api_url, disable_request_logging)

def upload(self, file: bytes, options=FileUploadParams) -> Any:
overwrite = options.get("overwrite")
filename = options.get("filename")
Expand All @@ -121,7 +99,7 @@ def upload(self, file: bytes, options=FileUploadParams) -> Any:
return resp

def get(self, key: str) -> Any:
path = f"/store/file/{key}"
path = f"/store/file/read/{key}"
resp = Request(
config=self.config,
path=path,
Expand All @@ -131,7 +109,7 @@ def get(self, key: str) -> Any:
return resp

def delete(self, key: str) -> FileDeleteResponse:
path = f"/store/file/{key}"
path = f"/store/file/read/{key}"
resp = Request(
config=self.config,
path=path,
Expand All @@ -141,7 +119,6 @@ def delete(self, key: str) -> FileDeleteResponse:
return resp


class AsyncKV(ClientConfig):

config: AsyncRequestConfig

Expand Down Expand Up @@ -188,7 +165,6 @@ async def delete(self, key: str) -> KVGetResponse:

class AsyncStore(ClientConfig):
config: AsyncRequestConfig
kv: AsyncKV

def __init__(
self,
Expand All @@ -202,7 +178,7 @@ def __init__(
api_key=api_key,
disable_request_logging=disable_request_logging,
)
self.kv = AsyncKV(api_key, api_url, disable_request_logging)


async def upload(self, file: bytes, options=FileUploadParams) -> Any:
overwrite = options.get("overwrite")
Expand All @@ -225,7 +201,7 @@ async def upload(self, file: bytes, options=FileUploadParams) -> Any:
return resp

async def get(self, key: str) -> Any:
path = f"/store/file/{key}"
path = f"/store/file/read/{key}"
resp = await AsyncRequest(
config=self.config,
path=path,
Expand All @@ -235,7 +211,7 @@ async def get(self, key: str) -> Any:
return resp

async def delete(self, key: str) -> FileDeleteResponse:
path = f"/store/file/{key}"
path = f"/store/file/read/{key}"
resp = AsyncRequest(
config=self.config,
path=path,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="jigsawstack",
version="0.1.29",
version="0.1.30",
description="JigsawStack Python SDK",
long_description=open("README.md", encoding="utf8").read(),
long_description_content_type="text/markdown",
Expand Down
44 changes: 28 additions & 16 deletions tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,41 @@


@pytest.mark.skip(reason="Skipping TestWebAPI class for now")
def test_async_kv_response():
async def _test():
client = AsyncJigsawStack()
try:
result = await client.store.kv.add(
{"key": "hello", "value": "world", "encrypt": False}
)
logger.info(result)
assert result["success"] == True
except JigsawStackError as e:
pytest.fail(f"Unexpected JigsawStackError: {e}")
class TestAsyncFileOperations:
"""
Test class for async file operations.
Add your file operation tests here.
"""

def test_async_file_upload(self):
# Template for future file upload tests
pass

def test_async_file_retrieval(self):
# Template for future file retrieval tests
pass

def test_async_file_deletion(self):
# Template for future file deletion tests
pass

asyncio.run(_test())


def test_async_retriev_kv_response():
# Example file upload test
# Uncomment and modify as needed
"""
def test_async_file_upload_example():
async def _test():
client = AsyncJigsawStack()
try:
result = await client.store.kv.get("hello")
file_content = b"test file content"
result = await client.store.upload(
file_content,
{"filename": "test.txt", "overwrite": True}
)
logger.info(result)
assert result["success"] == True
assert result["success"] == True
except JigsawStackError as e:
pytest.fail(f"Unexpected JigsawStackError: {e}")

asyncio.run(_test())
"""