MCPcopy Index your code
hub / github.com/StackStorm/st2 / run

Method run

st2client/st2client/commands/auth.py:452–488  ·  view source on GitHub ↗
(self, args, **kwargs)

Source from the content-addressed store, hash-verified

450
451 @resource.add_auth_token_to_kwargs_from_cli
452 def run(self, args, **kwargs):
453 resources = resource.load_meta_file(args.file)
454 if not resources:
455 print(
456 "No %s found in %s."
457 % (self.resource.get_display_name().lower(), args.file)
458 )
459 return None
460 if not isinstance(resources, list):
461 resources = [resources]
462 instances = []
463 for res in resources:
464 # pick only the meaningful properties.
465 data = {
466 "user": res["user"], # required
467 "key_hash": res["key_hash"], # required
468 "metadata": res.get("metadata", {}),
469 "enabled": res.get("enabled", False),
470 }
471
472 if "id" in res:
473 data["id"] = res["id"]
474
475 instance = self.resource.deserialize(data)
476
477 try:
478 result = self.manager.update(instance, **kwargs)
479 except requests.exceptions.HTTPError as e:
480 if e.response.status_code == http_client.NOT_FOUND:
481 instance = self.resource.deserialize(data)
482 # Key doesn't exist yet, create it instead
483 result = self.manager.create(instance, **kwargs)
484 else:
485 raise e
486
487 instances.append(result)
488 return instances
489
490 def run_and_print(self, args, **kwargs):
491 instances = self.run(args, **kwargs)

Callers 1

run_and_printMethod · 0.95

Calls 5

get_display_nameMethod · 0.80
deserializeMethod · 0.80
createMethod · 0.80
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected