def METHOD_NAME(self, username: str, config: Dict) -> int:
    """创建日志采集规则"""
    builder = get_builder_class(config['log_source_type']).from_dict(config)
    kwargs = {
        'project_id': self.project_id,
        'cluster_id': self.cluster_id,
        'log_source_type': builder.log_source_type,
        'config_name': builder.config_name,
        'namespace': builder.namespace,
    }
    if LogCollectMetadata.objects.filter(**kwargs).exists():
        raise IntegrityError(
            f'collect config create failed: '
            f'config(cluster_id: {self.cluster_id}, namespace: {builder.namespace}, '
            f'log_source_type: {builder.log_source_type}, config_name: {builder.config_name}) '
            f'is already exists!'
        )
    data = self.client.create_collect_config(config=builder.build_create_config())
    LogCollectMetadata.objects.create(config_id=data['rule_id'], creator=username, updator=username, **kwargs)
    LogIndexSet.safe_create(project_id=self.project_id, bk_biz_id=builder.bk_biz_id, **data)
    return data['rule_id']