alfred-python 0.5.0__tar.gz → 0.6.0__tar.gz

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 (39) hide show
  1. {alfred_python-0.5.0 → alfred_python-0.6.0}/PKG-INFO +18 -2
  2. {alfred_python-0.5.0 → alfred_python-0.6.0}/README.md +17 -1
  3. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/realtime/__init__.py +13 -5
  4. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/jobs/base.py +10 -0
  5. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/jobs/v1.py +16 -0
  6. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred_python.egg-info/PKG-INFO +18 -2
  7. {alfred_python-0.5.0 → alfred_python-0.6.0}/pyproject.toml +1 -1
  8. {alfred_python-0.5.0 → alfred_python-0.6.0}/LICENSE +0 -0
  9. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/__init__.py +0 -0
  10. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/base/__init__.py +0 -0
  11. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/base/config.py +0 -0
  12. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/base/constants.py +0 -0
  13. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/base/exceptions.py +0 -0
  14. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/exceptions/__init__.py +0 -0
  15. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/http/__init__.py +0 -0
  16. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/http/http_client.py +0 -0
  17. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/http/typed.py +0 -0
  18. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/__init__.py +0 -0
  19. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/data_points/__init__.py +0 -0
  20. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/data_points/base.py +0 -0
  21. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/data_points/v1.py +0 -0
  22. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/files/__init__.py +0 -0
  23. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/files/base.py +0 -0
  24. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/files/typed.py +0 -0
  25. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/files/v1.py +0 -0
  26. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/jobs/__init__.py +0 -0
  27. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/jobs/typed.py +0 -0
  28. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/sessions/__init__.py +0 -0
  29. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/sessions/base.py +0 -0
  30. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/rest/sessions/v1.py +0 -0
  31. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/typings/__init__.py +0 -0
  32. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/typings/misc.py +0 -0
  33. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/utils/__init__.py +0 -0
  34. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred/utils/logging.py +0 -0
  35. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred_python.egg-info/SOURCES.txt +0 -0
  36. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred_python.egg-info/dependency_links.txt +0 -0
  37. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred_python.egg-info/requires.txt +0 -0
  38. {alfred_python-0.5.0 → alfred_python-0.6.0}/alfred_python.egg-info/top_level.txt +0 -0
  39. {alfred_python-0.5.0 → alfred_python-0.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: alfred-python
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Python library designed to simplify and streamline interactions with the Alfred API
5
5
  Author-email: Tagshelf LLC <support@tagshelf.com>
6
6
  License: Copyright (c) 2018 The Python Packaging Authority
@@ -92,6 +92,16 @@ result = client.jobs.get("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
92
92
  print(result)
93
93
  ```
94
94
 
95
+ #### Get paginated jobs
96
+
97
+ ```python
98
+ # Get paginated jobs
99
+ response = client.jobs.get_all(page_size=None, current_page=None)
100
+ print(response.is_empty)
101
+ print(response.result)
102
+ print(response.total)
103
+ ```
104
+
95
105
  #### Create job
96
106
 
97
107
  ```python
@@ -227,7 +237,13 @@ auth_config = AuthConfiguration({
227
237
  "api_key": "AXXXXXXXXXXXXXXXXXXXXXX"
228
238
  })
229
239
 
230
- client = AlfredRealTimeClient(config, auth_config, verbose=True)
240
+ client = AlfredRealTimeClient(
241
+ config,
242
+ auth_config,
243
+ verbose=False,
244
+ on_callback=None,
245
+ on_connect=None
246
+ )
231
247
  ```
232
248
 
233
249
  ### File Events
@@ -55,6 +55,16 @@ result = client.jobs.get("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
55
55
  print(result)
56
56
  ```
57
57
 
58
+ #### Get paginated jobs
59
+
60
+ ```python
61
+ # Get paginated jobs
62
+ response = client.jobs.get_all(page_size=None, current_page=None)
63
+ print(response.is_empty)
64
+ print(response.result)
65
+ print(response.total)
66
+ ```
67
+
58
68
  #### Create job
59
69
 
60
70
  ```python
@@ -190,7 +200,13 @@ auth_config = AuthConfiguration({
190
200
  "api_key": "AXXXXXXXXXXXXXXXXXXXXXX"
191
201
  })
192
202
 
193
- client = AlfredRealTimeClient(config, auth_config, verbose=True)
203
+ client = AlfredRealTimeClient(
204
+ config,
205
+ auth_config,
206
+ verbose=False,
207
+ on_callback=None,
208
+ on_connect=None
209
+ )
194
210
  ```
195
211
 
196
212
  ### File Events
@@ -13,7 +13,7 @@ from alfred.utils import logging, setup_logger
13
13
 
14
14
 
15
15
  class AlfredRealTimeClient:
16
- def __init__(self, config: ConfigurationDict, auth_config: AuthConfiguration, verbose=False):
16
+ def __init__(self, config: ConfigurationDict, auth_config: AuthConfiguration, verbose=False, error_callback=None, on_connect=None):
17
17
  """
18
18
  Initializes the AlfredRealTimeClient class.
19
19
 
@@ -27,6 +27,8 @@ class AlfredRealTimeClient:
27
27
  self.config = config
28
28
  self.auth_config = auth_config
29
29
  self.base_url = config.get("realtime_url")
30
+ self.error_callback = error_callback
31
+ self.on_connect = on_connect
30
32
 
31
33
  # Initialize logger
32
34
  self.logger = logging.getLogger("alfred-python")
@@ -35,7 +37,6 @@ class AlfredRealTimeClient:
35
37
  "level": "DEBUG" if verbose else "INFO",
36
38
  "name": "alfred-python"
37
39
  })
38
- print(self.logger.level)
39
40
 
40
41
  # Subscribe to connection life-cycle events.
41
42
  self.socket.on('connect', self.__on_connect)
@@ -55,12 +56,15 @@ class AlfredRealTimeClient:
55
56
  Handles the 'connect' event.
56
57
  """
57
58
  self.logger.info(f"Successfully connected to: {self.base_url}")
59
+ if self.on_connect:
60
+ self.on_connect()
58
61
 
59
62
  def __on_disconnect(self):
60
63
  """
61
64
  Handles the 'disconnect' event.
62
65
  """
63
- self.logger.info("Disconnected from the server.")
66
+ if self.verbose:
67
+ self.logger.info("Disconnected from the server.")
64
68
 
65
69
  def __on_connect_error(self, err):
66
70
  """
@@ -69,9 +73,12 @@ class AlfredRealTimeClient:
69
73
  Args:
70
74
  err (str): The error message.
71
75
  """
72
- self.logger.info("Connection error: %s", err)
76
+ if self.verbose:
77
+ self.logger.error("Connection error: %s", err)
73
78
  self.disconnect()
74
- raise Exception(f"Failed to connect to {self.base_url}: {err}")
79
+ # trigger error callback:
80
+ if self.error_callback:
81
+ self.error_callback(err)
75
82
 
76
83
  def __callback(self, event: Union[FileEvent, JobEvent, EventType], callback):
77
84
  """
@@ -122,3 +129,4 @@ class AlfredRealTimeClient:
122
129
  """
123
130
  self.logger.info("Closing connection...")
124
131
  self.socket.disconnect()
132
+
@@ -22,3 +22,13 @@ class JobsBase(ABC):
22
22
  Args:
23
23
  - job_id: Unique identifier of the Job.
24
24
  """
25
+
26
+ @abstractmethod
27
+ def get_all(self, page_size: int = None, current_page: int = None) -> Any:
28
+ """
29
+ Fetches all jobs for a company
30
+
31
+ Args:
32
+ - page_size: Number of jobs to fetch per page.
33
+ - current_page: Page number to fetch.
34
+ """
@@ -30,3 +30,19 @@ class Jobs(JobsBase):
30
30
  """
31
31
  parsed_resp, _ = self.http_client.get(f"/api/job/detail/{job_id}")
32
32
  return parsed_resp
33
+
34
+ def get_all(self, page_size: int = None, current_page: int = None):
35
+ """
36
+ Fetches all jobs for a company
37
+
38
+ Args:
39
+ - page_size: Number of jobs to fetch per page.
40
+ - current_page: Page number to fetch.
41
+ """
42
+ params = {}
43
+ if page_size:
44
+ params["pageSize"] = page_size
45
+ if current_page:
46
+ params["currentPage"] = current_page
47
+ parsed_resp, _ = self.http_client.get("/api/job/all", params=params)
48
+ return parsed_resp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: alfred-python
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Python library designed to simplify and streamline interactions with the Alfred API
5
5
  Author-email: Tagshelf LLC <support@tagshelf.com>
6
6
  License: Copyright (c) 2018 The Python Packaging Authority
@@ -92,6 +92,16 @@ result = client.jobs.get("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
92
92
  print(result)
93
93
  ```
94
94
 
95
+ #### Get paginated jobs
96
+
97
+ ```python
98
+ # Get paginated jobs
99
+ response = client.jobs.get_all(page_size=None, current_page=None)
100
+ print(response.is_empty)
101
+ print(response.result)
102
+ print(response.total)
103
+ ```
104
+
95
105
  #### Create job
96
106
 
97
107
  ```python
@@ -227,7 +237,13 @@ auth_config = AuthConfiguration({
227
237
  "api_key": "AXXXXXXXXXXXXXXXXXXXXXX"
228
238
  })
229
239
 
230
- client = AlfredRealTimeClient(config, auth_config, verbose=True)
240
+ client = AlfredRealTimeClient(
241
+ config,
242
+ auth_config,
243
+ verbose=False,
244
+ on_callback=None,
245
+ on_connect=None
246
+ )
231
247
  ```
232
248
 
233
249
  ### File Events
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "alfred-python"
7
- version = "0.5.0"
7
+ version = "0.6.0"
8
8
  authors = [{ name = "Tagshelf LLC", email = "support@tagshelf.com" }]
9
9
  description = "Python library designed to simplify and streamline interactions with the Alfred API"
10
10
  readme = "README.md"
File without changes
File without changes