python-eigen-ingenuity 0.5.24b2__py3-none-any.whl → 0.5.25__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.
eigeningenuity/elastic.py CHANGED
@@ -36,7 +36,14 @@ class ElasticConnection(object):
36
36
  """An elasticsearch instance which talks the Eigen elastic endpoint."""
37
37
 
38
38
  def __init__(self, baseurl, auth):
39
- """This is a constructor. It takes in a URL like http://infra:8080/ei-applet/search/"""
39
+ """Constructor for ElasticConnection.
40
+
41
+ Args:
42
+ baseurl: The base URL for the Elastic endpoint, e.g., http://infra:8080/ei-applet/search/
43
+ auth: Authentication object for the connection.
44
+
45
+ Docs: https://docs.eigeningenuity.co/developing-with-eigen/python-library/elastic/overview/
46
+ """
40
47
  self.baseurl = baseurl
41
48
  self.auth = auth
42
49
 
@@ -78,7 +85,7 @@ class ElasticConnection(object):
78
85
  return status
79
86
 
80
87
  def listIndices(self, instance: str, wildcard: str = None):
81
- """Lists all indices in Elastic Database.
88
+ """Deprecated: Lists all indices in Elastic Database.
82
89
 
83
90
  Args:
84
91
  instance: The elasticsearch instance to query indices from.
@@ -86,6 +93,8 @@ class ElasticConnection(object):
86
93
 
87
94
  Returns:
88
95
  List of all indices
96
+
97
+ Docs: https://docs.eigeningenuity.co/developing-with-eigen/python-library/elastic/overview/
89
98
  """
90
99
 
91
100
  args = {"clientname": instance}
@@ -100,7 +109,7 @@ class ElasticConnection(object):
100
109
  return indices
101
110
 
102
111
  def checkIndices(self, instance: str, indices: str):
103
- """Checks for indices in Elastic Database.
112
+ """Deprecated: Checks for indices in Elastic Database.
104
113
 
105
114
  Args:
106
115
  instance: The elasticsearch instance to query instances from.
@@ -108,6 +117,8 @@ class ElasticConnection(object):
108
117
 
109
118
  Returns:
110
119
  Boolean indicating existence of the index, or dict of form {index: boolean}
120
+
121
+ Docs: https://docs.eigeningenuity.co/developing-with-eigen/python-library/elastic/overview/
111
122
  """
112
123
 
113
124
  foundIndices = self.listIndices(instance)
@@ -137,7 +148,7 @@ class ElasticConnection(object):
137
148
  output: str = "json",
138
149
  filepath: str = None,
139
150
  ):
140
- """Executes a raw cypher query against Elastic.
151
+ """Deprecated: Executes a raw cypher query against Elastic.
141
152
 
142
153
  Args:
143
154
  index: The elasticsearch index to query
@@ -148,6 +159,8 @@ class ElasticConnection(object):
148
159
 
149
160
  Returns:
150
161
  Elasticsearch API response to the query, the format is dependent on the output parameter
162
+
163
+ Docs: https://docs.eigeningenuity.co/developing-with-eigen/python-library/elastic/overview/
151
164
  """
152
165
  # self._testConnection(instance,index)
153
166
  validOutputTypes = ["raw", "json", "df", "file"]
@@ -186,13 +199,15 @@ class ElasticConnection(object):
186
199
 
187
200
 
188
201
  def get_elastic(eigenserver: EigenServer = None):
189
- """Instantiate an elasticsearch connection for the given EigenServer.
202
+ """Deprecated: Instantiate an elasticsearch connection for the given EigenServer.
190
203
 
191
204
  Args:
192
205
  eigenserver: (Optional) An EigenServer Object linked to the ingenuity url containing the elasticsearch. Can be omitted if environmental variable "EIGENSERVER" exists and is equal to the Ingenuity base url
193
206
 
194
207
  Returns:
195
208
  An Object that can be used to query elasticsearch data from the ingenuity.
209
+
210
+ Docs: https://docs.eigeningenuity.co/developing-with-eigen/python-library/elastic/overview/
196
211
  """
