jaseci 1.4.2.6__py3-none-any.whl → 2.0.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.

Potentially problematic release.


This version of jaseci might be problematic. Click here for more details.

Files changed (187) hide show
  1. jaseci/__init__.py +3 -37
  2. jaseci-2.0.0.dist-info/METADATA +65 -0
  3. jaseci-2.0.0.dist-info/RECORD +4 -0
  4. {jaseci-1.4.2.6.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
  5. jaseci/VERSION +0 -1
  6. jaseci/cli_tools/__init__.py +0 -0
  7. jaseci/cli_tools/book_tools.py +0 -457
  8. jaseci/cli_tools/jsctl.py +0 -500
  9. jaseci/cli_tools/tests/__init__.py +0 -0
  10. jaseci/cli_tools/tests/test_jsctl.py +0 -556
  11. jaseci/extens/__init__.py +0 -0
  12. jaseci/extens/act_lib/__init__.py +0 -0
  13. jaseci/extens/act_lib/date.py +0 -118
  14. jaseci/extens/act_lib/elastic.py +0 -87
  15. jaseci/extens/act_lib/file.py +0 -77
  16. jaseci/extens/act_lib/file_handler.py +0 -190
  17. jaseci/extens/act_lib/internal.py +0 -19
  18. jaseci/extens/act_lib/jaseci.py +0 -62
  19. jaseci/extens/act_lib/mail.py +0 -10
  20. jaseci/extens/act_lib/maths.py +0 -168
  21. jaseci/extens/act_lib/net.py +0 -192
  22. jaseci/extens/act_lib/rand.py +0 -83
  23. jaseci/extens/act_lib/regex.py +0 -85
  24. jaseci/extens/act_lib/request.py +0 -170
  25. jaseci/extens/act_lib/std.py +0 -236
  26. jaseci/extens/act_lib/storage.py +0 -53
  27. jaseci/extens/act_lib/stripe.py +0 -338
  28. jaseci/extens/act_lib/task.py +0 -14
  29. jaseci/extens/act_lib/tests/__init__.py +0 -0
  30. jaseci/extens/act_lib/tests/std_test_code.py +0 -37
  31. jaseci/extens/act_lib/tests/test_date.py +0 -26
  32. jaseci/extens/act_lib/tests/test_elastic.py +0 -159
  33. jaseci/extens/act_lib/tests/test_file.py +0 -116
  34. jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
  35. jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
  36. jaseci/extens/act_lib/tests/test_maths.py +0 -147
  37. jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
  38. jaseci/extens/act_lib/tests/test_regex.py +0 -61
  39. jaseci/extens/act_lib/tests/test_std.py +0 -51
  40. jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
  41. jaseci/extens/act_lib/tests/test_url.py +0 -32
  42. jaseci/extens/act_lib/tests/test_vector.py +0 -36
  43. jaseci/extens/act_lib/tests/test_webtool.py +0 -44
  44. jaseci/extens/act_lib/tests/test_zlib.py +0 -24
  45. jaseci/extens/act_lib/url.py +0 -80
  46. jaseci/extens/act_lib/vector.py +0 -158
  47. jaseci/extens/act_lib/webtool.py +0 -29
  48. jaseci/extens/act_lib/zip.py +0 -34
  49. jaseci/extens/api/__init__.py +0 -0
  50. jaseci/extens/api/actions_api.py +0 -171
  51. jaseci/extens/api/alias_api.py +0 -140
  52. jaseci/extens/api/architype_api.py +0 -197
  53. jaseci/extens/api/config_api.py +0 -129
  54. jaseci/extens/api/global_api.py +0 -85
  55. jaseci/extens/api/graph_api.py +0 -168
  56. jaseci/extens/api/health_api.py +0 -21
  57. jaseci/extens/api/interface.py +0 -269
  58. jaseci/extens/api/jac_api.py +0 -172
  59. jaseci/extens/api/jsorc_api.py +0 -317
  60. jaseci/extens/api/logger_api.py +0 -90
  61. jaseci/extens/api/master_api.py +0 -134
  62. jaseci/extens/api/object_api.py +0 -102
  63. jaseci/extens/api/prometheus_api.py +0 -75
  64. jaseci/extens/api/queue_api.py +0 -141
  65. jaseci/extens/api/sentinel_api.py +0 -271
  66. jaseci/extens/api/share_api.py +0 -64
  67. jaseci/extens/api/super_api.py +0 -65
  68. jaseci/extens/api/tests/__init__.py +0 -0
  69. jaseci/extens/api/tests/test_architype_api.py +0 -66
  70. jaseci/extens/api/tests/test_global_api.py +0 -179
  71. jaseci/extens/api/tests/test_graph_api.py +0 -64
  72. jaseci/extens/api/tests/test_logger_api.py +0 -43
  73. jaseci/extens/api/tests/test_object_api.py +0 -20
  74. jaseci/extens/api/tests/test_sentinel_api.py +0 -66
  75. jaseci/extens/api/tests/test_uncommon.py +0 -107
  76. jaseci/extens/api/tests/test_user_api.py +0 -32
  77. jaseci/extens/api/tests/test_walker_api.py +0 -316
  78. jaseci/extens/api/user_api.py +0 -166
  79. jaseci/extens/api/walker_api.py +0 -299
  80. jaseci/extens/api/webhook_api.py +0 -77
  81. jaseci/extens/svc/__init__.py +0 -0
  82. jaseci/extens/svc/elastic_svc.py +0 -366
  83. jaseci/extens/svc/kube_svc.py +0 -432
  84. jaseci/extens/svc/mail_svc.py +0 -156
  85. jaseci/extens/svc/prome_svc.py +0 -378
  86. jaseci/extens/svc/redis_svc.py +0 -63
  87. jaseci/extens/svc/storage_svc.py +0 -193
  88. jaseci/extens/svc/stripe_svc.py +0 -51
  89. jaseci/extens/svc/task_svc.py +0 -155
  90. jaseci/extens/svc/tasks.py +0 -302
  91. jaseci/jac/__init__.py +0 -0
  92. jaseci/jac/interpreter/__init__.py +0 -0
  93. jaseci/jac/interpreter/architype_interp.py +0 -219
  94. jaseci/jac/interpreter/interp.py +0 -1784
  95. jaseci/jac/interpreter/sentinel_interp.py +0 -260
  96. jaseci/jac/interpreter/tests/__init__.py +0 -0
  97. jaseci/jac/interpreter/tests/test_interp.py +0 -42
  98. jaseci/jac/interpreter/walker_interp.py +0 -249
  99. jaseci/jac/ir/__init__.py +0 -0
  100. jaseci/jac/ir/ast.py +0 -73
  101. jaseci/jac/ir/ast_builder.py +0 -249
  102. jaseci/jac/ir/jac_code.py +0 -151
  103. jaseci/jac/ir/passes/__init__.py +0 -6
  104. jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
  105. jaseci/jac/ir/passes/codegen_pass.py +0 -244
  106. jaseci/jac/ir/passes/ir_pass.py +0 -29
  107. jaseci/jac/ir/passes/printer_pass.py +0 -23
  108. jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
  109. jaseci/jac/ir/passes/schedule.py +0 -23
  110. jaseci/jac/ir/passes/stats_pass.py +0 -16
  111. jaseci/jac/jac.g4 +0 -450
  112. jaseci/jac/jac_parse/__init__.py +0 -0
  113. jaseci/jac/jac_parse/jacLexer.py +0 -809
  114. jaseci/jac/jac_parse/jacListener.py +0 -853
  115. jaseci/jac/jac_parse/jacParser.py +0 -9192
  116. jaseci/jac/jac_set.py +0 -120
  117. jaseci/jac/jsci_vm/__init__.py +0 -0
  118. jaseci/jac/jsci_vm/disasm.py +0 -94
  119. jaseci/jac/jsci_vm/inst_ptr.py +0 -31
  120. jaseci/jac/jsci_vm/machine.py +0 -188
  121. jaseci/jac/jsci_vm/op_codes.py +0 -82
  122. jaseci/jac/jsci_vm/tests/__init__.py +0 -0
  123. jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
  124. jaseci/jac/machine/__init__.py +0 -0
  125. jaseci/jac/machine/jac_scope.py +0 -86
  126. jaseci/jac/machine/jac_value.py +0 -227
  127. jaseci/jac/machine/machine_state.py +0 -386
  128. jaseci/jac/tests/__init__.py +0 -0
  129. jaseci/jac/tests/book_code.py +0 -624
  130. jaseci/jac/tests/test_book.py +0 -380
  131. jaseci/jac/tests/test_lang_14.py +0 -49
  132. jaseci/jsorc/__init__.py +0 -7
  133. jaseci/jsorc/jsorc.py +0 -642
  134. jaseci/jsorc/jsorc_settings.py +0 -211
  135. jaseci/jsorc/jsorc_utils.py +0 -298
  136. jaseci/jsorc/live_actions.py +0 -365
  137. jaseci/jsorc/manifests/__init__.py +0 -0
  138. jaseci/jsorc/manifests/database.yaml +0 -109
  139. jaseci/jsorc/manifests/elastic.yaml +0 -6029
  140. jaseci/jsorc/manifests/prometheus.yaml +0 -1383
  141. jaseci/jsorc/manifests/redis.yaml +0 -64
  142. jaseci/jsorc/memory.py +0 -258
  143. jaseci/jsorc/redis.py +0 -140
  144. jaseci/jsorc/remote_actions.py +0 -158
  145. jaseci/jsorc/tests/__init__.py +0 -0
  146. jaseci/jsorc/tests/test_actions.py +0 -542
  147. jaseci/jsorc/tests/test_jsorc.py +0 -112
  148. jaseci/prim/__init__.py +0 -0
  149. jaseci/prim/ability.py +0 -94
  150. jaseci/prim/architype.py +0 -90
  151. jaseci/prim/edge.py +0 -173
  152. jaseci/prim/element.py +0 -233
  153. jaseci/prim/graph.py +0 -27
  154. jaseci/prim/master.py +0 -67
  155. jaseci/prim/node.py +0 -533
  156. jaseci/prim/obj_mixins.py +0 -238
  157. jaseci/prim/sentinel.py +0 -282
  158. jaseci/prim/super_master.py +0 -31
  159. jaseci/prim/walker.py +0 -261
  160. jaseci/svc/__init__.py +0 -0
  161. jaseci/tests/__init__.py +0 -0
  162. jaseci/tests/infer.py +0 -39
  163. jaseci/tests/jac_test_code.py +0 -1293
  164. jaseci/tests/jac_test_progs.py +0 -774
  165. jaseci/tests/test_core.py +0 -153
  166. jaseci/tests/test_jac.py +0 -824
  167. jaseci/tests/test_node.py +0 -89
  168. jaseci/tests/test_progs.py +0 -702
  169. jaseci/tests/test_stack.py +0 -220
  170. jaseci/tests/test_stripe.py +0 -225
  171. jaseci/utils/__init__.py +0 -0
  172. jaseci/utils/actions/__init__.py +0 -0
  173. jaseci/utils/actions/actions_manager.py +0 -254
  174. jaseci/utils/actions/actions_optimizer.py +0 -517
  175. jaseci/utils/actions/actions_state.py +0 -95
  176. jaseci/utils/file_handler.py +0 -171
  177. jaseci/utils/gprof2dot.py +0 -3786
  178. jaseci/utils/id_list.py +0 -169
  179. jaseci/utils/json_handler.py +0 -70
  180. jaseci/utils/log_utils.py +0 -57
  181. jaseci/utils/test_core.py +0 -62
  182. jaseci/utils/utils.py +0 -387
  183. jaseci-1.4.2.6.dist-info/LICENSE +0 -21
  184. jaseci-1.4.2.6.dist-info/METADATA +0 -39
  185. jaseci-1.4.2.6.dist-info/RECORD +0 -185
  186. jaseci-1.4.2.6.dist-info/entry_points.txt +0 -3
  187. jaseci-1.4.2.6.dist-info/top_level.txt +0 -1
@@ -1,140 +0,0 @@
1
- """
2
- Alias api as a mixin
3
- """
4
-
5
- from jaseci.extens.api.interface import Interface
6
-
7
-
8
- class AliasAPI:
9
- """
10
- Alias APIs for creating nicknames for UUIDs and other long strings
11
-
12
- The alias set of APIs provide a set of `alias' management functions for
13
- creating and managing aliases for long strings such as UUIDs. If an alias'
14
- name is used as a parameter value in any API call, that parameter will see
15
- the alias' value instead. Given that references to all sentinels, walkers,
16
- nodes, etc. utilize UUIDs, it becomes quite useful to create pneumonic
17
- names for them. Also, when registering sentinels, walkers, architype
18
- handy aliases are automatically generated. These generated aliases can
19
- then be managed using the alias APIs. Keep in mind that whenever an alias
20
- is created, all parameter values submitted to any API with the alias name
21
- will be replaced internally by its value. If you get in a bind, simply use
22
- the clear or delete alias APIs.
23
- """
24
-
25
- def __init__(self):
26
- self.alias_map = {}
27
-
28
- @Interface.private_api(cli_args=["name"])
29
- def alias_register(self, name: str, value: str):
30
- """Create string to string alias mapping that caller can use.
31
-
32
- Either create new alias string to string mappings or replace
33
- an existing mappings of a given alias name. Once registered the
34
- alias mapping is instantly active.
35
-
36
- Args:
37
- name (str): The name for the alias created by caller.
38
- value (str): The value for that name to map to (i.e., UUID)
39
-
40
- Returns:
41
- json: Fields include
42
- 'response': Message of mapping that was created
43
- """
44
- self.alias_map[name] = value
45
- self.save()
46
- return {"response": f"Alias from '{name}' to '{value}' set!"}
47
-
48
- @Interface.private_api()
49
- def alias_list(self):
50
- """List all string to string alias that caller can use.
51
-
52
- Returns dictionary object of name to value mappings currently active.
53
- This API is quite useful to track not only the aliases the caller
54
- creates, but also the aliases automatically created as various Jaseci
55
- objects (walkers, architypes, sentinels, etc.) are created, changed,
56
- or destroyed.
57
-
58
- Returns:
59
- dictionary: Dictionary of active mappings
60
- 'name': 'value'
61
- ...
62
- """
63
- return self.alias_map
64
-
65
- @Interface.private_api(cli_args=["name"])
66
- def alias_delete(self, name: str):
67
- """Delete an active string to string alias mapping.
68
-
69
- Removes a specific alias by its name. Only the alias is removed no
70
- actual objects are affected. Future uses of this name will not be
71
- mapped.
72
-
73
- Args:
74
- name (str): The name for the alias to be removed from caller.
75
-
76
- Returns:
77
- dictionary: Fields include
78
- 'response': Message of success/failure to remove alias
79
- 'success': True/False based on delete actually happening
80
- """
81
- if name in self.alias_map.keys():
82
- del self.alias_map[name]
83
- self.save()
84
- return {"response": f"Alias {name} successfully deleted", "success": True}
85
- else:
86
- return {"response": f"Alias {name} not present", "success": False}
87
-
88
- @Interface.private_api()
89
- def alias_clear(self):
90
- """Remove all string to string alias that client can use.
91
-
92
- Removes a all aliases. No actual objects are affected. Aliases will
93
- continue to be automatically generated when creating other Jaseci
94
- objects.
95
-
96
- Returns:
97
- dictionary: Fields include
98
- 'response': Message of number of alias removed
99
- 'removed': Number of aliases removed
100
- """
101
- n = len(self.alias_map.keys())
102
- self.alias_map = {}
103
- self.save()
104
- return {"response": f"All {n} aliases deleted", "removed": n}
105
-
106
- def extract_snt_aliases(self, snt):
107
- """
108
- Extract and register all aliases from sentinel
109
- """
110
- self.alias_register(f"sentinel:{snt.name}", snt.jid)
111
- for i in snt.arch_ids.obj_list():
112
- self.extract_arch_aliases(snt, i)
113
- self.save()
114
-
115
- def extract_arch_aliases(self, snt, arch):
116
- """
117
- Extract and register all aliases from architype
118
- """
119
- if arch.kind == "walker":
120
- self.alias_register(f"{snt.name}:walker:{arch.name}", arch.jid)
121
- else:
122
- self.alias_register(f"{snt.name}:architype:{arch.name}", arch.jid)
123
-
124
- def remove_snt_aliases(self, snt):
125
- """
126
- Extract and register all aliases from sentinel
127
- """
128
- self.alias_delete(f"sentinel:{snt.name}")
129
- for i in snt.arch_ids.obj_list():
130
- self.remove_arch_aliases(snt, i)
131
- self.save()
132
-
133
- def remove_arch_aliases(self, snt, arch):
134
- """
135
- Extract and register all aliases from architype
136
- """
137
- if arch.kind == "walker":
138
- self.alias_delete(f"{snt.name}:walker:{arch.name}")
139
- else:
140
- self.alias_delete(f"{snt.name}:architype:{arch.name}")
@@ -1,197 +0,0 @@
1
- """
2
- Architype api functions as a mixin
3
- """
4
-
5
- from jaseci.extens.api.interface import Interface
6
- from jaseci.prim.architype import Architype
7
- from jaseci.prim.sentinel import Sentinel
8
- from jaseci.utils.utils import b64decode_str
9
-
10
-
11
- class ArchitypeApi:
12
- """Architype APIs for creating and managing Jaseci architypes
13
-
14
- The architype set of APIs allow for the addition and removing of
15
- architypes. Given a Jac implementation of an architype these APIs are
16
- designed for creating, compiling, and managing architypes that can be
17
- used by Jaseci. There are two ways to add an architype to Jaseci, either
18
- through the management of sentinels using the sentinel API, or by
19
- registering independent architypes with these architype APIs. These
20
- APIs are also used for inspecting and managing existing arichtypes that
21
- a Jaseci instance is aware of.
22
- """
23
-
24
- @Interface.private_api(cli_args=["code"])
25
- def architype_register(
26
- self, code: str, encoded: bool = False, snt: Sentinel = None
27
- ):
28
- """Create an architype based on the code passed and return object.
29
-
30
- This register API allows for the creation or replacement/update of
31
- an architype that can then be used by walkers in their interactions
32
- of graphs. The code argument takes Jac source code for the single
33
- architype. To load multiple architypes and walkers at the same time,
34
- use sentinel register API.
35
-
36
- Args:
37
- code (str): The text (or filename) for an architypes Jac code
38
- encoded (bool): True/False flag as to whether code is encode
39
- in base64
40
- snt (uuid): The UUID of the sentinel to be the owner of this
41
- architype
42
-
43
- Returns:
44
- json: Fields include
45
- 'architype': Architype object if created otherwise null
46
- 'success': True/False whether register was successful
47
- 'errors': List of errors if register failed
48
- 'response': Message on outcome of register call
49
- """
50
- ret = {"architype": None, "success": False, "errors": []}
51
- if encoded:
52
- code = b64decode_str(code)
53
- arch = snt.register_architype(code)
54
- if arch:
55
- self.extract_arch_aliases(snt, arch)
56
- ret["architype"] = arch.serialize()
57
- ret["success"] = True
58
- ret["response"] = f"Successfully created {arch.name} architype"
59
- else:
60
- ret["errors"] = snt.errors
61
- ret["response"] = "Errors occured"
62
- return ret
63
-
64
- @Interface.private_api()
65
- def architype_get(
66
- self, arch: Architype, mode: str = "default", detailed: bool = False
67
- ):
68
- """Get an architype rendered with specific mode
69
-
70
- Args:
71
- arch (uuid): The architype being accessed
72
- mode (str): Valid modes: {default, code, ir, }
73
- detailed (bool): Flag to give summary or complete set of fields
74
-
75
- Returns:
76
- json: Fields include (depends on mode)
77
- 'code': Formal source code for architype
78
- 'ir': Intermediate representation of architype
79
- 'architype': Architype object print
80
- """
81
- # ternary python example
82
- a = 1 if True else 2
83
-
84
- if mode == "code":
85
- try:
86
- return {"code": arch.get_jac_ast().src}
87
- except AttributeError:
88
- return {"code": "No code available for architype"}
89
- elif mode == "ir":
90
- return {"ir": arch.ir_dict()}
91
- else:
92
- return {"architype": arch.serialize(detailed=detailed)}
93
-
94
- @Interface.private_api(cli_args=["code"])
95
- def architype_set(self, arch: Architype, code: str, mode: str = "default"):
96
- """Set code/ir for a architype
97
-
98
- Args:
99
- arch (uuid): The architype being set
100
- code (str): The text (or filename) for an architypes Jac code/ir
101
- mode (str): Valid modes: {default, code, ir, }
102
-
103
- Returns:
104
- json: Fields include (depends on mode)
105
- 'success': True/False whether set was successful
106
- 'errors': List of errors if set failed
107
- 'response': Message on outcome of set call
108
- """
109
- if mode == "code" or mode == "default":
110
- arch.register(code)
111
- elif mode == "ir":
112
- arch.apply_ir(code)
113
- else:
114
- return {
115
- "response": f"Invalid mode to set {arch}",
116
- "success": False,
117
- "errors": [],
118
- }
119
- if arch.is_active:
120
- return {
121
- "response": f"{arch} registered and active!",
122
- "success": True,
123
- "errors": [],
124
- }
125
- else:
126
- return {
127
- "response": f"{arch} registered and active!",
128
- "success": True,
129
- "errors": arch.errors,
130
- }
131
-
132
- @Interface.private_api()
133
- def architype_list(
134
- self, snt: Sentinel = None, kind: str = None, detailed: bool = False
135
- ):
136
- """List architypes known to sentinel
137
-
138
- Args:
139
- snt (uuid): The sentinel for which to list its architypes
140
- detailed (bool): Flag to give summary or complete set of fields
141
- kind (str): Architype kind used to narrow the result set
142
-
143
- Returns:
144
- json: List of architype objects
145
- """
146
- archs = []
147
-
148
- for i in snt.arch_ids.obj_list():
149
- if not kind:
150
- archs.append(i.serialize(detailed=detailed))
151
- elif i.kind == kind:
152
- archs.append(i.serialize(detailed=detailed))
153
-
154
- return archs
155
-
156
- @Interface.private_api()
157
- def architype_count(self, snt: Sentinel = None, kind: str = None):
158
- """Return count of architypes
159
-
160
- Args:
161
- snt (uuid): The sentinel for which to list its architypes
162
- detailed (bool): Flag to give summary or complete set of fields
163
- kind (str): Architype kind used to narrow the result set from which the count is evaluated
164
-
165
- Returns:
166
- int: Count of architype objects
167
- """
168
- arch_objects = snt.arch_ids.obj_list()
169
-
170
- if kind:
171
- arch_objects = list(filter(lambda obj: obj.kind == kind, arch_objects))
172
-
173
- return len(arch_objects)
174
-
175
- @Interface.private_api(cli_args=["arch"])
176
- def architype_delete(self, arch: Architype, snt: Sentinel = None):
177
- """Permanently delete sentinel with given id
178
-
179
- Args:
180
- arch (uuid): The architype being set
181
- snt (uuid): The sentinel for which to list its architypes
182
-
183
- Returns:
184
- json: Fields include (depends on mode)
185
- 'success': True/False whether command was successful
186
- 'response': Message on outcome of command
187
- """
188
-
189
- if arch.jid not in snt.arch_ids:
190
- return {
191
- "response": f"Architype {arch} not in sentinel {snt}",
192
- "success": False,
193
- }
194
- self.remove_arch_aliases(snt, arch)
195
- archid = arch.jid
196
- snt.arch_ids.destroy_obj(arch)
197
- return {"response": f"Architype {archid} successfully deleted", "success": True}
@@ -1,129 +0,0 @@
1
- """
2
- Admin config api functions as a mixin
3
- """
4
-
5
- from typing import Optional
6
- from json import dumps, loads
7
- from jaseci.extens.api.interface import Interface
8
-
9
-
10
- class ConfigApi:
11
- """
12
- Admin config APIs
13
- Abstracted since there are no valid configs in core atm, see jaseci_serv
14
- to see how used.
15
- """
16
-
17
- def __init__(self, *args, **kwargs):
18
- self._valid_configs = [
19
- "CONFIG_EXAMPLE",
20
- "ACTION_SETS",
21
- "REDIS_CONFIG",
22
- "TASK_CONFIG",
23
- "MAIL_CONFIG",
24
- "PROME_CONFIG",
25
- "ELASTIC_CONFIG",
26
- "STRIPE_CONFIG",
27
- "KUBE_CONFIG",
28
- "JSORC_CONFIG",
29
- ]
30
-
31
- @Interface.admin_api(cli_args=["name"])
32
- def config_get(self, name: str, do_check: bool = True):
33
- """
34
- Get a config
35
- """
36
- if do_check and not self.name_check(name):
37
- return self.name_error(name)
38
- return self._h.get_glob(name)
39
-
40
- @Interface.admin_api(cli_args=["name"])
41
- def config_set(self, name: str, value: str or dict, do_check: bool = True):
42
- """
43
- Set a config
44
- """
45
- if do_check and not self.name_check(name):
46
- return self.name_error(name)
47
-
48
- if not (value is None) and type(value) is dict:
49
- value = dumps(value)
50
-
51
- self._h.save_glob(name, value)
52
- return [f"Config of '{name}' to '{value}' set!"]
53
-
54
- @Interface.admin_api(cli_args=["name"])
55
- def config_update(
56
- self,
57
- name: str,
58
- field_key: str,
59
- field_value: str
60
- or int
61
- or float
62
- or list
63
- or dict
64
- or bool
65
- or tuple
66
- or None, # json serializable types
67
- do_check: bool = True,
68
- ):
69
- """
70
- Update a key-value of a config
71
- """
72
- if do_check and not self.name_check(name):
73
- return self.name_error(name)
74
-
75
- conf = self._h.get_glob(name)
76
- try:
77
- conf = loads(conf)
78
- except Exception:
79
- return [
80
- f"Config {name} is not a dictionary. Uses config_set to set the value for this config."
81
- ]
82
- if field_key not in conf:
83
- return [f"Field {field_key} does not exist in config {name}"]
84
-
85
- conf[field_key] = field_value
86
- conf = dumps(conf)
87
- self._h.save_glob(name, conf)
88
- return [
89
- f"Config of '{name}' is updated with {field_key}:{field_value}. Current config value: {conf}"
90
- ]
91
-
92
- @Interface.admin_api()
93
- def config_list(self):
94
- """
95
- Check a config is present
96
- """
97
- return [v for v in self._h.list_glob() if v in self._valid_configs]
98
-
99
- @Interface.admin_api()
100
- def config_index(self):
101
- """
102
- List all valid configs
103
- """
104
- return self._valid_configs
105
-
106
- @Interface.admin_api(cli_args=["name"])
107
- def config_exists(self, name: str):
108
- """
109
- Check a config is present
110
- """
111
- return self._h.has_glob(name)
112
-
113
- @Interface.admin_api(cli_args=["name"])
114
- def config_delete(self, name: str, do_check: bool = True):
115
- """
116
- Delete a config
117
- """
118
- if do_check and not self.name_check(name):
119
- return self.name_error(name)
120
- self._h.destroy_glob(name)
121
- return [f"{name} Deleted."]
122
-
123
- def name_error(self, name):
124
- """Much used error output"""
125
- return [f"Config {name} not recognized, must be in {self._valid_configs}!"]
126
-
127
- def name_check(self, name):
128
- """Much used name check"""
129
- return name in self._valid_configs
@@ -1,85 +0,0 @@
1
- """
2
- Admin Global api functions as a mixin
3
- """
4
-
5
- from jaseci.extens.api.interface import Interface
6
- from jaseci.prim.sentinel import Sentinel
7
- import uuid
8
-
9
-
10
- class GlobalApi:
11
- """
12
- Admin global APIs
13
- """
14
-
15
- @Interface.admin_api(cli_args=["name"])
16
- def global_set(self, name: str, value: str):
17
- """
18
- Set a global
19
- """
20
- ret = {"success": True}
21
- if name == "GLOB_SENTINEL" or name in self._valid_configs:
22
- ret["response"] = f"{name} is sacred!"
23
- ret["success"] = False
24
- else:
25
- self._h.save_glob(name, value)
26
- ret["response"] = f"Global variable '{name}' to '{value}' set!"
27
- return ret
28
-
29
- @Interface.admin_api(cli_args=["name"])
30
- def global_delete(self, name: str):
31
- """
32
- Delete a global
33
- """
34
- ret = {"success": True}
35
- if name == "GLOB_SENTINEL" or name in self._valid_configs:
36
- ret["response"] = f"{name} is sacred!"
37
- ret["success"] = False
38
- else:
39
- self._h.destroy_glob(name)
40
- ret["response"] = f"Global {name} deleted."
41
- return ret
42
-
43
- @Interface.admin_api()
44
- def global_sentinel_set(self, snt: Sentinel = None):
45
- """
46
- Make a sentinel globally accessible and set it as the global sentinel
47
- """
48
- snt.make_read_only()
49
- snt.propagate_access()
50
- self._h.save_glob("GLOB_SENTINEL", snt.jid)
51
- return {"response": f"Global sentinel set to '{snt}'!"}
52
-
53
- @Interface.admin_api()
54
- def global_sentinel_setaccess(self, snt: Sentinel = None):
55
- """
56
- Make a sentinel globally accessible
57
- """
58
- snt.make_read_only()
59
- snt.propagate_access()
60
- return {"response": f"Sentinel '{snt}' is now globally accessible (read-only)."}
61
-
62
- @Interface.admin_api()
63
- def global_sentinel_revokeaccess(self, snt: Sentinel = None):
64
- """
65
- Revoke the global accessibility of a sentinel. Making it private.
66
- """
67
- if snt.check_write_access(self._m_id):
68
- snt.make_private()
69
- snt.propagate_access()
70
- return {"response": f"Sentinel '{snt}' is now private."}
71
- else:
72
- return {"response:" "Insufficient permission."}
73
-
74
- @Interface.admin_api()
75
- def global_sentinel_unset(self):
76
- """
77
- Unset a global sentinel
78
- """
79
- current = self.global_get("GLOB_SENTINEL")["value"]
80
- if current:
81
- snt = self._h.get_obj(self._m_id, current)
82
- for i in snt.get_deep_obj_list():
83
- i.make_private()
84
- self._h.destroy_glob("GLOB_SENTINEL")
85
- return {"response": "Global sentinel cleared!"}