Documentation
¶
Overview ¶
Package api 存放对服务端的API调用逻辑,考虑到日后服务器API会有大改,便于解耦
Index ¶
- Constants
- Variables
- func QueryResult(taskId string) (*model.TaskScanResponse, error)
- func SendDetect(input *SendDetectRequest) error
- func StartCheckTaskType(taskId string, kind model.TaskKind) error
- func UploadChunk(taskId string, chunkId int, reader io.Reader) error
- type Client
- type CommonApiErr
- type Contributor
- type CreateTaskGitInfo
- type CreateTaskRequest
- type CreateTaskResponse
- type ModuleType
- type SendDetectRequest
- type VoFileHash
- type VoGitInfo
- type VoModule
Constants ¶
View Source
const HeaderMachineId = "machine-id"
Variables ¶
View Source
var BaseCommonApiError = &CommonApiErr{}
View Source
var ErrServerRequest = model.WrapIdeaErr(err("Send request failed"), model.IdeaServerRequestFailed)
View Source
var ErrTimeout = model.WrapIdeaErr(err("API request timeout"), model.IdeaApiTimeout)
View Source
var ErrTlsRequest = model.WrapIdeaErr(err("TLS communication error"), model.IdeaServerRequestFailed)
View Source
var ErrTokenInvalid = model.WrapIdeaErr(err("Token invalid"), model.IdeaTokenInvalid)
View Source
var Logger = zap.NewNop()
View Source
var NetworkLogger = zap.NewNop()
View Source
var UnprocessableResponse = model.WrapIdeaErr(err("Unprocessable response"), model.IdeaServerRequestFailed)
Functions ¶
func QueryResult ¶
func QueryResult(taskId string) (*model.TaskScanResponse, error)
func SendDetect ¶
func SendDetect(input *SendDetectRequest) error
Types ¶
type Client ¶
type Client struct {
Token string
// contains filtered or unexported fields
}
var C *Client
type CommonApiErr ¶
type CommonApiErr struct {
EError struct {
Code int `json:"code"`
Message string `json:"message"`
Details string `json:"details"`
} `json:"error"`
}
func (*CommonApiErr) Error ¶
func (c *CommonApiErr) Error() string
func (*CommonApiErr) Is ¶
func (c *CommonApiErr) Is(e error) bool
type Contributor ¶
type CreateTaskGitInfo ¶
type CreateTaskRequest ¶
type CreateTaskRequest struct {
CliVersion string `json:"cli_version"`
TaskKind model.TaskKind `json:"task_kind"`
TaskType model.TaskType `json:"task_type"`
UserAgent string `json:"user_agent"`
CmdLine string `json:"cmd_line"`
ApiToken string `json:"api_token"`
GitInfo *VoGitInfo `json:"git_info,omitempty"`
ProjectName string `json:"project_name"`
TargetAbsPath string `json:"target_abs_path"`
ProjectType model.ProjectType `json:"project_type"`
ContributorList []model.Contributor `json:"contributor_list,omitempty"`
ProjectId string `json:"project_id,omitempty"`
}
type CreateTaskResponse ¶
type CreateTaskResponse struct {
TaskInfo string `json:"task_info"`
TotalContributors int `json:"total_contributors"`
ProjectId string `json:"project_id"`
Username string `json:"username"`
AlertMessage string `json:"alert_message"`
AlertLevel display.MsgLevel `json:"alert_level"`
}
func CreateTask ¶
func CreateTask(req *CreateTaskRequest) (*CreateTaskResponse, error)
type ModuleType ¶
type ModuleType string
const ( ModuleTypeVersion ModuleType = "version" ModuleTypeFileHash ModuleType = "file_hash" )
type SendDetectRequest ¶
type VoFileHash ¶
type VoModule ¶
type VoModule struct {
Dependencies []model.Dependency `json:"dependencies,omitempty"`
FileHashList []VoFileHash `json:"file_hash_list,omitempty"`
Language model.Language `json:"language,omitempty"`
Name string `json:"name,omitempty"`
PackageManager model.PackageManagerType `json:"package_manager,omitempty"`
RelativePath string `json:"relative_path,omitempty"`
RuntimeInfo interface{} `json:"runtime_info,omitempty"`
Version string `json:"version,omitempty"`
ModuleUUID uuid.UUID `json:"module_uuid,omitempty"`
ModuleType ModuleType `json:"module_type"`
ScanStrategy string `json:"scan_strategy"`
}
Click to show internal directories.
Click to hide internal directories.