197
212
  warnings.warn(
198
213
  "The Elastic module is deprecated and will be removed in future releases, please use eventlog instead",
eigeningenuity/events.py CHANGED
@@ -50,27 +50,24 @@ class EventLog(object):
50
50
  def getEvents(
51
51
  self, query: dict, eventlog: str = "default", size: int = 1000, page: int = 0
52
52
  ) -> list:
53
- """
54
- Execute a raw query against the ingenuity eventlog
53
+ """Execute a raw query against the eventlog.
55
54
 
56
55
  Args:
57
- query: A dictionary containing the query structure with the following format:
58
- - start (required): Start time (e.g., "yesterday", SO datetime string, python datetime object)
59
- - end (required): End time (e.g., "now", SO datetime string, python datetime object)
60
- - severities (optional): List of severity levels (e.g., ["INFO", "WARNING"])
61
- - types (optional): List of event types (e.g., ["DataTagThresholdCheck"]). Exact matches only. API fails to parse certain characters like '-'
62
- - sources (optional): List of source identifiers. Allows partial matches
63
- - messages (optional): List of message types. Allows partial matches
64
- - assetNames (optional): List of asset names
65
- - contentFilter (optional): Additional filter string. Uses Elasticsearch Query String syntax e.g. (fieldName1 = value1 AND fieldName2 = value2) AND (fieldName3 = b OR fieldName4 = d)
66
- size: Maximum number of results to return (default: 1000)
67
- page: Page number for pagination (default: 0)
56
+ query (dict): Eventlog query dictionary with required `start` and `end`, and optional filters.
57
+ eventlog (str, optional): Eventlog name to query. Defaults to "default".
58
+ size (int, optional): Maximum number of results returned. Defaults to 1000.
59
+ page (int, optional): Page number for pagination. Defaults to 0.
68
60
 
69
61
  Returns:
70
- The response from ingenuity, typically a list of dictionaries
62
+ list: Events matching the query.
71
63
 
72
64
  Raises:
73
- ValueError: If required fields are missing or invalid
65
+ ValueError: If required fields are missing or invalid.
66
+ URLError: If no Ingenuity instance can be reached or no internet connection is available.
67
+ HTTPError: If the API request fails.
68
+
69
+ Docs:
70
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/get-events
74
71
  """
75
72
 
76
73
  if eventlog == "default":
@@ -97,23 +94,28 @@ class EventLog(object):
97
94
  size: int = 1000,
98
95
  page: int = 0,
99
96
  ) -> list:
100
- """
101
- Retrieve events from the ingenuity eventlog filtered by source
97
+ """Retrieve events filtered by source.
102
98
 
103
99
  Args:
104
- source: The source identifier to filter events by (string)
105
- exact_match: If True, only return events with an exact match on source. If False, allows partial matches (default: False)
106
- start: Start time (e.g., "yesterday", SO datetime string, python datetime object)
107
- end: End time (e.g., "now", SO datetime string, python datetime object)
108
- filter: Additional filter string. Uses Elasticsearch Query String syntax e.g. (fieldName1 = value1 AND fieldName2 = value2) AND (fieldName3 = b OR fieldName4 = d) (default: None)
109
- size: Maximum number of results to return (default: 1000)
110
- page: Page number for pagination (default: 0)
100
+ source (Union[str, list]): Source identifier(s) to filter by. Allows partial matches.
101
+ eventlog (str, optional): Eventlog name to query. Defaults to "default".
102
+ exact_match (bool, optional): If True, only exact matches on source. Defaults to False.
103
+ start (Union[str, datetime], optional): Start time. Defaults to "yesterday".
104
+ end (Union[str, datetime], optional): End time. Defaults to "now".
105
+ filter (str, optional): Additional filter using Elasticsearch Query String syntax. Defaults to None.
106
+ size (int, optional): Maximum number of results returned. Defaults to 1000.
107
+ page (int, optional): Page number for pagination. Defaults to 0.
111
108
 
112
109
  Returns:
113
- The response from ingenuity, typically a list of dictionaries
110
+ list: Events matching the source.
114
111
 
115
112
  Raises:
116
- ValueError: If the source is not provided
113
+ ValueError: If the source is not provided.
114
+ URLError: If no Ingenuity instance can be reached or no internet connection is available.
115
+ HTTPError: If the API request fails.
116
+
117
+ Docs:
118
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/get-events-by-source
117
119
  """
118
120
  if not source or not isinstance(source, (str, list)):
119
121
  raise ValueError("Source must be a non-empty string or list")
@@ -157,22 +159,27 @@ class EventLog(object):
157
159
  size: int = 1000,
158
160
  page: int = 0,
159
161
  ) -> list:
