howler-api 3.0.0.dev366__py3-none-any.whl → 3.0.0.dev369__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.

Potentially problematic release.


This version of howler-api might be problematic. Click here for more details.

@@ -430,7 +430,7 @@ class ESCollection(Generic[ModelType]):
430
430
  wait_for_completion=True,
431
431
  timeout="10s",
432
432
  )
433
- except elasticsearch.exceptions.TransportError as e:
433
+ except (elasticsearch.exceptions.TransportError, elasticsearch.exceptions.ApiError) as e:
434
434
  err_code, msg, _ = e.args
435
435
  if (err_code == 500 or err_code == "500") and msg in [
436
436
  "timeout_exception",
@@ -9,10 +9,6 @@ DELAY = 5
9
9
  if __name__ == "__main__":
10
10
  print("This script will allow you to reindex all indexes in elasticsearch.")
11
11
  print("For obvious reasons, be EXTREMELY CAREFUL running this code.")
12
-
13
- for i in range(DELAY):
14
- print(f"Continuing in {str(DELAY - i)}...", end="\r")
15
- time.sleep(1)
16
12
  print()
17
13
  answer = input("Are you sure you want to reindex data for an index in this cluster? [yes/NO]\n")
18
14
 
@@ -28,15 +24,15 @@ if __name__ == "__main__":
28
24
 
29
25
  ds = loader.datastore(archive_access=False)
30
26
 
31
- indexes: dict[str, tuple[list[str], Callable]] = {
32
- "analytic": (ds.analytic.index_list_full, ds.analytic.reindex),
33
- "hit": (ds.hit.index_list_full, ds.hit.reindex),
34
- "view": (ds.view.index_list_full, ds.view.reindex),
35
- "template": (ds.template.index_list_full, ds.template.reindex),
36
- "overview": (ds.overview.index_list_full, ds.overview.reindex),
37
- "action": (ds.action.index_list_full, ds.action.reindex),
38
- "user": (ds.user.index_list_full, ds.user.reindex),
39
- "dossier": (ds.dossier.index_list_full, ds.dossier.reindex),
27
+ indexes: dict[str, tuple[ESCollection, Callable]] = {
28
+ "analytic": (ds.analytic, ds.analytic.reindex),
29
+ "hit": (ds.hit, ds.hit.reindex),
30
+ "view": (ds.view, ds.view.reindex),
31
+ "template": (ds.template, ds.template.reindex),
32
+ "overview": (ds.overview, ds.overview.reindex),
33
+ "action": (ds.action, ds.action.reindex),
34
+ "user": (ds.user, ds.user.reindex),
35
+ "dossier": (ds.dossier, ds.dossier.reindex),
40
36
  }
41
37
 
42
38
  print("Which index will you reindex?")
@@ -47,10 +43,10 @@ if __name__ == "__main__":
47
43
  sys.exit(1)
48
44
 
49
45
  print("Index schema:")
50
- print(json.dumps(ds.hit._get_index_mappings(), indent=2))
46
+ print(json.dumps(indexes[index_answer][0]._get_index_mappings(), indent=2))
51
47
 
52
48
  print("\nYou will be reindexing the following indexes:")
53
- print("\n".join(indexes[index_answer][0]))
49
+ print("\n".join(indexes[index_answer][0].index_list_full))
54
50
 
55
51
  answer = input(("\nAre you sure you want to reindex these indexes? [yes/NO]\n"))
56
52
  print()
howler/odm/base.py CHANGED
@@ -1093,8 +1093,8 @@ class Model:
1093
1093
  return out
1094
1094
 
1095
1095
  @classmethod
1096
- def add_namespace(cls, namespace: str, field: _Field):
1097
- field.name = namespace
1096
+ def add_namespace(cls, namespace: str, field: _Field, index=None, store=None, description=None):
1097
+ recursive_set_name(field, namespace)
1098
1098
 
1099
1099
  if hasattr(cls, "_odm_field_cache_skip"):
1100
1100
  cls._odm_field_cache_skip[namespace.rstrip("_")] = field
@@ -1102,7 +1102,25 @@ class Model:
1102
1102
  if hasattr(cls, "_odm_field_cache"):
1103
1103
  cls._odm_field_cache[namespace.rstrip("_")] = field
1104
1104
 
1105
- return setattr(cls, namespace, field)
1105
+ setattr(cls, namespace, field)
1106
+
1107
+ field._Model__description = description
1108
+ for name, field_data in field.fields().items():
1109
+ if not FIELD_SANITIZER.match(name) or name in BANNED_FIELDS:
1110
+ raise HowlerValueError(f"Illegal variable name: {name}")
1111
+
1112
+ recursive_set_name(field_data, name)
1113
+ field_data.apply_defaults(index=index, store=store)
1114
+
1115
+ @classmethod
1116
+ def remove_namespace(cls, namespace: str):
1117
+ if hasattr(cls, "_odm_field_cache_skip"):
1118
+ del cls._odm_field_cache_skip[namespace.rstrip("_")]
1119
+
1120
+ if hasattr(cls, "_odm_field_cache"):
1121
+ del cls._odm_field_cache[namespace.rstrip("_")]
1122
+
1123
+ delattr(cls, namespace)
1106
1124
 
1107
1125
  @staticmethod
1108
1126
  def _recurse_fields(name, field, show_compound, skip_mappings, multivalued=False):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: howler-api
3
- Version: 3.0.0.dev366
3
+ Version: 3.0.0.dev369
4
4
  Summary: Howler - API server
5
5
  License: MIT
6
6
  Keywords: howler,alerting,gc,canada,cse-cst,cse,cst,cyber,cccs
@@ -53,7 +53,7 @@ howler/cronjobs/view_cleanup.py,sha256=ULWLR1uFcRemRgkEDrMqmBamHiE0dgDvu49VK0qDk
53
53
  howler/datastore/README.md,sha256=ekWl1YJSrHlZpU5PgBkPEzPWjdbTdav6Rd2P0ccIesw,4758
54
54
  howler/datastore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  howler/datastore/bulk.py,sha256=VfolZfiaBD4ZTK3j6IVVVq4GMjVXb5elrsGwwM_nONE,2829
56
- howler/datastore/collection.py,sha256=69VhtrFp24Alssm-yTuDHqPZ1XWhN5Ty-eeRJaPQEP4,91154
56
+ howler/datastore/collection.py,sha256=joi4-lUMWGH1DBO3ag36GriSI7J2n-UpIfb1-KaBdTU,91191
57
57
  howler/datastore/constants.py,sha256=x7ODomtOQmDjmXoAxly4onPAnUkq4BLZ1TBg-UgpU1g,2415
58
58
  howler/datastore/exceptions.py,sha256=yZvQXRI4mR50ltGFHbdZAD4TIbhdKJku6LLTPQ0JZRk,955
59
59
  howler/datastore/howler_store.py,sha256=kW7FKM-tILcfTmrjSB1yZm-ZnumPS_tiQEZUDaQoDkg,2915
@@ -70,7 +70,7 @@ howler/external/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  howler/external/generate_mitre.py,sha256=B4ALOP9OdAuq45u0UahprtFkG-B0SuMw-PwuUdZFFfM,2638
71
71
  howler/external/generate_sigma_rules.py,sha256=QkdgEtOYqazRqvc0sfkP_sZmooDbmog6BUfgTJ2zhPY,831
72
72
  howler/external/generate_tlds.py,sha256=S_J-x3QUaRjpZKOcBrnL8w7-FfTNKLOIrvW3qJDcj4Y,1386
73
- howler/external/reindex_data.py,sha256=37rHW3vsL0oUYZ9EDEyEzZKmnonUuSA6Q9ueM-6dshg,2219
73
+ howler/external/reindex_data.py,sha256=NyVZ0fXnsVGeuI3DZF5Ufq8Wqp9giimyRzdJOT8Dyh0,2016
74
74
  howler/external/wipe_databases.py,sha256=CO_mUdezp24h6xz6Di_K5-Mid61d9EVcBO4ap5qnVao,1610
75
75
  howler/gunicorn_config.py,sha256=0X7DPFcVDu3qAgMbNsdYGqCuvQGn5ZNx_eapOMyuXuI,750
76
76
  howler/healthz.py,sha256=nvb8MBBERYIkA_UxxLIyNEQazYOnPCcm0sH0Jm5nF0k,769
@@ -84,7 +84,7 @@ howler/helper/workflow.py,sha256=fsYhjeZo1foM0J8AW3nMjTEJOAnh9R6L0f4ZL12pE4E,480
84
84
  howler/helper/ws.py,sha256=ONxC7DFYGQKpp0AmrFqQLeIyxOMD4nHk5i6lFyWOtqo,15911
85
85
  howler/odm/README.md,sha256=Ihc_DyjVQlLaIOEbPoQNPkum9Ecn8kn37-PMFQsX77s,5645
86
86
  howler/odm/__init__.py,sha256=1n6vgBOrFcCHSBFysqgODERvqP7s5DIeJe8N8UeE5pM,44
87
- howler/odm/base.py,sha256=uAgEaccEfoLZpNPlRheDzZTuDWTz-UJrTWNrKHeSFmo,52254
87
+ howler/odm/base.py,sha256=uK405FXmcSKqgTyLutPTMDSmcBvAfa94PUlAjJFyg2w,52987
88
88
  howler/odm/charter.txt,sha256=-Wgrv7nqugZmeQknJk0_m6klLJStjVbuqKbi_KaDinQ,15277
89
89
  howler/odm/helper.py,sha256=EELMg3pvE7Kb9VDeKSYJQHiq6uCO2YuS095CPRgWrEM,13927
90
90
  howler/odm/howler_enum.py,sha256=JzRK3_adlhvfkoGdMZD1jgOwlneZs8-x7OxGEj3zcpY,768
@@ -192,7 +192,7 @@ howler/utils/path.py,sha256=DfOU4i4zSs4wchHoE8iE7aWVLkTxiC_JRGepF2hBYBk,690
192
192
  howler/utils/socket_utils.py,sha256=nz1SklC9xBHUSfHyTJjpq3mbozX1GDf01WzdGxfaUII,2212
193
193
  howler/utils/str_utils.py,sha256=HE8Hqh2HlOLaj16w0H9zKOyDJLp-f1LQ50y_WeGZaEk,8389
194
194
  howler/utils/uid.py,sha256=p9dsqyvZ-lpiAuzZWCPCeEM99kdk0Ly9czf04HNdSuw,1341
195
- howler_api-3.0.0.dev366.dist-info/METADATA,sha256=mtydac9xvKXb19JTlx8d0dfZayCfp8kDq2L7W17SO7o,2804
196
- howler_api-3.0.0.dev366.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
197
- howler_api-3.0.0.dev366.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
198
- howler_api-3.0.0.dev366.dist-info/RECORD,,
195
+ howler_api-3.0.0.dev369.dist-info/METADATA,sha256=_tAldPmKk79tk451OlRf3WOaUVYqpbpbYChJvVGDEA4,2804
196
+ howler_api-3.0.0.dev369.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
197
+ howler_api-3.0.0.dev369.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
198
+ howler_api-3.0.0.dev369.dist-info/RECORD,,