Skip to content
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

v0.4.0.dev9 #17

Merged
merged 6 commits into from
Nov 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion pkgs/crouton/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "crouton"
version = "0.0.4.dev8"
version = "0.0.4.dev9"
description = "A repository to enable API CRUD Routing"
authors = ["Jacob Stewart <[email protected]>"]
license = "Apache-2.0"
Expand Down
14 changes: 6 additions & 8 deletions pkgs/crouton_client/crouton_client/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ async def _build_url(self, resource: str, item_id: Optional[str] = None, query_p

return url

async def get(
async def aget(
self,
resource: str,
item_id: Optional[str] = None,
filter_key: Optional[str] = None,
filter_value: Optional[str] = None
filters: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""
Perform an asynchronous GET request with optional filters and an item ID.
"""
query_params = {filter_key: filter_value} if filter_key and filter_value else None
url = await self._build_url(resource, item_id, query_params)
url = await self._build_url(resource, item_id, filters)

logger.info(f"Performing GET request to {url}")
async with aiohttp.ClientSession() as session:
Expand All @@ -58,7 +56,7 @@ async def get(
logger.error(f"GET request failed with status {res.status}: {error_content}")
raise ValueError(f"GET request failed with status {res.status}: {error_content}")

async def post(self, resource: str, data_obj: Dict[str, Any]) -> Dict[str, Any]:
async def apost(self, resource: str, data_obj: Dict[str, Any]) -> Dict[str, Any]:
"""
Perform an asynchronous POST request to create a resource.
"""
Expand All @@ -77,7 +75,7 @@ async def post(self, resource: str, data_obj: Dict[str, Any]) -> Dict[str, Any]:
logger.error(f"POST request failed with status {res.status}: {error_content}")
raise ValueError(f"POST request failed with status {res.status}: {error_content}")

async def put(self, resource: str, data_obj: Dict[str, Any], item_id: Optional[str] = None) -> Dict[str, Any]:
async def aput(self, resource: str, data_obj: Dict[str, Any], item_id: Optional[str] = None) -> Dict[str, Any]:
"""
Perform an asynchronous PUT request to update a resource.
"""
Expand All @@ -93,7 +91,7 @@ async def put(self, resource: str, data_obj: Dict[str, Any], item_id: Optional[s
logger.error(f"PUT request failed with status {res.status}: {error_content}")
raise ValueError(f"PUT request failed with status {res.status}: {error_content}")

async def delete(self, resource: str, item_id: Optional[str] = None) -> Dict[str, Any]:
async def adelete(self, resource: str, item_id: Optional[str] = None) -> Dict[str, Any]:
"""
Perform an asynchronous DELETE request to delete a resource.
"""
Expand Down
8 changes: 4 additions & 4 deletions pkgs/crouton_client/crouton_client/blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _build_url(self, resource: str, item_id: Optional[str] = None, query_params:

return url

def api_get_call(
def get(
self,
resource: str,
item_id: Optional[str] = None,
Expand All @@ -54,7 +54,7 @@ def api_get_call(
logger.error(f"GET request failed with status {res.status_code}: {res.text}")
raise ValueError(f"GET request failed with status {res.status_code}: {res.text}")

def api_post_call(self, resource: str, data_obj: dict) -> dict:
def post(self, resource: str, data_obj: dict) -> dict:
"""
Perform a POST request to create a resource.
"""
Expand All @@ -71,7 +71,7 @@ def api_post_call(self, resource: str, data_obj: dict) -> dict:
logger.error(f"POST request failed with status {res.status_code}: {res.text}")
raise ValueError(f"POST request failed with status {res.status_code}: {res.text}")

def api_put_call(self, resource: str, data_obj: dict, item_id: str) -> dict:
def put(self, resource: str, data_obj: dict, item_id: str) -> dict:
"""
Perform a PUT request to update a resource.
"""
Expand All @@ -85,7 +85,7 @@ def api_put_call(self, resource: str, data_obj: dict, item_id: str) -> dict:
logger.error(f"PUT request failed with status {res.status_code}: {res.text}")
raise ValueError(f"PUT request failed with status {res.status_code}: {res.text}")

def api_delete_call(self, resource: str, item_id: Optional[str] = None) -> dict:
def delete(self, resource: str, item_id: Optional[str] = None) -> dict:
"""
Perform a DELETE request to delete a resource.
"""
Expand Down
2 changes: 1 addition & 1 deletion pkgs/crouton_client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "crouton_client"
version = "0.0.4.dev8"
version = "0.0.4.dev9"
description = "A client for Swarmauri's crouton."
authors = ["Jacob Stewart <[email protected]>"]
license = "Apache-2.0"
Expand Down