160
- """
161
- Retrieve events from the ingenuity eventlog filtered by event type
162
+ """Retrieve events filtered by event type.
162
163
 
163
164
  Args:
164
- event_type: The event type to filter events by (string)
165
- start: Start time (e.g., "yesterday", ISO datetime string, python datetime object)
166
- end: End time (e.g., "now", ISO datetime string, python datetime object)
167
- filter: Additional filter string. Uses Elasticsearch Query String syntax e.g. (fieldName1 = value1 AND fieldName2 = value2) AND (fieldName3 = b OR fieldName4 = d) (default: None)
168
- size: Maximum number of results to return (default: 1000)
169
- page: Page number for pagination (default: 0)
165
+ event_type (Union[str, list]): Event type(s) to filter by. Exact matches only.
166
+ eventlog (str, optional): Eventlog name to query. Defaults to "default".
167
+ start (Union[str, datetime], optional): Start time. Defaults to "yesterday".
168
+ end (Union[str, datetime], optional): End time. Defaults to "now".
169
+ filter (str, optional): Additional filter using Elasticsearch Query String syntax. Defaults to None.
170
+ size (int, optional): Maximum number of results returned. Defaults to 1000.
171
+ page (int, optional): Page number for pagination. Defaults to 0.
170
172
 
171
173
  Returns:
172
- The response from ingenuity, typically a list of dictionaries
174
+ list: Events matching the event type.
173
175
 
174
176
  Raises:
175
- ValueError: If the event type is not provided
177
+ ValueError: If the event type is not provided.
178
+ URLError: If no Ingenuity instance can be reached or no internet connection is available.
179
+ HTTPError: If the API request fails.
180
+
181
+ Docs:
182
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/get-events-by-type
176
183
  """
177
184
  if not event_type or not isinstance(event_type, (str, list)):
178
185
  raise ValueError("Event type must be a non-empty string or list")
@@ -205,23 +212,26 @@ class EventLog(object):
205
212
  id_type: str = "eventId",
206
213
  eventlog: str = "default",
207
214
  ) -> list:
208
- """
209
- Retrieve events from the ingenuity eventlog filtered by event IDs
215
+ """Retrieve events filtered by event IDs.
210
216
 
211
217
  Args:
212
- event_ids: A single event ID (string) or a list of event IDs to retrieve
213
- id_type: The type of ID to filter by
214
- "eventId" - Filter by the unique event identifier generated by ingenuity
215
- "externalId" - Filter by an unique identifier assign by uploader
216
- "episodeId" - Filter by the episode identifier associated with event pairs (Start/End)
217
- (default: "eventId")
218
- eventlog: The name of the eventlog to query (default: default_eventlog)
219
-
218
+ event_ids (Union[str, list]): Event ID(s) to retrieve.
219
+ id_type (str, optional): Type of ID to filter by. Defaults to "eventId".
220
+ - "eventId": Unique identifier generated by Ingenuity.
221
+ - "externalId": Unique identifier assigned by uploader.
222
+ - "episodeId": Episode identifier for event pairs (Start/End).
223
+ eventlog (str, optional): Eventlog name to query. Defaults to "default".
220
224
 
221
225
  Returns:
222
- The response from ingenuity, typically a list of dictionaries
226
+ list: Events matching the event IDs.
227
+
223
228
  Raises:
224
- ValueError: If event_ids is not provided
229
+ ValueError: If event_ids is not provided or id_type is invalid.
230
+ URLError: If no Ingenuity instance can be reached or no internet connection is available.
231
+ HTTPError: If the API request fails.
232
+
233
+ Docs:
234
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/get-events-by-id
225
235
  """
