MCPcopy Create free account
hub / github.com/StackStorm/st2 / validate_action

Function validate_action

st2common/st2common/validators/api/action.py:35–60  ·  view source on GitHub ↗

:param runner_type_db: RunnerTypeDB object belonging to this action. If not provided, it's retrieved from the database. :type runner_type_db: :class:`RunnerTypeDB`

(action_api, runner_type_db=None)

Source from the content-addressed store, hash-verified

33
34
35def validate_action(action_api, runner_type_db=None):
36 """
37 :param runner_type_db: RunnerTypeDB object belonging to this action. If not provided, it's
38 retrieved from the database.
39 :type runner_type_db: :class:`RunnerTypeDB`
40 """
41 if not runner_type_db:
42 runner_db = get_runner_model(action_api)
43 else:
44 runner_db = runner_type_db
45
46 # Check if pack is valid.
47 if not _is_valid_pack(action_api.pack):
48 packs_base_paths = get_packs_base_paths()
49 packs_base_paths = ",".join(packs_base_paths)
50 msg = (
51 'Content pack "%s" is not found or doesn\'t contain actions directory. '
52 "Searched in: %s" % (action_api.pack, packs_base_paths)
53 )
54 raise ValueValidationException(msg)
55
56 # Check if parameters defined are valid.
57 action_ref = ResourceReference.to_string_reference(
58 pack=action_api.pack, name=action_api.name
59 )
60 _validate_parameters(action_ref, action_api.parameters, runner_db.runner_parameters)
61
62
63def get_runner_model(action_api):

Callers

nothing calls this directly

Calls 6

get_packs_base_pathsFunction · 0.90
get_runner_modelFunction · 0.85
_is_valid_packFunction · 0.85
_validate_parametersFunction · 0.85
to_string_referenceMethod · 0.45

Tested by

no test coverage detected