(20250210) Worked on the IP addr util a bit.

This commit is contained in:
2025-02-10 19:34:52 +05:30
parent 800d6706ef
commit 95d90e807b
15 changed files with 1918 additions and 10 deletions
+22 -10
View File
@@ -95,13 +95,13 @@ import inspect
# *****************************************************************************************************************
class AsyncRestBase:
class AsyncREST:
def __init__(
self,
http_client: httpx.AsyncClient = None,
debug = True,
debug_prefix = "GMail | ",
debug_prefix = "REST (C) | ",
debug_only_errors = True
):
@@ -155,7 +155,8 @@ class AsyncRestBase:
self,
url: str,
headers: dict = None,
params: dict = None
params: dict = None,
auth: httpx.Auth = None
) -> ApiResponse:
"""
@@ -163,6 +164,7 @@ class AsyncRestBase:
:param url: The URL to call.
:param headers: The headers to pass.
:param params: The params to send in the query string itself.
:param auth: Any authentication credentials that need to be sent.
:return: A structured response that includes the raw response, the exception (if any), and so on.
"""
@@ -179,7 +181,8 @@ class AsyncRestBase:
response = await self._http_client.get(
url = url,
headers = headers,
params = params
params = params,
auth = auth
)
# Note down the results:
@@ -202,7 +205,8 @@ class AsyncRestBase:
headers: dict = None,
json: dict = None,
data: dict = None,
content: str | bytes = None
content: str | bytes = None,
auth: httpx.Auth = None
) -> ApiResponse:
"""
@@ -212,6 +216,7 @@ class AsyncRestBase:
:param json: The params to send in the JSON body.
:param data: The params to send in the form-data in the body.
:param content: The raw content to be sent in the body (typically as an octet-stream).
:param auth: Any authentication credentials that need to be sent.
:return: A structured response that includes the raw response, the exception (if any), and so on.
"""
@@ -230,7 +235,8 @@ class AsyncRestBase:
headers = headers,
json = json,
data = data,
content = content
content = content,
auth = auth
)
# Note down the results:
@@ -252,7 +258,8 @@ class AsyncRestBase:
url: str,
headers: dict = None,
json: dict = None,
data: dict = None
data: dict = None,
auth: httpx.Auth = None
) -> ApiResponse:
"""
@@ -261,6 +268,7 @@ class AsyncRestBase:
:param headers: The headers to pass.
:param json: The params to send in the JSON body.
:param data: The params to send in the form-data in the body.
:param auth: Any authentication credentials that need to be sent.
:return: A structured response that includes the raw response, the exception (if any), and so on.
"""
@@ -278,7 +286,8 @@ class AsyncRestBase:
url = url,
headers = headers,
json = json,
data = data
data = data,
auth = auth
)
# Note down the results:
@@ -298,13 +307,15 @@ class AsyncRestBase:
async def delete(
self,
url: str,
headers: dict = None
headers: dict = None,
auth: httpx.Auth = None
) -> ApiResponse:
"""
To call an API using the DELETE method.
:param url: The URL to call.
:param headers: The headers to pass.
:param auth: Any authentication credentials that need to be sent.
:return: A structured response that includes the raw response, the exception (if any), and so on.
"""
@@ -320,7 +331,8 @@ class AsyncRestBase:
# Make the API call:
response = await self._http_client.delete(
url = url,
headers = headers
headers = headers,
auth = auth
)
# Note down the results: