worqhat 3.9.0__py3-none-any.whl → 4.1.0__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.
Files changed (80) hide show
  1. worqhat/__init__.py +8 -89
  2. worqhat/client.py +62 -0
  3. worqhat/exceptions.py +43 -0
  4. worqhat/http_client.py +171 -0
  5. worqhat/py.typed +1 -0
  6. worqhat/resources/__init__.py +5 -59
  7. worqhat/resources/database.py +293 -0
  8. worqhat/resources/flows.py +61 -409
  9. worqhat/resources/storage.py +41 -431
  10. worqhat-4.1.0.dist-info/METADATA +538 -0
  11. worqhat-4.1.0.dist-info/RECORD +13 -0
  12. {worqhat-3.9.0.dist-info → worqhat-4.1.0.dist-info}/WHEEL +2 -1
  13. worqhat-4.1.0.dist-info/top_level.txt +1 -0
  14. worqhat/_base_client.py +0 -1995
  15. worqhat/_client.py +0 -484
  16. worqhat/_compat.py +0 -219
  17. worqhat/_constants.py +0 -14
  18. worqhat/_exceptions.py +0 -108
  19. worqhat/_files.py +0 -123
  20. worqhat/_models.py +0 -835
  21. worqhat/_qs.py +0 -150
  22. worqhat/_resource.py +0 -43
  23. worqhat/_response.py +0 -830
  24. worqhat/_streaming.py +0 -333
  25. worqhat/_types.py +0 -260
  26. worqhat/_utils/__init__.py +0 -64
  27. worqhat/_utils/_compat.py +0 -45
  28. worqhat/_utils/_datetime_parse.py +0 -136
  29. worqhat/_utils/_logs.py +0 -25
  30. worqhat/_utils/_proxy.py +0 -65
  31. worqhat/_utils/_reflection.py +0 -42
  32. worqhat/_utils/_resources_proxy.py +0 -24
  33. worqhat/_utils/_streams.py +0 -12
  34. worqhat/_utils/_sync.py +0 -86
  35. worqhat/_utils/_transform.py +0 -457
  36. worqhat/_utils/_typing.py +0 -156
  37. worqhat/_utils/_utils.py +0 -421
  38. worqhat/_version.py +0 -4
  39. worqhat/lib/.keep +0 -4
  40. worqhat/resources/db/__init__.py +0 -33
  41. worqhat/resources/db/db.py +0 -800
  42. worqhat/resources/db/tables.py +0 -389
  43. worqhat/resources/health.py +0 -143
  44. worqhat/types/__init__.py +0 -32
  45. worqhat/types/db/__init__.py +0 -10
  46. worqhat/types/db/table_get_row_count_params.py +0 -12
  47. worqhat/types/db/table_get_row_count_response.py +0 -15
  48. worqhat/types/db/table_list_params.py +0 -15
  49. worqhat/types/db/table_list_response.py +0 -26
  50. worqhat/types/db/table_retrieve_schema_params.py +0 -12
  51. worqhat/types/db/table_retrieve_schema_response.py +0 -29
  52. worqhat/types/db_delete_records_params.py +0 -19
  53. worqhat/types/db_delete_records_response.py +0 -18
  54. worqhat/types/db_execute_batch_params.py +0 -36
  55. worqhat/types/db_execute_batch_response.py +0 -27
  56. worqhat/types/db_execute_query_params.py +0 -24
  57. worqhat/types/db_execute_query_response.py +0 -21
  58. worqhat/types/db_insert_record_params.py +0 -19
  59. worqhat/types/db_insert_record_response.py +0 -15
  60. worqhat/types/db_process_nl_query_params.py +0 -19
  61. worqhat/types/db_process_nl_query_response.py +0 -18
  62. worqhat/types/db_update_records_params.py +0 -22
  63. worqhat/types/db_update_records_response.py +0 -18
  64. worqhat/types/flow_get_metrics_params.py +0 -25
  65. worqhat/types/flow_get_metrics_response.py +0 -55
  66. worqhat/types/flow_trigger_with_file_params.py +0 -17
  67. worqhat/types/flow_trigger_with_file_response.py +0 -18
  68. worqhat/types/flow_trigger_with_payload_params.py +0 -13
  69. worqhat/types/flow_trigger_with_payload_response.py +0 -20
  70. worqhat/types/get_server_info_response.py +0 -15
  71. worqhat/types/health_check_response.py +0 -33
  72. worqhat/types/storage_delete_file_by_id_response.py +0 -18
  73. worqhat/types/storage_retrieve_file_by_id_response.py +0 -33
  74. worqhat/types/storage_retrieve_file_by_path_params.py +0 -12
  75. worqhat/types/storage_retrieve_file_by_path_response.py +0 -33
  76. worqhat/types/storage_upload_file_params.py +0 -17
  77. worqhat/types/storage_upload_file_response.py +0 -33
  78. worqhat-3.9.0.dist-info/METADATA +0 -432
  79. worqhat-3.9.0.dist-info/RECORD +0 -73
  80. worqhat-3.9.0.dist-info/licenses/LICENSE +0 -201
