// Copyright Project Harbor Authors
//
// 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.

package report

import "github.com/goharbor/harbor/src/pkg/scan/dao/scan"

// Manager is used to manage the scan reports.
type Manager interface {
	// Create a new report record.
	//
	//  Arguments:
	//    r *scan.Report : report model to be created
	//
	//  Returns:
	//    string : uuid of the new report
	//    error  : non nil error if any errors occurred
	//
	Create(r *scan.Report) (string, error)

	// Update the scan job ID of the given report.
	//
	//  Arguments:
	//    trackID string : uuid to identify the report
	//    jobID string   : scan job ID
	//
	//  Returns:
	//    error  : non nil error if any errors occurred
	//
	UpdateScanJobID(trackID string, jobID string) error

	// Update the status (mapping to the scan job status) of the given report.
	//
	//  Arguments:
	//    trackID string : uuid to identify the report
	//    status string  : status info
	//    rev int64      : data revision info
	//
	//  Returns:
	//    error  : non nil error if any errors occurred
	//
	UpdateStatus(trackID string, status string, rev int64) error

	// Update the report data (with JSON format) of the given report.
	//
	//  Arguments:
	//    uuid string    : uuid to identify the report
	//    report string  : report JSON data
	//    rev int64      : data revision info
	//
	//  Returns:
	//    error  : non nil error if any errors occurred
	//
	UpdateReportData(uuid string, report string, rev int64) error

	// Get the reports for the given digest by other properties.
	//
	//  Arguments:
	//    digest string           : digest of the artifact
	//    registrationUUID string : [optional] the report generated by which registration.
	//                              If it is empty, reports by all the registrations are retrieved.
	//    mimeTypes []string      : [optional] mime types of the reports requiring
	//                              If empty array is specified, reports with all the supported mimes are retrieved.
	//
	//  Returns:
	//    []*scan.Report : report list
	//    error          : non nil error if any errors occurred
	GetBy(digest string, registrationUUID string, mimeTypes []string) ([]*scan.Report, error)

	// Get the report for the given uuid.
	//
	//  Arguments:
	//    uuid string           : uuid of the scan report
	//
	//  Returns:
	//    *scan.Report : scan report
	//    error        : non nil error if any errors occurred
	Get(uuid string) (*scan.Report, error)
}
