def get_data(self, session): return_internal = is_boolean( self.server.fs_server_config.misc.return_internal_objects) internal_del = is_boolean( self.server.fs_server_config.misc.internal_services_may_be_deleted) out = [] search_result = self._search(service_list, session, self.request.input.cluster_id, return_internal, False) for item in elems_with_opaque(search_result): item.may_be_deleted = internal_del if item.is_internal else True item.usage = self.server.kvdb.conn.get('{}{}'.format( KVDB.SERVICE_USAGE, item.name)) or 0 # Attach JSON Schema validation configuration json_schema_config = get_service_config(item, self.server) item.is_json_schema_enabled = json_schema_config[ 'is_json_schema_enabled'] item.needs_json_schema_err_details = json_schema_config[ 'needs_json_schema_err_details'] out.append(item) return out
def set_up_class_json_schema(self, class_, service_config=None): # type: (Service, dict) class_name = class_.get_name() service_config = service_config or self.server.config.service[class_name]['config'] json_schema_config = get_service_config(service_config, self.server) # Make sure the schema points to an absolute path and that it exists if not os.path.isabs(class_.json_schema): schema_path = os.path.join(self.server.json_schema_dir, class_.json_schema) else: schema_path = class_.json_schema if not os.path.exists(schema_path): logger.warn('Could not find JSON Schema for `%s` in `%s` (class_.json_schema=%s)', class_name, schema_path, class_.json_schema) return config = JSONSchemaValidationConfig() config.is_enabled = json_schema_config['is_json_schema_enabled'] config.object_name = class_name config.object_type = CHANNEL.SERVICE config.schema_path = schema_path config.needs_err_details = json_schema_config['needs_json_schema_err_details'] validator = JSONSchemaValidator() validator.config = config validator.init() class_._json_schema_validator = validator
def set_up_class_json_schema(self, class_, service_config=None): # type: (Service, dict) class_name = class_.get_name() # We are required to configure JSON Schema for this service # but first we need to check if the service is already deployed. # If it is not, we need to set a flag indicating that our caller # should do it later, once the service has been actually deployed. service_info = self.server.config.service.get(class_name) if not service_info: setattr(class_, self.needs_post_deploy_attr, True) return service_config = service_config or service_info['config'] json_schema_config = get_service_config(service_config, self.server) # Make sure the schema points to an absolute path and that it exists if not os.path.isabs(class_.schema): schema_path = os.path.join(self.server.json_schema_dir, class_.schema) else: schema_path = class_.schema if not os.path.exists(schema_path): logger.warn( 'Could not find JSON Schema for `%s` in `%s` (class_.schema=%s)', class_name, schema_path, class_.schema) return config = JSONSchemaValidationConfig() config.is_enabled = json_schema_config['is_json_schema_enabled'] config.object_name = class_name config.object_type = CHANNEL.SERVICE config.schema_path = schema_path config.needs_err_details = json_schema_config[ 'needs_json_schema_err_details'] validator = JSONSchemaValidator() validator.config = config validator.init() class_._json_schema_validator = validator