jaseci 1.4.2.5__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.
- jaseci/__init__.py +3 -37
- jaseci-2.0.0.dist-info/METADATA +65 -0
- jaseci-2.0.0.dist-info/RECORD +4 -0
- {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
- jaseci/VERSION +0 -1
- jaseci/cli_tools/__init__.py +0 -0
- jaseci/cli_tools/book_tools.py +0 -457
- jaseci/cli_tools/jsctl.py +0 -500
- jaseci/cli_tools/tests/__init__.py +0 -0
- jaseci/cli_tools/tests/test_jsctl.py +0 -556
- jaseci/extens/__init__.py +0 -0
- jaseci/extens/act_lib/__init__.py +0 -0
- jaseci/extens/act_lib/date.py +0 -117
- jaseci/extens/act_lib/elastic.py +0 -87
- jaseci/extens/act_lib/file.py +0 -76
- jaseci/extens/act_lib/file_handler.py +0 -189
- jaseci/extens/act_lib/internal.py +0 -18
- jaseci/extens/act_lib/jaseci.py +0 -61
- jaseci/extens/act_lib/mail.py +0 -10
- jaseci/extens/act_lib/maths.py +0 -168
- jaseci/extens/act_lib/net.py +0 -191
- jaseci/extens/act_lib/rand.py +0 -82
- jaseci/extens/act_lib/regex.py +0 -85
- jaseci/extens/act_lib/request.py +0 -169
- jaseci/extens/act_lib/std.py +0 -235
- jaseci/extens/act_lib/storage.py +0 -53
- jaseci/extens/act_lib/stripe.py +0 -337
- jaseci/extens/act_lib/task.py +0 -13
- jaseci/extens/act_lib/tests/__init__.py +0 -0
- jaseci/extens/act_lib/tests/std_test_code.py +0 -37
- jaseci/extens/act_lib/tests/test_date.py +0 -26
- jaseci/extens/act_lib/tests/test_elastic.py +0 -159
- jaseci/extens/act_lib/tests/test_file.py +0 -116
- jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
- jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
- jaseci/extens/act_lib/tests/test_maths.py +0 -147
- jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
- jaseci/extens/act_lib/tests/test_regex.py +0 -61
- jaseci/extens/act_lib/tests/test_std.py +0 -51
- jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
- jaseci/extens/act_lib/tests/test_url.py +0 -32
- jaseci/extens/act_lib/tests/test_vector.py +0 -36
- jaseci/extens/act_lib/tests/test_webtool.py +0 -44
- jaseci/extens/act_lib/tests/test_zlib.py +0 -24
- jaseci/extens/act_lib/url.py +0 -79
- jaseci/extens/act_lib/vector.py +0 -157
- jaseci/extens/act_lib/webtool.py +0 -28
- jaseci/extens/act_lib/zip.py +0 -33
- jaseci/extens/api/__init__.py +0 -0
- jaseci/extens/api/actions_api.py +0 -170
- jaseci/extens/api/alias_api.py +0 -139
- jaseci/extens/api/architype_api.py +0 -196
- jaseci/extens/api/config_api.py +0 -129
- jaseci/extens/api/global_api.py +0 -84
- jaseci/extens/api/graph_api.py +0 -167
- jaseci/extens/api/health_api.py +0 -20
- jaseci/extens/api/interface.py +0 -268
- jaseci/extens/api/jac_api.py +0 -171
- jaseci/extens/api/jsorc_api.py +0 -316
- jaseci/extens/api/logger_api.py +0 -89
- jaseci/extens/api/master_api.py +0 -133
- jaseci/extens/api/object_api.py +0 -101
- jaseci/extens/api/prometheus_api.py +0 -74
- jaseci/extens/api/queue_api.py +0 -140
- jaseci/extens/api/sentinel_api.py +0 -270
- jaseci/extens/api/super_api.py +0 -64
- jaseci/extens/api/tests/__init__.py +0 -0
- jaseci/extens/api/tests/test_architype_api.py +0 -66
- jaseci/extens/api/tests/test_global_api.py +0 -179
- jaseci/extens/api/tests/test_graph_api.py +0 -64
- jaseci/extens/api/tests/test_logger_api.py +0 -43
- jaseci/extens/api/tests/test_object_api.py +0 -20
- jaseci/extens/api/tests/test_sentinel_api.py +0 -66
- jaseci/extens/api/tests/test_uncommon.py +0 -107
- jaseci/extens/api/tests/test_user_api.py +0 -32
- jaseci/extens/api/tests/test_walker_api.py +0 -316
- jaseci/extens/api/user_api.py +0 -144
- jaseci/extens/api/walker_api.py +0 -298
- jaseci/extens/api/webhook_api.py +0 -74
- jaseci/extens/svc/__init__.py +0 -0
- jaseci/extens/svc/elastic_svc.py +0 -366
- jaseci/extens/svc/kube_svc.py +0 -432
- jaseci/extens/svc/mail_svc.py +0 -156
- jaseci/extens/svc/prome_svc.py +0 -378
- jaseci/extens/svc/redis_svc.py +0 -63
- jaseci/extens/svc/storage_svc.py +0 -193
- jaseci/extens/svc/stripe_svc.py +0 -51
- jaseci/extens/svc/task_svc.py +0 -155
- jaseci/extens/svc/tasks.py +0 -302
- jaseci/jac/__init__.py +0 -0
- jaseci/jac/interpreter/__init__.py +0 -0
- jaseci/jac/interpreter/architype_interp.py +0 -214
- jaseci/jac/interpreter/interp.py +0 -1783
- jaseci/jac/interpreter/sentinel_interp.py +0 -257
- jaseci/jac/interpreter/tests/__init__.py +0 -0
- jaseci/jac/interpreter/tests/test_interp.py +0 -42
- jaseci/jac/interpreter/walker_interp.py +0 -248
- jaseci/jac/ir/__init__.py +0 -0
- jaseci/jac/ir/ast.py +0 -73
- jaseci/jac/ir/ast_builder.py +0 -249
- jaseci/jac/ir/jac_code.py +0 -152
- jaseci/jac/ir/passes/__init__.py +0 -6
- jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
- jaseci/jac/ir/passes/codegen_pass.py +0 -244
- jaseci/jac/ir/passes/ir_pass.py +0 -29
- jaseci/jac/ir/passes/printer_pass.py +0 -23
- jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
- jaseci/jac/ir/passes/schedule.py +0 -23
- jaseci/jac/ir/passes/stats_pass.py +0 -16
- jaseci/jac/jac.g4 +0 -450
- jaseci/jac/jac_parse/__init__.py +0 -0
- jaseci/jac/jac_parse/jacLexer.py +0 -809
- jaseci/jac/jac_parse/jacListener.py +0 -853
- jaseci/jac/jac_parse/jacParser.py +0 -9192
- jaseci/jac/jac_set.py +0 -119
- jaseci/jac/jsci_vm/__init__.py +0 -0
- jaseci/jac/jsci_vm/disasm.py +0 -94
- jaseci/jac/jsci_vm/inst_ptr.py +0 -31
- jaseci/jac/jsci_vm/machine.py +0 -188
- jaseci/jac/jsci_vm/op_codes.py +0 -82
- jaseci/jac/jsci_vm/tests/__init__.py +0 -0
- jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
- jaseci/jac/machine/__init__.py +0 -0
- jaseci/jac/machine/jac_scope.py +0 -85
- jaseci/jac/machine/jac_value.py +0 -226
- jaseci/jac/machine/machine_state.py +0 -383
- jaseci/jac/tests/__init__.py +0 -0
- jaseci/jac/tests/book_code.py +0 -624
- jaseci/jac/tests/test_book.py +0 -380
- jaseci/jac/tests/test_lang_14.py +0 -49
- jaseci/jsorc/__init__.py +0 -7
- jaseci/jsorc/jsorc.py +0 -642
- jaseci/jsorc/jsorc_settings.py +0 -211
- jaseci/jsorc/jsorc_utils.py +0 -298
- jaseci/jsorc/live_actions.py +0 -364
- jaseci/jsorc/manifests/__init__.py +0 -0
- jaseci/jsorc/manifests/database.yaml +0 -109
- jaseci/jsorc/manifests/elastic.yaml +0 -6024
- jaseci/jsorc/manifests/prometheus.yaml +0 -1383
- jaseci/jsorc/manifests/redis.yaml +0 -64
- jaseci/jsorc/memory.py +0 -258
- jaseci/jsorc/redis.py +0 -139
- jaseci/jsorc/remote_actions.py +0 -157
- jaseci/jsorc/tests/__init__.py +0 -0
- jaseci/jsorc/tests/test_actions.py +0 -542
- jaseci/jsorc/tests/test_jsorc.py +0 -112
- jaseci/prim/__init__.py +0 -0
- jaseci/prim/ability.py +0 -93
- jaseci/prim/architype.py +0 -89
- jaseci/prim/edge.py +0 -172
- jaseci/prim/element.py +0 -233
- jaseci/prim/graph.py +0 -26
- jaseci/prim/master.py +0 -64
- jaseci/prim/node.py +0 -532
- jaseci/prim/obj_mixins.py +0 -235
- jaseci/prim/sentinel.py +0 -281
- jaseci/prim/super_master.py +0 -31
- jaseci/prim/walker.py +0 -261
- jaseci/svc/__init__.py +0 -0
- jaseci/tests/__init__.py +0 -0
- jaseci/tests/infer.py +0 -39
- jaseci/tests/jac_test_code.py +0 -1293
- jaseci/tests/jac_test_progs.py +0 -774
- jaseci/tests/test_core.py +0 -153
- jaseci/tests/test_jac.py +0 -824
- jaseci/tests/test_node.py +0 -89
- jaseci/tests/test_progs.py +0 -702
- jaseci/tests/test_stack.py +0 -220
- jaseci/tests/test_stripe.py +0 -225
- jaseci/utils/__init__.py +0 -0
- jaseci/utils/actions/__init__.py +0 -0
- jaseci/utils/actions/actions_manager.py +0 -254
- jaseci/utils/actions/actions_optimizer.py +0 -516
- jaseci/utils/actions/actions_state.py +0 -95
- jaseci/utils/file_handler.py +0 -171
- jaseci/utils/gprof2dot.py +0 -3786
- jaseci/utils/id_list.py +0 -168
- jaseci/utils/json_handler.py +0 -70
- jaseci/utils/log_utils.py +0 -57
- jaseci/utils/test_core.py +0 -62
- jaseci/utils/utils.py +0 -387
- jaseci-1.4.2.5.dist-info/LICENSE +0 -21
- jaseci-1.4.2.5.dist-info/METADATA +0 -39
- jaseci-1.4.2.5.dist-info/RECORD +0 -184
- jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
- jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
jaseci/extens/api/walker_api.py
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Walker api functions as a mixin
|
|
3
|
-
"""
|
|
4
|
-
from jaseci.extens.api.interface import Interface
|
|
5
|
-
from jaseci.prim.walker import Walker
|
|
6
|
-
from jaseci.prim.node import Node
|
|
7
|
-
from jaseci.prim.sentinel import Sentinel
|
|
8
|
-
from jaseci.utils.id_list import IdList
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class WalkerApi:
|
|
12
|
-
"""
|
|
13
|
-
Walker APIs
|
|
14
|
-
|
|
15
|
-
The walker set of APIs are used for execution and management of walkers. Walkers
|
|
16
|
-
are the primary entry points for running Jac programs. The
|
|
17
|
-
primary API used to run walkers is \\textbf{walker_run}. There are a number of
|
|
18
|
-
variations on this API that enable the invocation of walkers with various
|
|
19
|
-
semantics.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __init__(self):
|
|
23
|
-
self.spawned_walker_ids = IdList(self)
|
|
24
|
-
self.yielded_walkers_ids = IdList(self)
|
|
25
|
-
self.reset_profiling(False)
|
|
26
|
-
|
|
27
|
-
def reset_profiling(self, profiling):
|
|
28
|
-
self._profiling = profiling
|
|
29
|
-
self._jac_profile = {}
|
|
30
|
-
|
|
31
|
-
@Interface.private_api(cli_args=["wlk"])
|
|
32
|
-
def walker_get(self, wlk: Walker, mode: str = "default", detailed: bool = False):
|
|
33
|
-
"""
|
|
34
|
-
Get a walker rendered with specific mode
|
|
35
|
-
Valid modes: {default, code, ir, keys, }
|
|
36
|
-
"""
|
|
37
|
-
if mode == "code":
|
|
38
|
-
return wlk._jac_ast.get_text()
|
|
39
|
-
elif mode == "ir":
|
|
40
|
-
return wlk.ir_dict()
|
|
41
|
-
elif mode == "keys":
|
|
42
|
-
return wlk.namespace_keys()
|
|
43
|
-
else:
|
|
44
|
-
return wlk.serialize(detailed=detailed)
|
|
45
|
-
|
|
46
|
-
@Interface.private_api()
|
|
47
|
-
def walker_total(self, snt: Sentinel = None, detailed: bool = False):
|
|
48
|
-
"""
|
|
49
|
-
Get total walkers known to sentinel
|
|
50
|
-
"""
|
|
51
|
-
objects = snt.arch_ids.obj_list()
|
|
52
|
-
walker_objects = list(filter(lambda obj: obj.kind == "walker", objects))
|
|
53
|
-
return len(walker_objects)
|
|
54
|
-
|
|
55
|
-
@Interface.private_api()
|
|
56
|
-
def walker_list(self, snt: Sentinel = None, detailed: bool = False):
|
|
57
|
-
"""
|
|
58
|
-
List walkers known to sentinel
|
|
59
|
-
"""
|
|
60
|
-
walks = []
|
|
61
|
-
for i in snt.arch_ids.obj_list():
|
|
62
|
-
if i.kind == "walker":
|
|
63
|
-
walks.append(i.serialize(detailed=detailed))
|
|
64
|
-
return walks
|
|
65
|
-
|
|
66
|
-
@Interface.private_api(cli_args=["name"])
|
|
67
|
-
def walker_spawn_create(self, name: str, snt: Sentinel = None):
|
|
68
|
-
"""
|
|
69
|
-
Creates new instance of walker and returns new walker object
|
|
70
|
-
"""
|
|
71
|
-
wlk = snt.run_architype(name=name, kind="walker", caller=self, is_async=False)
|
|
72
|
-
wlk.make_persistent()
|
|
73
|
-
if wlk:
|
|
74
|
-
if self.spawned_walker_ids.has_obj_by_name(name):
|
|
75
|
-
self.spawned_walker_ids.destroy_obj_by_name(name)
|
|
76
|
-
self.spawned_walker_ids.add_obj(wlk)
|
|
77
|
-
self.alias_register(f"spawned:walker:{name}", wlk.jid)
|
|
78
|
-
return wlk.serialize()
|
|
79
|
-
else:
|
|
80
|
-
return ["Walker not found!"]
|
|
81
|
-
|
|
82
|
-
@Interface.private_api()
|
|
83
|
-
def walker_spawn_list(self, detailed: bool = False):
|
|
84
|
-
"""
|
|
85
|
-
List walkers spawned by master
|
|
86
|
-
"""
|
|
87
|
-
walks = []
|
|
88
|
-
for i in self.spawned_walker_ids.obj_list():
|
|
89
|
-
walks.append(i.serialize(detailed=detailed))
|
|
90
|
-
return walks
|
|
91
|
-
|
|
92
|
-
@Interface.private_api(cli_args=["name"])
|
|
93
|
-
def walker_spawn_delete(self, name: str):
|
|
94
|
-
"""
|
|
95
|
-
Delete instance of walker
|
|
96
|
-
"""
|
|
97
|
-
if self.spawned_walker_ids.has_obj_by_name(name):
|
|
98
|
-
self.spawned_walker_ids.destroy_obj_by_name(name)
|
|
99
|
-
self.alias_delete(f"spawned:walker:{name}")
|
|
100
|
-
return [f"Walker {name} deteled!"]
|
|
101
|
-
else:
|
|
102
|
-
return [f"Walker {name} not found!"]
|
|
103
|
-
|
|
104
|
-
@Interface.private_api()
|
|
105
|
-
def walker_spawn_clear(self):
|
|
106
|
-
"""
|
|
107
|
-
Delete instance of walker
|
|
108
|
-
"""
|
|
109
|
-
ret = {"success": True}
|
|
110
|
-
count = len(self.spawned_walker_ids)
|
|
111
|
-
for i in self.spawned_walker_ids.obj_list():
|
|
112
|
-
self.spawned_walker_ids.destroy_obj(i)
|
|
113
|
-
ret["response"] = f"All {count} spawned walkers destroyed."
|
|
114
|
-
return ret
|
|
115
|
-
|
|
116
|
-
@Interface.private_api()
|
|
117
|
-
def walker_yield_list(self, detailed: bool = False):
|
|
118
|
-
"""
|
|
119
|
-
List walkers spawned by master
|
|
120
|
-
"""
|
|
121
|
-
walks = []
|
|
122
|
-
for i in self.yielded_walkers_ids.obj_list():
|
|
123
|
-
walks.append(i.serialize(detailed=detailed))
|
|
124
|
-
return walks
|
|
125
|
-
|
|
126
|
-
@Interface.private_api(cli_args=["name"])
|
|
127
|
-
def walker_yield_delete(self, name: str):
|
|
128
|
-
"""
|
|
129
|
-
Delete instance of walker
|
|
130
|
-
"""
|
|
131
|
-
ret = {"success": True}
|
|
132
|
-
if self.yielded_walkers_ids.has_obj_by_name(name):
|
|
133
|
-
self.yielded_walkers_ids.destroy_obj_by_name(name)
|
|
134
|
-
ret["response"] = f"Walker {name} deteled!"
|
|
135
|
-
else:
|
|
136
|
-
ret["success"] = False
|
|
137
|
-
ret["response"] = f"Walker {name} not found!"
|
|
138
|
-
return ret
|
|
139
|
-
|
|
140
|
-
@Interface.private_api()
|
|
141
|
-
def walker_yield_clear(self):
|
|
142
|
-
"""
|
|
143
|
-
Delete instance of walker
|
|
144
|
-
"""
|
|
145
|
-
ret = {"success": True}
|
|
146
|
-
count = len(self.yielded_walkers_ids)
|
|
147
|
-
for i in self.yielded_walkers_ids.obj_list():
|
|
148
|
-
self.yielded_walkers_ids.destroy_obj(i)
|
|
149
|
-
ret["response"] = f"All {count} yielded walkers destroyed."
|
|
150
|
-
return ret
|
|
151
|
-
|
|
152
|
-
@Interface.private_api(cli_args=["wlk"])
|
|
153
|
-
def walker_prime(
|
|
154
|
-
self, wlk: Walker, nd: Node = None, ctx: dict = {}, _req_ctx: dict = {}
|
|
155
|
-
):
|
|
156
|
-
"""
|
|
157
|
-
Assigns walker to a graph node and primes walker for execution
|
|
158
|
-
"""
|
|
159
|
-
wlk.prime(nd, prime_ctx=ctx, request_ctx=_req_ctx)
|
|
160
|
-
return [f"Walker primed on node {nd.id}"]
|
|
161
|
-
|
|
162
|
-
@Interface.private_api(cli_args=["wlk"])
|
|
163
|
-
def walker_execute(
|
|
164
|
-
self,
|
|
165
|
-
wlk: Walker,
|
|
166
|
-
prime: Node = None,
|
|
167
|
-
ctx: dict = {},
|
|
168
|
-
_req_ctx: dict = {},
|
|
169
|
-
profiling: bool = False,
|
|
170
|
-
):
|
|
171
|
-
"""
|
|
172
|
-
Executes walker (assumes walker is primed)
|
|
173
|
-
"""
|
|
174
|
-
self.reset_profiling(profiling)
|
|
175
|
-
return wlk.run(
|
|
176
|
-
start_node=prime, prime_ctx=ctx, request_ctx=_req_ctx, profiling=profiling
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
@Interface.private_api(cli_args=["wlk"])
|
|
180
|
-
def walker_step(self, wlk: Walker, detailed: bool = False):
|
|
181
|
-
"""
|
|
182
|
-
Executes walker (assumes walker is primed)
|
|
183
|
-
"""
|
|
184
|
-
wlk.step()
|
|
185
|
-
ret = {
|
|
186
|
-
"current_node": wlk.current_node.serialize(detailed=detailed),
|
|
187
|
-
"next_node_ids": wlk.next_node_ids,
|
|
188
|
-
"walker_context": wlk.serialize(detailed=detailed)["context"],
|
|
189
|
-
"walker_report": wlk.report,
|
|
190
|
-
"profile": wlk.profile,
|
|
191
|
-
}
|
|
192
|
-
return ret
|
|
193
|
-
|
|
194
|
-
@Interface.private_api(cli_args=["name"])
|
|
195
|
-
def walker_run(
|
|
196
|
-
self,
|
|
197
|
-
name: str,
|
|
198
|
-
nd: Node = None,
|
|
199
|
-
ctx: dict = {},
|
|
200
|
-
_req_ctx: dict = {},
|
|
201
|
-
snt: Sentinel = None,
|
|
202
|
-
profiling: bool = False,
|
|
203
|
-
is_async: bool = None,
|
|
204
|
-
):
|
|
205
|
-
"""
|
|
206
|
-
Creates walker instance, primes walker on node, executes walker,
|
|
207
|
-
reports results, and cleans up walker instance.
|
|
208
|
-
"""
|
|
209
|
-
self.reset_profiling(profiling)
|
|
210
|
-
wlk = self.yielded_walkers_ids.get_obj_by_name(name, silent=True)
|
|
211
|
-
if wlk is None:
|
|
212
|
-
wlk = snt.run_architype(
|
|
213
|
-
name=name, kind="walker", caller=self, is_async=is_async
|
|
214
|
-
)
|
|
215
|
-
if wlk is None:
|
|
216
|
-
return self.bad_walk_response([f"Walker {name} not found!"])
|
|
217
|
-
res = self.walker_execute(
|
|
218
|
-
wlk=wlk, prime=nd, ctx=ctx, _req_ctx=_req_ctx, profiling=profiling
|
|
219
|
-
)
|
|
220
|
-
wlk.register_yield_or_destroy(self.yielded_walkers_ids)
|
|
221
|
-
return res
|
|
222
|
-
|
|
223
|
-
@Interface.private_api(cli_args=["name"], url_args=["name"])
|
|
224
|
-
def wapi(
|
|
225
|
-
self,
|
|
226
|
-
name: str,
|
|
227
|
-
nd: Node = None,
|
|
228
|
-
ctx: dict = {},
|
|
229
|
-
_req_ctx: dict = {},
|
|
230
|
-
snt: Sentinel = None,
|
|
231
|
-
profiling: bool = False,
|
|
232
|
-
):
|
|
233
|
-
"""
|
|
234
|
-
Walker individual APIs
|
|
235
|
-
"""
|
|
236
|
-
self.reset_profiling(profiling)
|
|
237
|
-
return self.walker_run(name, nd, ctx, _req_ctx, snt, profiling)
|
|
238
|
-
|
|
239
|
-
@Interface.public_api(cli_args=["wlk"])
|
|
240
|
-
def walker_summon(
|
|
241
|
-
self,
|
|
242
|
-
key: str,
|
|
243
|
-
wlk: Walker,
|
|
244
|
-
nd: Node,
|
|
245
|
-
ctx: dict = {},
|
|
246
|
-
_req_ctx: dict = {},
|
|
247
|
-
global_sync: bool = True,
|
|
248
|
-
):
|
|
249
|
-
"""
|
|
250
|
-
Public api for running walkers, namespace key must be provided
|
|
251
|
-
along with the walker id and node id
|
|
252
|
-
"""
|
|
253
|
-
if key not in wlk.namespace_keys().values():
|
|
254
|
-
return self.bad_walk_response(["Not authorized to execute this walker"])
|
|
255
|
-
if global_sync:
|
|
256
|
-
# Deprecated Walkers are always synced with sentinel now
|
|
257
|
-
pass
|
|
258
|
-
|
|
259
|
-
walk = wlk.duplicate()
|
|
260
|
-
res = self.walker_execute(
|
|
261
|
-
wlk=walk, prime=nd, ctx=ctx, _req_ctx=_req_ctx, profiling=False
|
|
262
|
-
)
|
|
263
|
-
walk.destroy()
|
|
264
|
-
return res
|
|
265
|
-
|
|
266
|
-
@Interface.public_api(url_args=["nd", "wlk"], allowed_methods=["post", "get"])
|
|
267
|
-
def walker_callback(
|
|
268
|
-
self,
|
|
269
|
-
nd: Node,
|
|
270
|
-
wlk: Walker,
|
|
271
|
-
key: str,
|
|
272
|
-
ctx: dict = {},
|
|
273
|
-
_req_ctx: dict = {},
|
|
274
|
-
global_sync: bool = True,
|
|
275
|
-
):
|
|
276
|
-
"""
|
|
277
|
-
Public api for running walkers, namespace key must be provided
|
|
278
|
-
along with the walker id and node id
|
|
279
|
-
"""
|
|
280
|
-
|
|
281
|
-
return self.walker_summon(
|
|
282
|
-
nd=nd,
|
|
283
|
-
wlk=wlk,
|
|
284
|
-
key=key,
|
|
285
|
-
ctx=ctx,
|
|
286
|
-
_req_ctx=_req_ctx,
|
|
287
|
-
global_sync=global_sync,
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
def destroy(self):
|
|
291
|
-
"""
|
|
292
|
-
Destroys self from memory and persistent storage
|
|
293
|
-
"""
|
|
294
|
-
for i in self.spawned_walker_ids.obj_list():
|
|
295
|
-
i.destroy()
|
|
296
|
-
|
|
297
|
-
def bad_walk_response(self, errors=list()):
|
|
298
|
-
return {"report": [], "success": False, "errors": errors}
|
jaseci/extens/api/webhook_api.py
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Webhook API
|
|
3
|
-
"""
|
|
4
|
-
from jaseci.extens.api.interface import Interface
|
|
5
|
-
from fastapi import HTTPException
|
|
6
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
7
|
-
from jaseci.extens.svc.stripe_svc import StripeService
|
|
8
|
-
|
|
9
|
-
import stripe as _stripe
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class WebhookApi:
|
|
13
|
-
"""
|
|
14
|
-
Webhook API
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
@Interface.public_api(url_args=["provider"], allowed_methods=["post"])
|
|
18
|
-
def webhook(self, provider: str, _req_ctx: dict = {}):
|
|
19
|
-
"""Handle webhook logic"""
|
|
20
|
-
req_body = _req_ctx["body"]
|
|
21
|
-
|
|
22
|
-
if provider == "stripe":
|
|
23
|
-
stripe_service = JsOrc.svc("stripe", StripeService)
|
|
24
|
-
stripe = stripe_service.poke(_stripe)
|
|
25
|
-
|
|
26
|
-
# to be updated
|
|
27
|
-
stripe_service.get_event(
|
|
28
|
-
self._h.get_file_handler(_req_ctx["raw"]).to_bytes(),
|
|
29
|
-
_req_ctx["headers"],
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
payload_obj = req_body.get("data").get("object")
|
|
33
|
-
payload_meta = payload_obj.get("metadata")
|
|
34
|
-
|
|
35
|
-
customer_id = payload_obj.get("customer")
|
|
36
|
-
customer_meta = (
|
|
37
|
-
stripe.Customer.retrieve(id=customer_id).get("metadata")
|
|
38
|
-
if customer_id
|
|
39
|
-
else {}
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
master_id = payload_meta.get("master") or customer_meta.get("master")
|
|
43
|
-
master = self._h.get_obj(master_id, master_id)
|
|
44
|
-
|
|
45
|
-
node_id = payload_meta.get("node") or customer_meta.get("node")
|
|
46
|
-
if not node_id:
|
|
47
|
-
node_id = master.active_gph_id
|
|
48
|
-
node = self._h.get_obj(master_id, node_id)
|
|
49
|
-
|
|
50
|
-
sentinel_id = (
|
|
51
|
-
payload_meta.get("sentinel")
|
|
52
|
-
or customer_meta.get("sentinel")
|
|
53
|
-
or master.active_snt_id
|
|
54
|
-
or self._h.get_glob("GLOB_SENTINEL")
|
|
55
|
-
)
|
|
56
|
-
sentinel = self._h.get_obj(
|
|
57
|
-
master_id,
|
|
58
|
-
self._h.get_glob("GLOB_SENTINEL")
|
|
59
|
-
if sentinel_id == "global"
|
|
60
|
-
else sentinel_id,
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
payload = {"event": req_body}
|
|
64
|
-
self.seek_committer(master)
|
|
65
|
-
|
|
66
|
-
wlk = stripe_service.get_walker(req_body["type"])
|
|
67
|
-
|
|
68
|
-
return master.walker_run(
|
|
69
|
-
name=wlk, nd=node, ctx=payload, _req_ctx=_req_ctx, snt=sentinel
|
|
70
|
-
)
|
|
71
|
-
else:
|
|
72
|
-
raise HTTPException(
|
|
73
|
-
status_code=400, detail=str(provider + " webhook is not yet supported")
|
|
74
|
-
)
|
jaseci/extens/svc/__init__.py
DELETED
|
File without changes
|