226
236
 
227
237
  if not event_ids or not isinstance(event_ids, (str, list)):
@@ -265,12 +275,24 @@ class EventLog(object):
265
275
  def deleteEventsById(
266
276
  self, event_ids: Union[str, list], eventlog: str = "default"
267
277
  ) -> bool:
268
- """
269
- Delete events from the ingenuity eventlog filtered by event IDs
278
+ """Delete events from the eventlog by event IDs.
279
+
280
+ Events deleted this way CANNOT be recovered, use with caution.
270
281
 
271
282
  Args:
272
- event_ids: A single event ID (string) or a list of event IDs to delete
273
- eventlog: The name of the eventlog to query (default: default_eventlog)
283
+ event_ids (Union[str, list]): Event ID(s) to delete.
284
+ eventlog (str, optional): Eventlog name to query. Defaults to "default".
285
+
286
+ Returns:
287
+ dict or bool: Success status and any errors.
288
+
289
+ Raises:
290
+ ValueError: If event_ids is not provided.
291
+ URLError: If no Ingenuity instance can be reached or no internet connection is available.
292
+ HTTPError: If the API request fails.
293
+
294
+ Docs:
295
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/delete-events-by-id
274
296
  """
275
297
 
276
298
  if not event_ids or not isinstance(event_ids, (str, list)):
@@ -300,14 +322,20 @@ class EventLog(object):
300
322
  return {"success": True, "errors": {}}
301
323
 
302
324
  def pushToEventlog(self, events: Union[dict, list]) -> bool:
303
- """
304
- Push one or more events to the ingenuity eventlog, accepts any event structure
325
+ """Push events to the eventlog.
305
326
 
306
327
  Args:
307
- events: A single event as dict, many events as a list of dicts, or the string filepath of a file containing events
328
+ events (Union[dict, list]): Single event dict, list of dicts, or filepath to file containing events.
308
329
 
309
330
  Returns:
310
- A boolean representing the successful push of all events. False if at least one event failed to be created
331
+ bool or dict: True if all events succeeded, else dict with errors.
332
+
333
+ Raises:
334
+ URLError: If no Ingenuity instance can be reached or no internet connection is available.
335
+ HTTPError: If the API request fails.
336
+
337
+ Docs:
338
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/push-to-eventlog
311
339
  """
312
340
  events = parseEvents(events)
313
341
  relative_url = "/save"
@@ -325,14 +353,17 @@ class EventLog(object):
325
353
  def get_eventlog(
326
354
  eigenserver: EigenServer = None, default_eventlog: Union[str, None] = None
327
355
  ) -> EventLog:
328
- """
329
- Connect to Assetmodel of eigenserver. If eigenserver is not provided this will default to the EIGENSERVER environmental variable
356
+ """Create an EventLog client.
330
357
 
331
358
  Args:
332
- eigenserver: An instance of EigenServer() to query
359
+ eigenserver (EigenServer, optional): EigenServer instance to query.
360
+ default_eventlog (str, optional): Default eventlog name. Defaults to "eventlog".
333
361
 
334
362
  Returns:
335
- An object defining a connection to the AssetModel
363
+ EventLog: An object defining a connection to the EventLog, that exposes methods to query and write to the eventlog.
364
+
365
+ Docs:
366
+ https://docs.eigeningenuity.co/developing-with-eigen/python-library/eventlog/get-eventlog
336
367
  """
337
368
  if eigenserver is None:
338
369
  eigenserver = get_default_server()