How to use the st2client.commands.resource.add_auth_token_to_kwargs_from_cli function in st2client

To help you get started, we’ve selected a few st2client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github StackStorm / st2 / st2client / st2client / commands / triggerinstance.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run_and_print(self, args, **kwargs):
        ret = self.run(args, **kwargs)
        if 'message' in ret:
            print(ret['message'])
github StackStorm / st2 / st2client / st2client / commands / trace.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run(self, args, **kwargs):
        resource_id = getattr(args, self.pk_argument_name, None)
        return self.get_resource_by_id(resource_id, **kwargs)
github StackStorm / st2 / st2client / st2client / commands / action_alias.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run(self, args, **kwargs):
        payload = core.Resource()
        payload.command = args.command_text
        payload.user = args.user
        payload.source_channel = 'cli'

        alias_execution_mgr = self.app.client.managers['ActionAliasExecution']
        execution = alias_execution_mgr.match_and_execute(payload)
        return execution
github StackStorm / st2 / st2client / st2client / commands / triggerinstance.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run(self, args, **kwargs):
        # Filtering options
        if args.trigger:
            kwargs['trigger'] = args.trigger
        if args.timestamp_gt:
            kwargs['timestamp_gt'] = args.timestamp_gt
        if args.timestamp_lt:
            kwargs['timestamp_lt'] = args.timestamp_lt
        if args.status:
            kwargs['status'] = args.status

        include_attributes = self._get_include_attributes(args=args)
        if include_attributes:
            include_attributes = ','.join(include_attributes)
            kwargs['params'] = {'include_attributes': include_attributes}
github StackStorm / st2 / st2client / st2client / commands / trigger.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run_and_print(self, args, **kwargs):
        if args.help:
            self.parser.print_help()
            return
        instances = self.run(args, **kwargs)
        self.print_output(instances, table.MultiColumnTable, json=args.json, yaml=args.yaml)
github StackStorm / st2 / st2client / st2client / commands / keyvalue.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run_and_print(self, args, **kwargs):
        instances, count = self.run(args, **kwargs)
        if args.json or args.yaml:
            self.print_output(
                reversed(instances),
                table.MultiColumnTable,
                attributes=args.attr,
                widths=args.width,
                json=args.json,
                yaml=args.yaml,
                attribute_transform_functions=self.attribute_transform_functions,
            )
        else:
            self.print_output(
                instances,
                table.MultiColumnTable,
github StackStorm / st2 / st2client / st2client / commands / policy.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run(self, args, **kwargs):
        if args.resource_type:
            filters = {'resource_type': args.resource_type}
            filters.update(**kwargs)
            instances = self.manager.query(**filters)
            return instances
        else:
            return self.manager.get_all(**kwargs)
github StackStorm / st2 / st2client / st2client / commands / auth.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run(self, args, **kwargs):
        resources = resource.load_meta_file(args.file)
        if not resources:
            print('No %s found in %s.' % (self.resource.get_display_name().lower(), args.file))
            return None
        if not isinstance(resources, list):
            resources = [resources]
        instances = []
        for res in resources:
            # pick only the meaningful properties.
            data = {
                'user': res['user'],  # required
                'key_hash': res['key_hash'],  # required
                'metadata': res.get('metadata', {}),
                'enabled': res.get('enabled', False)
            }
github StackStorm / st2 / st2client / st2client / commands / timer.py View on Github external
    @resource.add_auth_token_to_kwargs_from_cli
    def run(self, args, **kwargs):
        if args.timer_type:
            kwargs['timer_type'] = args.timer_type

        if kwargs:
            return self.manager.query(**kwargs)
        else:
            return self.manager.get_all(**kwargs)
github StackStorm / st2 / st2client / st2client / commands / action.py View on Github external
    @add_auth_token_to_kwargs_from_cli
    def run_and_print(self, args, **kwargs):
        try:
            execution = self.run(args, **kwargs)

            if not args.json and not args.yaml:
                # Include elapsed time for running executions
                execution = format_execution_status(execution)
        except resource.ResourceNotFoundError:
            self.print_not_found(args.id)
            raise ResourceNotFoundError('Execution with id %s not found.' % (args.id))
        return self._print_execution_details(execution=execution, args=args, **kwargs)