worqhat/__init__.py CHANGED
@@ -1,92 +1,11 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1
+ """
2
+ Worqhat Python SDK
2
3
 
3
- import typing as _t
4
+ Official Python SDK for the Worqhat API.
5
+ """
4
6
 
5
- from . import types
6
- from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
7
- from ._utils import file_from_path
8
- from ._client import Client, Stream, Timeout, Worqhat, Transport, AsyncClient, AsyncStream, AsyncWorqhat, RequestOptions
9
- from ._models import BaseModel
10
- from ._version import __title__, __version__
11
- from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
12
- from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
13
- from ._exceptions import (
14
- APIError,
15
- WorqhatError,
16
- ConflictError,
17
- NotFoundError,
18
- APIStatusError,
19
- RateLimitError,
20
- APITimeoutError,
21
- BadRequestError,
22
- APIConnectionError,
23
- AuthenticationError,
24
- InternalServerError,
25
- PermissionDeniedError,
26
- UnprocessableEntityError,
27
- APIResponseValidationError,
28
- )
29
- from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
30
- from ._utils._logs import setup_logging as _setup_logging
7
+ from .client import Worqhat
8
+ from .exceptions import WorqhatError, APIError, AuthenticationError, ValidationError
31
9
 
32
- __all__ = [
33
- "types",
34
- "__version__",
35
- "__title__",
36
- "NoneType",
37
- "Transport",
38
- "ProxiesTypes",
39
- "NotGiven",
40
- "NOT_GIVEN",
41
- "not_given",
42
- "Omit",
43
- "omit",
44
- "WorqhatError",
45
- "APIError",
46
- "APIStatusError",
47
- "APITimeoutError",
48
- "APIConnectionError",
49
- "APIResponseValidationError",
50
- "BadRequestError",
51
- "AuthenticationError",
52
- "PermissionDeniedError",
53
- "NotFoundError",
54
- "ConflictError",
55
- "UnprocessableEntityError",
56
- "RateLimitError",
57
- "InternalServerError",
58
- "Timeout",
59
- "RequestOptions",
60
- "Client",
61
- "AsyncClient",
62
- "Stream",
63
- "AsyncStream",
64
- "Worqhat",
65
- "AsyncWorqhat",
66
- "file_from_path",
67
- "BaseModel",
68
- "DEFAULT_TIMEOUT",
69
- "DEFAULT_MAX_RETRIES",
70
- "DEFAULT_CONNECTION_LIMITS",
71
- "DefaultHttpxClient",
72
- "DefaultAsyncHttpxClient",
73
- "DefaultAioHttpClient",
74
- ]
75
-
76
- if not _t.TYPE_CHECKING:
77
- from ._utils._resources_proxy import resources as resources
78
-
79
- _setup_logging()
80
-
81
- # Update the __module__ attribute for exported symbols so that
82
- # error messages point to this module instead of the module
83
- # it was originally defined in, e.g.
84
- # worqhat._exceptions.NotFoundError -> worqhat.NotFoundError
85
- __locals = locals()
86
- for __name in __all__:
87
- if not __name.startswith("__"):
88
- try:
89
- __locals[__name].__module__ = "worqhat"
90
- except (TypeError, AttributeError):
91
- # Some of our exported symbols are builtins which we can't set attributes for.
92
- pass
10
+ __version__ = "1.0.0"
11
+ __all__ = ["Worqhat", "WorqhatError", "APIError", "AuthenticationError", "ValidationError"]
worqhat/client.py ADDED
@@ -0,0 +1,62 @@
1
+ """Main Worqhat client."""
2
+
3
+ from typing import Optional
4
+
5
+ from .http_client import HTTPClient
6
+ from .resources import DatabaseResource, FlowsResource, StorageResource
7
+
8
+
9
+ class Worqhat:
10
+ """
11
+ Worqhat API client.
12
+
13
+ Example:
14
+ >>> from worqhat import Worqhat
15
+ >>> client = Worqhat(api_key="your-api-key")
16
+ >>> response = client.db.execute_query(query="SELECT * FROM users")
17
+ >>> print(response["data"])
18
+ """
19
+
20
+ def __init__(
21
+ self,
22
+ api_key: Optional[str] = None,
23
+ base_url: str = "https://api.worqhat.app",
24
+ target: Optional[str] = None,
25
+ timeout: int = 60,
26
+ ):
27
+ """
28
+ Initialize the Worqhat client.
29
+
30
+ Args:
31
+ api_key: API key for authentication. Defaults to WORQHAT_API_KEY environment variable.
32
+ base_url: Base URL for the API (default: https://api.worqhat.app).
33
+ target: Backend target ('app' or 'fyi').
34
+ timeout: Request timeout in seconds (default: 60).
35
+
36
+ Raises:
37
+ AuthenticationError: If no API key is provided.
38
+ """
39
+ self._http_client = HTTPClient(
40
+ api_key=api_key, base_url=base_url, target=target, timeout=timeout
41
+ )
42
+
43
+ # Initialize resources
44
+ self.db = DatabaseResource(self._http_client)
45
+ self.flows = FlowsResource(self._http_client)
46
+ self.storage = StorageResource(self._http_client)
47
+
48
+ def close(self) -> None:
49
+ """Close the HTTP client session."""
50
+ self._http_client.close()
51
+
52
+ def __enter__(self) -> "Worqhat":
53
+ """Context manager entry."""
54
+ return self
55
+
56
+ def __exit__(self, *args: object) -> None:
57
+ """Context manager exit."""
58
+ self.close()
59
+
60
+ def __repr__(self) -> str:
61
+ """String representation."""
62
+ return f"Worqhat(base_url='{self._http_client.base_url}')"
worqhat/exceptions.py ADDED
@@ -0,0 +1,43 @@
1
+ """Exception classes for the Worqhat SDK."""
2
+
3
+ from typing import Optional, Dict, Any
4
+
5
+
6
+ class WorqhatError(Exception):
7
+ """Base exception for all Worqhat SDK errors."""
8
+
9
+ def __init__(self, message: str, code: Optional[int] = None, details: Optional[Dict[str, Any]] = None):
10
+ super().__init__(message)
11
+ self.message = message
12
+ self.code = code
13
+ self.details = details or {}
14
+
15
+
16
+ class APIError(WorqhatError):
17
+ """Raised when the API returns an error response."""
18
+
19
+ pass
20
+
21
+
22
+ class AuthenticationError(WorqhatError):
23
+ """Raised when authentication fails."""
24
+
25
+ pass
26
+
27
+
28
+ class ValidationError(WorqhatError):
29
+ """Raised when request validation fails."""
30
+
31
+ pass
32
+
33
+
34
+ class NotFoundError(WorqhatError):
35
+ """Raised when a resource is not found."""
36
+
37
+ pass
38
+
39
+
40
+ class RateLimitError(WorqhatError):
41
+ """Raised when rate limit is exceeded."""
42
+
43
+ pass
worqhat/http_client.py ADDED
@@ -0,0 +1,171 @@
1
+ """HTTP client for making requests to the Worqhat API."""
2
+
3
+ import os
4
+ from typing import Optional, Dict, Any, Union
5
+ import requests
6
+
7
+ from .exceptions import APIError, AuthenticationError, NotFoundError, RateLimitError
8
+
9
+
10
+ class HTTPClient:
11
+ """HTTP client for the Worqhat API."""
12
+
13
+ def __init__(
14
+ self,
15
+ api_key: Optional[str] = None,
16
+ base_url: str = "https://api.worqhat.app",
17
+ target: Optional[str] = None,
18
+ timeout: int = 60,
19
+ ):
20
+ """
21
+ Initialize the HTTP client.
22
+
23
+ Args:
24
+ api_key: API key for authentication. Defaults to WORQHAT_API_KEY environment variable.
25
+ base_url: Base URL for the API.
26
+ target: Backend target ('app' or 'fyi').
27
+ timeout: Request timeout in seconds.
28
+ """
29
+ self.api_key = api_key or os.environ.get("WORQHAT_API_KEY")
30
+ if not self.api_key:
31
+ raise AuthenticationError(
32
+ "API key is required. Provide it via api_key parameter or WORQHAT_API_KEY environment variable."
33
+ )
34
+
35
+ self.base_url = base_url.rstrip("/")
36
+ self.target = target
37
+ self.timeout = timeout
38
+ self.session = requests.Session()
39
+
40
+ # Set default headers
41
+ self.session.headers.update(
42
+ {
43
+ "Authorization": f"Bearer {self.api_key}",
44
+ "Content-Type": "application/json",
45
+ }
46
+ )
47
+
48
+ # Add target header if specified
49
+ if self.target:
50
+ self.session.headers["x-worqhat-target"] = self.target
51
+
52
+ def _handle_error(self, response: requests.Response) -> None:
53
+ """Handle error responses from the API."""
54
+ try:
55
+ error_data = response.json()
56
+ error_message = error_data.get("message", response.text)
57
+ error_code = response.status_code
58
+ except ValueError:
59
+ error_message = response.text
60
+ error_code = response.status_code
61
+
62
+ if response.status_code == 401:
63
+ raise AuthenticationError(error_message, code=error_code)
64
+ elif response.status_code == 404:
65
+ raise NotFoundError(error_message, code=error_code)
66
+ elif response.status_code == 429:
67
+ raise RateLimitError(error_message, code=error_code)
68
+ else:
69
+ raise APIError(error_message, code=error_code)
70
+
71
+ def get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
72
+ """
73
+ Make a GET request.
74
+
75
+ Args:
76
+ path: API endpoint path.
77
+ params: Query parameters.
78
+
79
+ Returns:
80
+ Response data as a dictionary.
81
+ """
82
+ url = f"{self.base_url}{path}"
83
+ response = self.session.get(url, params=params, timeout=self.timeout)
84
+
85
+ if not response.ok:
86
+ self._handle_error(response)
87
+
88
+ return response.json()
89
+
90
+ def post(
91
+ self,
92
+ path: str,
93
+ json: Optional[Dict[str, Any]] = None,
94
+ data: Optional[Any] = None,
95
+ files: Optional[Dict[str, Any]] = None,
96
+ ) -> Dict[str, Any]:
97
+ """
98
+ Make a POST request.
99
+
100
+ Args:
101
+ path: API endpoint path.
102
+ json: JSON data to send.
103
+ data: Form data to send.
104
+ files: Files to upload.
105
+
106
+ Returns:
107
+ Response data as a dictionary.
108
+ """
109
+ url = f"{self.base_url}{path}"
110
+
111
+ # Remove Content-Type header for multipart/form-data
112
+ headers = {}
113
+ if files:
114
+ headers = {"Content-Type": None}
115
+
116
+ response = self.session.post(
117
+ url, json=json, data=data, files=files, headers=headers or None, timeout=self.timeout
118
+ )
119
+
120
+ if not response.ok:
121
+ self._handle_error(response)
122
+
123
+ return response.json()
124
+
125
+ def put(self, path: str, json: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
126
+ """
127
+ Make a PUT request.
128
+
129
+ Args:
130
+ path: API endpoint path.
131
+ json: JSON data to send.
132
+
133
+ Returns:
134
+ Response data as a dictionary.
135
+ """
136
+ url = f"{self.base_url}{path}"
137
+ response = self.session.put(url, json=json, timeout=self.timeout)
138
+
139
+ if not response.ok:
140
+ self._handle_error(response)
141
+
142
+ return response.json()
143
+
144
+ def delete(self, path: str, json: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
145
+ """
146
+ Make a DELETE request.
147
+
148
+ Args:
149
+ path: API endpoint path.
150
+ json: JSON data to send.
151
+
152
+ Returns:
153
+ Response data as a dictionary.
154
+ """
155
+ url = f"{self.base_url}{path}"
156
+ response = self.session.delete(url, json=json, timeout=self.timeout)
157
+
158
+ if not response.ok:
159
+ self._handle_error(response)
160
+
161
+ return response.json()
162
+
163
+ def close(self) -> None:
164
+ """Close the HTTP session."""
165
+ self.session.close()
166
+
167
+ def __enter__(self) -> "HTTPClient":
168
+ return self
169
+
170
+ def __exit__(self, *args: Any) -> None:
171
+ self.close()
worqhat/py.typed CHANGED
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561
@@ -1,61 +1,7 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1
+ """Resources for the Worqhat SDK."""
2
2
 
3
- from .db import (
4
- DBResource,
5
- AsyncDBResource,
6
- DBResourceWithRawResponse,
7
- AsyncDBResourceWithRawResponse,
8
- DBResourceWithStreamingResponse,
9
- AsyncDBResourceWithStreamingResponse,
10
- )
11
- from .flows import (
12
- FlowsResource,
13
- AsyncFlowsResource,
14
- FlowsResourceWithRawResponse,
15
- AsyncFlowsResourceWithRawResponse,
16
- FlowsResourceWithStreamingResponse,
17
- AsyncFlowsResourceWithStreamingResponse,
18
- )
19
- from .health import (
20
- HealthResource,
21
- AsyncHealthResource,
22
- HealthResourceWithRawResponse,
23
- AsyncHealthResourceWithRawResponse,
24
- HealthResourceWithStreamingResponse,
25
- AsyncHealthResourceWithStreamingResponse,
26
- )
27
- from .storage import (
28
- StorageResource,
29
- AsyncStorageResource,
30
- StorageResourceWithRawResponse,
31
- AsyncStorageResourceWithRawResponse,
32
- StorageResourceWithStreamingResponse,
33
- AsyncStorageResourceWithStreamingResponse,
34
- )
3
+ from .database import DatabaseResource
4
+ from .flows import FlowsResource
5
+ from .storage import StorageResource
35
6
 
36
- __all__ = [
37
- "DBResource",
38
- "AsyncDBResource",
39
- "DBResourceWithRawResponse",
40
- "AsyncDBResourceWithRawResponse",
41
- "DBResourceWithStreamingResponse",
42
- "AsyncDBResourceWithStreamingResponse",
43
- "HealthResource",
44
- "AsyncHealthResource",
45
- "HealthResourceWithRawResponse",
46
- "AsyncHealthResourceWithRawResponse",
47
- "HealthResourceWithStreamingResponse",
48
- "AsyncHealthResourceWithStreamingResponse",
49
- "FlowsResource",
50
- "AsyncFlowsResource",
51
- "FlowsResourceWithRawResponse",
52
- "AsyncFlowsResourceWithRawResponse",
53
- "FlowsResourceWithStreamingResponse",
54
- "AsyncFlowsResourceWithStreamingResponse",
55
- "StorageResource",
56
- "AsyncStorageResource",
57
- "StorageResourceWithRawResponse",
58
- "AsyncStorageResourceWithRawResponse",
59
- "StorageResourceWithStreamingResponse",
60
- "AsyncStorageResourceWithStreamingResponse",
61
- ]
7
+ __all__ = ["DatabaseResource", "FlowsResource", "StorageResource"]