def take_action(self, parsed_args): parsed_args = CreateTokenFormatOne.before_take_action( self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) # Allow prompt for password when not specified passwd = parsed_args.tapis_password if passwd is None: passwd = prompt('Password', passwd, secret=True) headers = SearchableCommand.headers(self, Token, parsed_args) try: self.tapis_client.token.password = passwd result = self.tapis_client.token.create() self.tapis_client.token.password = None except HTTPError as h: if str(h).startswith('400'): raise AgaveError( 'Failed to create a token pair: {0}'.format(h)) else: raise AgaveError(str(h)) result = list() for h in headers: result.append(self.tapis_client.token.token_info.get(h)) return (tuple(headers), tuple(result))
def take_action(self, parsed_args): parsed_args = AppsFormatMany.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) # Map properties set in parsed_args to a query payload for search filters = list() for sarg_name, sarg in self.search_args.items(): # raise SystemError(sarg.destination) parsed_args_val = getattr(parsed_args, sarg.destination, None) if parsed_args_val: filt = sarg.get_param(parsed_args_val) filters.append(filt) for f in filters: k = list(f.keys())[0] v = f[k] self.post_payload[k] = v headers = SearchableCommand.headers(self, App, parsed_args) results = self.requests_client.get_data(params=self.post_payload) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = MetadataFormatMany.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION, 'data') self.take_action_defaults(parsed_args) # Map properties set in parsed_args to a payload for the 'q' param # Note that this is different from how we usually construct the # parameters payload! filters = list() mongoql_els = dict() for sarg_name, sarg in self.search_args.items(): # raise SystemError(sarg.destination) parsed_args_val = getattr(parsed_args, sarg.destination, None) if parsed_args_val: filt = sarg.get_param(parsed_args_val) filters.append(filt) for f in filters: k = list(f.keys())[0] v = f[k] mongoql_els[k] = v self.post_payload['q'] = json.dumps(mongoql_els) headers = SearchableCommand.headers(self, Metadata, parsed_args) results = self.requests_client.get_data(params=self.post_payload) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = ProfilesFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) headers = SearchableCommand.headers(self, Profile, parsed_args) rec = self.tapis_client.profiles.get() data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = AppsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) headers = SearchableCommand.headers(self, App, parsed_args) rec = self.tapis_client.apps.manage(appId=parsed_args.identifier, body={'action': 'enable'}) data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = MetadataFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION, 'data') self.take_action_defaults(parsed_args) headers = SearchableCommand.headers(self, Metadata, parsed_args) rec = self.tapis_client.meta.getMetadata(uuid=parsed_args.identifier) data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = JobsFormatOne.before_take_action(self, parsed_args) API_PATH = '{0}/resubmit'.format(parsed_args.identifier) self.requests_client.setup(API_NAME, SERVICE_VERSION, API_PATH) headers = SearchableCommand.headers(self, Job, parsed_args) rec = self.requests_client.post(content_type='application/json') data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = JobsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.handle_file_upload(parsed_args) headers = SearchableCommand.headers(self, Job, parsed_args) rec = self.tapis_client.jobs.submit(body=self.json_file_contents) data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = SystemsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) headers = SearchableCommand.headers(self, System, parsed_args) rec = self.tapis_client.systems.manage(systemId=parsed_args.identifier, body={'action': 'unpublish'}) data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = AppsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) headers = SearchableCommand.headers(self, App, parsed_args) mgt_body = {'action': 'publish'} if parsed_args.public_execution_system is not None: mgt_body['executionSystem'] = parsed_args.public_execution_system rec = self.tapis_client.apps.manage(appId=parsed_args.identifier, body=mgt_body) data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = AppsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) headers = SearchableCommand.headers(self, App, parsed_args) rec = self.tapis_client.apps.get(appId=parsed_args.identifier) data = [] for key in headers: try: val = rec[key] except KeyError: val = None data.append(self.render_value(val)) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = ProfilesFormatMany.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) headers = SearchableCommand.headers(self, Profile, parsed_args) results = self.requests_client.get_data(params=self.post_payload) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = SystemsFormatMany.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) headers = SearchableCommand.headers(self, SystemRole, parsed_args) results = self.tapis_client.systems.listRoles( systemId=parsed_args.identifier) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = AppsFormatMany.before_take_action(self, parsed_args) api_resource = '{0}/history'.format(parsed_args.identifier) self.requests_client.setup(API_NAME, SERVICE_VERSION, api_resource) headers = SearchableCommand.headers(self, AppHistory, parsed_args) results = self.requests_client.get_data(params=self.post_payload) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = SystemsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) # List roles on the System to show the new role headers = SearchableCommand.headers(self, SystemRole, parsed_args) rec = self.tapis_client.systems.deleteRoleForUser( systemId=parsed_args.identifier, username=parsed_args.username) if rec is None: data = [parsed_args.username, None] else: raise AgaveError('Failed to revoke role from {0}'.format( parsed_args.identifier)) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = SystemsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) role = parsed_args.role body = {'username': parsed_args.username, 'role': role.upper()} # List roles on the System to show the new role headers = SearchableCommand.headers(self, SystemRole, parsed_args) rec = self.tapis_client.systems.updateRole( systemId=parsed_args.identifier, body=body)[0] data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = JobsHistoryFormatMany.before_take_action( self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) headers = SearchableCommand.headers(self, JobHistory, parsed_args) results = self.tapis_client.jobs.getHistory( jobId=parsed_args.identifier) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = TokenFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) headers = SearchableCommand.headers(self, Token, parsed_args) try: result = self.tapis_client.token.refresh() except HTTPError as h: if str(h).startswith('400'): raise AgaveError( 'Failed to refresh token. Try "tapis sessions token create"' ) else: raise AgaveError(str(h)) result = list() for h in headers: result.append(self.tapis_client.token.token_info.get(h)) return (tuple(headers), tuple(result))
def take_action(self, parsed_args): parsed_args = SystemsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) headers = SearchableCommand.headers(self, SystemRole, parsed_args) try: rec = self.tapis_client.systems.getRoleForUser( systemId=parsed_args.identifier, username=parsed_args.username) except Exception: rec = { 'username': parsed_args.username, 'role': None, '_links': [] } data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = JobsFormatOne.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) rec = self.tapis_client.jobs.get(jobId=parsed_args.identifier) if not parsed_args.job_template: headers = SearchableCommand.headers(self, Job, parsed_args) else: if self.formatter_default != 'json': raise ValueError( 'JSON output must be specified with --format json or -v option' ) else: headers = Job.TEMPLATE_KEYS rec = Job.transform_response(rec) data = [] for key in headers: val = self.render_value(rec.get(key, None)) data.append(val) return (tuple(headers), tuple(data))
def take_action(self, parsed_args): parsed_args = SystemsFormatMany.before_take_action(self, parsed_args) self.requests_client.setup(API_NAME, SERVICE_VERSION) self.take_action_defaults(parsed_args) drop_result = self.tapis_client.systems.deleteRoles( systemId=parsed_args.identifier) if drop_result is not None: raise AgaveError('Failed to drop roles on {0}'.format( systemId=parsed_args.identifier)) # Go ahead and list - should only return owner's role headers = SearchableCommand.headers(self, SystemRole, parsed_args) results = self.tapis_client.systems.listRoles( systemId=parsed_args.identifier) records = [] for rec in results: record = [] for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) records.append(record) return (tuple(headers), tuple(records))