package iface

import (
	"io"

	"github.com/pingcap-inc/clinic/pkg/config"
)

type IStorage interface {
	PreUpload(fileUUID string) (*string, error)

	Upload(fileUUID string, content io.ReadSeeker, config UploadConfigRequest) (*string, error)

	Flush(fileUUID string, config FlushConfigRequest) error

	Abort(fileUUID string, config UploadConfigRequest) error

	Type() config.StorageType

	GetObject(fileUUID, location string, cfg GetObjectRequest) (*ObjectResponse, error)

	DescribeObject(fileUUID, location string) (*ObjectResponse, error)

	DownloadCache(fileUUID string, w io.WriterAt) (int64, error)

	Persist(fileUUID, clusterID string, reader io.Reader) error

	DeleteCache(fileUUID string) error

	DeleteObject(fileUUID, location string) error
}

type UploadConfigRequest struct {
	SerialNumber int
	UploadId     string
}

type FlushConfigRequest struct {
	UploadId string
	Etags    []ETag
}

type ETag struct {
	ETag         string
	SerialNumber int
}

type GetObjectRequest struct {
	Range string
}

type ObjectResponse struct {
	Body io.ReadCloser

	ETag string

	ContentLen int64

	ContentType string

	ContentRange string

	AcceptRanges string
}
