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

Class PackResourceManager

st2client/st2client/models/core.py:639–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637
638
639class PackResourceManager(ResourceManager):
640 @add_auth_token_to_kwargs_from_env
641 def install(self, packs, force=False, skip_dependencies=False, **kwargs):
642 url = "/%s/install" % (self.resource.get_url_path_name())
643 payload = {
644 "packs": packs,
645 "force": force,
646 "skip_dependencies": skip_dependencies,
647 }
648 response = self.client.post(url, payload, **kwargs)
649 if response.status_code != http_client.OK:
650 self.handle_error(response)
651 instance = AsyncRequest.deserialize(parse_api_response(response))
652 return instance
653
654 @add_auth_token_to_kwargs_from_env
655 def remove(self, packs, **kwargs):
656 url = "/%s/uninstall" % (self.resource.get_url_path_name())
657 response = self.client.post(url, {"packs": packs}, **kwargs)
658 if response.status_code != http_client.OK:
659 self.handle_error(response)
660 instance = AsyncRequest.deserialize(parse_api_response(response))
661 return instance
662
663 @add_auth_token_to_kwargs_from_env
664 def search(self, args, ignore_errors=False, **kwargs):
665 url = "/%s/index/search" % (self.resource.get_url_path_name())
666 if "query" in vars(args):
667 payload = {"query": args.query}
668 else:
669 payload = {"pack": args.pack}
670
671 response = self.client.post(url, payload, **kwargs)
672
673 if response.status_code != http_client.OK:
674 if ignore_errors:
675 return None
676
677 self.handle_error(response)
678 data = parse_api_response(response)
679 if isinstance(data, list):
680 return [self.resource.deserialize(item) for item in data]
681 else:
682 return self.resource.deserialize(data) if data else None
683
684 @add_auth_token_to_kwargs_from_env
685 def register(self, packs=None, types=None, **kwargs):
686 url = "/%s/register" % (self.resource.get_url_path_name())
687 payload = {}
688 if types:
689 payload["types"] = types
690 if packs:
691 payload["packs"] = packs
692 response = self.client.post(url, payload, **kwargs)
693 if response.status_code != http_client.OK:
694 self.handle_error(response)
695 instance = self.resource.deserialize(parse_api_response(response))
696 return instance

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected