def from_swagger_model(self, api_model, user=None): self.name = api_model.name self.created = api_model.created if has_permission(user, Permissions.StoreSecretAccess): self.store_type = api_model.store_type self.store_data = api_model.store_data
def from_swagger_model(self, api_model, user=None): model = api_model # type: FileDetailed self.uid = model.uid self.name = model.name if has_permission(user, Permissions.StoreSecretAccess): self.store_data = model.store_data return self
def decorated(*args, **kwargs): # Need to be logged in if keyword_arg not in kwargs: return authenticate() user = kwargs[keyword_arg] if permissions.has_permission(user, permission): return f(*args, **kwargs) return missing_permission()
def from_swagger_model(self, api_model, user=None): model = api_model # type: BagStoreDetailed self.name = model.name self.description = model.description self.created = model.created self.store_type = model.store_type if has_permission(user, Permissions.StoreSecretAccess): self.store_data = model.store_data return self
def from_swagger_model(self, api_model, user=None): model = api_model # type: SimulationEnvironmentDetailed self.name = model.name self.module = model.module_name if has_permission( user, Permissions.SimulationEnvironmentConfigurationAccess): self.configuration = model.config self.example_configuration = model.example_config return model
def to_swagger_model(self, user=None): data = {'_hidden': True} if has_permission(user, Permissions.StoreSecretAccess): data = self.store_data data['_hidden'] = False return SwaggerFileStore( name=self.name, store_type=self.store_type, store_data=data, created=self.created )
def from_swagger_model(self, api_model, user=None): model = api_model # type: BagDetailed self.name = model.name if has_permission(user, Permissions.StoreSecretAccess): self.store_data = model.store_data self.discovered = model.discovered.replace( tzinfo=None) if model.discovered else None self.is_extracted = model.is_extracted self.in_trash = model.in_trash self.extraction_failure = model.extraction_failure self.meta_available = model.meta_available self.size = model.size self.start_time = model.start_time.replace( tzinfo=None) if model.start_time else None self.end_time = model.end_time.replace( tzinfo=None) if model.end_time else None self.duration = model.duration self.messages = model.messages self.comment = model.comment return self
def from_swagger_model(self, api_model, user=None): model = api_model # type: TaskDetailed self.configuration = model.config if has_permission(user, Permissions.QueueResultAccess): self.result = model.result self.log = model.log self.priority = model.priority self.description = model.description self.assigned_to = model.assigned_to self.created = model.created.replace(tzinfo=None) self.last_updated = model.last_updated.replace(tzinfo=None) self.state = model.state self.task = model.task self.success = model.success self.runtime = model.runtime self.worker_labels = model.worker_labels return self
def get_configuration_key(config_key, user=None): # noqa: E501 """Get configuration key # noqa: E501 :param config_key: Configuration key to read :type config_key: str :rtype: str """ session = Database.get_session() try: dictionary = ConfigKeyValue.get_config_dict(config_key, session) # Wipe out secure if not permissions.has_permission( user, permissions.Permissions.SystemConfigurationSecretAccess): del dictionary['secret'] return dictionary, 200 except Exception as e: session.rollback() return error_helper.handle_exception(e)