/******************************************************************************
 * Copyright (c)  2022 PingCAP, Inc.                                          *
 * Licensed under the Apache License, Version 2.0 (the "License");            *
 * you may not use this file except in compliance with the License.           *
 * You may obtain a copy of the License at                                    *
 *                                                                            *
 * http://www.apache.org/licenses/LICENSE-2.0                                 *
 *                                                                            *
 * Unless required by applicable law or agreed to in writing, software        *
 * distributed under the License is distributed on an "AS IS" BASIS,          *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
 * See the License for the specific language governing permissions and        *
 * limitations under the License.                                             *
 ******************************************************************************/

/*******************************************************************************
 * @File: interface.go
 * @Description:
 * @Author: jiangxunyu@pingcap.com
 * @Version: 1.0.0
 * @Date: 2022/6/7 14:27
*******************************************************************************/

package metamanager

import (
	"context"
	"mime/multipart"

	s3api "github.com/aws/aws-sdk-go-v2/service/s3"

	"github.com/tidbcloud/observability/pkg/common/structs"

	"k8s.io/apimachinery/pkg/watch"
)

type MetaService interface {

	// DetailMeta
	// @Description: detail metadata for services
	// @param ctx
	// @param nsAndCmName
	// @return string
	// @return error
	DetailMeta(ctx context.Context, nsAndCmName string) (string, error)

	// UpdateMeta
	// @Description: update metadata for services
	// @param ctx
	// @param nsAndCmName
	// @param metadata
	// @return error
	UpdateMeta(ctx context.Context, nsAndCmName string, metadata string) error

	// CreateMeta
	// @Description: create metadata for services
	// @param ctx
	// @param nsAndCmName
	// @param metadata
	// @return error
	CreateMeta(ctx context.Context, nsAndCmName string, metadata string) error

	// WatchMeta
	// @Description: metadata change listening for services
	// @param ctx
	// @param nsName
	// @return watch.Interface
	// @return error
	WatchMeta(ctx context.Context, nsName string) (watch.Interface, error)
}

type EvaluationMeta interface {
	SaveMeta(ctx context.Context, meta structs.Evaluation) error
	GetMeta(ctx context.Context, user string, evaluationName string) (structs.Evaluation, error)

	SavePred(ctx context.Context, meta structs.Evaluation, file multipart.File) error

	SaveResult(ctx context.Context, meta structs.Evaluation) error
	GetResult(ctx context.Context, user string, evaluationName string) (string, string, error)

	GetDatasetRecords(ctx context.Context, dataset string, date string) ([]*s3api.GetObjectOutput, error)
}

type ModelMeta interface {
	SaveMeta(ctx context.Context, meta structs.Model) error
	GetMeta(ctx context.Context, name, version string) (structs.Model, error)
}
