Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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'])
@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)
@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
@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}
@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)
@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,
@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)
@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)
}
@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)
@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)