Skip to content

Commit 38c5562

Browse files
jigsawstack-python updates:
1. Merged KV removal PR. 2. Fixed KV removal bug. 3. Updated validate.nsfw to accept valid params. 4. Tested all endpoints, to match jigsawstack & documentation.
1 parent cb89e5e commit 38c5562

File tree

2 files changed

+5
-93
lines changed

2 files changed

+5
-93
lines changed

jigsawstack/store.py

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,6 @@ class FileUploadParams(TypedDict):
1717
filename: str
1818
content_type: NotRequired[str]
1919

20-
21-
22-
23-
config: RequestConfig
24-
25-
def __init__(
26-
self,
27-
api_key: str,
28-
api_url: str,
29-
disable_request_logging: Union[bool, None] = False,
30-
):
31-
super().__init__(api_key, api_url, disable_request_logging)
32-
self.config = RequestConfig(
33-
api_url=api_url,
34-
api_key=api_key,
35-
disable_request_logging=disable_request_logging,
36-
)
37-
38-
def add(self, params: KVAddParams) -> KVAddResponse:
39-
path = "/store/kv"
40-
resp = Request(
41-
config=self.config,
42-
path=path,
43-
params=cast(Dict[Any, Any], params),
44-
verb="post",
45-
).perform_with_content()
46-
return resp
47-
48-
def get(self, key: str) -> KVGetResponse:
49-
path = f"/store/kv/{key}"
50-
resp = Request(config=self.config, path=path, verb="get").perform_with_content()
51-
return resp
52-
53-
def delete(self, key: str) -> KVGetResponse:
54-
path = f"/store/kv/{key}"
55-
resp = Request(
56-
config=self.config,
57-
path=path,
58-
params=cast(Dict[Any, Any], params={}),
59-
verb="delete",
60-
).perform_with_content()
61-
return resp
62-
63-
6420
class Store(ClientConfig):
6521

6622
config: RequestConfig
@@ -113,51 +69,7 @@ def delete(self, key: str) -> FileDeleteResponse:
11369
resp = Request(
11470
config=self.config,
11571
path=path,
116-
params=cast(Dict[Any, Any], params={}),
117-
verb="delete",
118-
).perform_with_content()
119-
return resp
120-
121-
122-
123-
config: AsyncRequestConfig
124-
125-
def __init__(
126-
self,
127-
api_key: str,
128-
api_url: str,
129-
disable_request_logging: Union[bool, None] = False,
130-
):
131-
super().__init__(api_key, api_url, disable_request_logging)
132-
self.config = AsyncRequestConfig(
133-
api_url=api_url,
134-
api_key=api_key,
135-
disable_request_logging=disable_request_logging,
136-
)
137-
138-
async def add(self, params: KVAddParams) -> KVAddResponse:
139-
path = "/store/kv"
140-
resp = await AsyncRequest(
141-
config=self.config,
142-
path=path,
143-
params=cast(Dict[Any, Any], params),
144-
verb="post",
145-
).perform_with_content()
146-
return resp
147-
148-
async def get(self, key: str) -> KVGetResponse:
149-
path = f"/store/kv/{key}"
150-
resp = await AsyncRequest(
151-
config=self.config, path=path, verb="get", params={}
152-
).perform_with_content()
153-
return resp
154-
155-
async def delete(self, key: str) -> KVGetResponse:
156-
path = f"/store/kv/{key}"
157-
resp = await AsyncRequest(
158-
config=self.config,
159-
path=path,
160-
params=cast(Dict[Any, Any], params={}),
72+
params=key,
16173
verb="delete",
16274
).perform_with_content()
16375
return resp

jigsawstack/validate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ def email(self, params: EmailValidationParams) -> EmailValidationResponse:
9696
).perform_with_content()
9797
return resp
9898

99-
def nsfw(self, url: str) -> NSFWResponse:
99+
def nsfw(self, params: NSFWParams) -> NSFWResponse:
100100
path = f"/validate/nsfw"
101101
resp = Request(
102102
config=self.config,
103103
path=path,
104104
params=cast(
105105
Dict[Any, Any],
106-
params={"url": url},
106+
params
107107
),
108108
verb="post",
109109
).perform_with_content()
@@ -174,14 +174,14 @@ async def email(self, params: EmailValidationParams) -> EmailValidationResponse:
174174
).perform_with_content()
175175
return resp
176176

177-
async def nsfw(self, url: str) -> NSFWResponse:
177+
async def nsfw(self, params: NSFWParams) -> NSFWResponse:
178178
path = f"/validate/nsfw"
179179
resp = await AsyncRequest(
180180
config=self.config,
181181
path=path,
182182
params=cast(
183183
Dict[Any, Any],
184-
params={"url": url},
184+
params,
185185
),
186186
verb="post",
187187
).perform_with_content()

0 commit comments

Comments
 (0)