def take_action(self, parsed_args): parsed_args = self.preprocess_args(parsed_args) identifier = MetadataUUID.get_identifier(self, parsed_args) body = {'username': parsed_args.username, 'permission': 'NONE'} revoke_result = self.tapis_client.meta.updateMetadataPermissions( uuid=identifier, body=body) headers = self.render_headers(Permission, parsed_args) results = self.tapis_client.meta.listMetadataPermissions( uuid=identifier) records = [] for rec in results: record = [] # Table display if self.app_verbose_level > self.VERBOSITY: record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) # Deal with an API-side bug where >1 identical pems are # returned for the owning user when no additional pems have been # granted on the app if record not in records: records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = self.preprocess_args(parsed_args) identifier = JobsUUID.get_identifier(self, parsed_args) self.update_payload(parsed_args) headers = self.render_headers(Permission, parsed_args) rec = self.tapis_client.meta.listPermissionsForUser( jobId=identifier, username=parsed_args.username) # TODO - Account for the wierd behavior where querying ANY username # will return +rwx even if the username is fictitious. A client-side # (partial) would be to list the pems, extract the usernames, and # validate presence of <username> among the. Another would be to # simply list all pems and extract the matching row by <username> record = [] if self.app_verbose_level > self.VERBOSITY: # Table display record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: # Verbose JSON display for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) return (headers, record)
def take_action(self, parsed_args): parsed_args = FilesPemsFormatMany.preprocess_args(self, parsed_args) headers = Permission.get_headers(self, self.VERBOSITY, parsed_args.formatter) self.update_payload(parsed_args) (storage_system, file_path) = AgaveURI.parse_url(parsed_args.agave_uri) results = pems_list(file_path, system_id=storage_system, limit=parsed_args.limit, offset=parsed_args.offset, permissive=False, agave=self.tapis_client) records = [] for rec in results: record = [] # Table display if self.app_verbose_level > self.VERBOSITY: record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) # Deal with an API-side bug where >1 identical pems are # returned for the owning user when no additional pems have been # granted on the app if record not in records: records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = self.preprocess_args(parsed_args) (storage_system, file_path) = self.parse_url(parsed_args.agave_uri) headers = self.render_headers(Permission, parsed_args) drop_result = self.tapis_client.files.deletePermissions( systemId=storage_system, filePath=file_path) # List now that the drop is complete results = pems_list(file_path, system_id=storage_system, agave=self.tapis_client) records = [] for rec in results: record = [] # Table display if self.app_verbose_level > self.VERBOSITY: record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) # Deal with an API-side bug where >1 identical pems are # returned for the owning user when no additional pems have been # granted on the app if record not in records: records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = self.preprocess_args(parsed_args) app_id = AppIdentifier.get_identifier(self, parsed_args) headers = self.render_headers(Permission, parsed_args) drop_result = self.tapis_client.apps.deletePermissions(appId=app_id) results = self.tapis_client.apps.listPermissions(appId=app_id) records = [] for rec in results: record = [] # Table display if self.app_verbose_level > self.VERBOSITY: record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) # Deal with an API-side bug where >1 identical pems are # returned for the owning user when no additional pems have been # granted on the app if record not in records: records.append(record) return (tuple(headers), tuple(records))
def take_action(self, parsed_args): parsed_args = self.preprocess_args(parsed_args) app_id = AppIdentifier.get_identifier(self, parsed_args) # Below is call to the AgavePy method but it is broken due to changes in behavior # between Py2 and Py3. It returns an wierdly iterated dict object: # # {'u': 'username', 's': 'username', 'e': 'username', 'r': 'username', 'n': 'username', 'a': 'username', 'm': 'username'} # rather than the expected dict of username & permission object # # rec = self.tapis_client.apps.listPermissionsForUser( # appId=app_id, username=parsed_args.username) # # Instead, we use the Command's requests client which returns a # very simple response: # {"username": "******", # "permission": {"write": bool, "read": bool, "exceute": bool, "_links": []} # API_PATH = '{0}/pems/{1}'.format(app_id, parsed_args.username) self.requests_client.setup(API_NAME, SERVICE_VERSION, API_PATH) headers = self.render_headers(Permission, parsed_args) rec = self.requests_client.get_data(params=self.post_payload) # TODO - Account for the wierd behavior where querying ANY username # will return +rwx even if the username is fictitious. A client-side # (partial) would be to list the pems, extract the usernames, and # validate presence of <username> among the. Another would be to # simply list all pems and extract the matching row by <username> record = [] if self.app_verbose_level > self.VERBOSITY: # Table display record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: # Verbose JSON display for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) return (headers, record)
def take_action(self, parsed_args): parsed_args = self.preprocess_args(parsed_args) self.update_payload(parsed_args) # We use the Command's requests client since file permissions lookup # by user are not supported via the documented API spec. # # Reponse: {"username": "******", # "permission": {"write": bool, "read": bool, # "exceute": bool, "_links": []} # # <api_server>/files/v2/pems/system/data-sd2e-community/path # (storage_system, file_path) = self.parse_url(parsed_args.agave_uri) API_PATH = 'pems/system/{0}{1}'.format(storage_system, file_path) self.requests_client.setup(API_NAME, SERVICE_VERSION, API_PATH) post_payload = {'username.eq': parsed_args.username} headers = self.render_headers(Permission, parsed_args) rec = self.requests_client.get_data(params=post_payload)[0] # TODO - Account for the wierd behavior where querying ANY username # will return -r-w-x even if the username is fictitious. A client-side # (partial) fix would be to list the pems, extract the usernames, and # validate presence of <username> among the. Another would be to # simply list all pems and extract the matching row by <username> record = [] if self.app_verbose_level > self.VERBOSITY: # Table display record.append(rec.get('username')) record.extend(Permission.pem_to_row(rec.get('permission', {}))) else: # Verbose JSON display for key in headers: val = self.render_value(rec.get(key, None)) record.append(val) return (headers, record)