syntax = "v1"

info(
    title: "schedule"
    desc: "调度服务"
    author: "tzwang"
    email: "tzwang@qq.com"
)

type (
    ScheduleReq {
        AiOption *AiOption `json:"aiOption,optional"`
    }

    ScheduleResp {
        Results []*ScheduleResult `json:"results"`
    }

    ScheduleResult {
        ClusterId string `json:"clusterId"`
        TaskId string `json:"taskId"`
        Card string `json:"card"`
        Strategy string `json:"strategy"`
        JobId string `json:"jobId"`
        Replica int32 `json:"replica"`
        Msg string `json:"msg"`
    }

    ScheduleOverviewResp {
    }

    AiOption {
        TaskName string `json:"taskName"`
        AdapterId string `json:"adapterId"`
        AiClusterIds []string `json:"aiClusterIds"`
        ResourceType string `json:"resourceType"`
        ComputeCard string `json:"card"`
        Tops float64 `json:"Tops,optional"`
        TaskType string `json:"taskType"`
        Datasets string `json:"datasets"`
        Algorithm string `json:"algorithm"`
        Strategy string `json:"strategy"`
        StaticWeightMap map[string]int32 `json:"staticWeightMap,optional"`
        Params []string `json:"params,optional"`
        Envs   []string `json:"envs,optional"`
        Cmd string `json:"cmd,optional"`
        Replica     int32     `json:"replicas"`
    }

    AiResourceTypesResp {
        ResourceTypes []string `json:"resourceTypes"`
    }

    AiTaskTypesResp {
        TaskTypes []string `json:"taskTypes"`
    }

    AiDatasetsReq {
        AdapterId string `path:"adapterId"`
    }

    AiDatasetsResp {
        Datasets []string `json:"datasets"`
    }

    AiStrategyResp {
        Strategies []string `json:"strategies"`
    }

    AiAlgorithmsReq {
        AdapterId string `path:"adapterId"`
        ResourceType string `path:"resourceType"`
        TaskType string `path:"taskType"`
        Dataset string `path:"dataset"`
    }

    AiAlgorithmsResp {
        Algorithms []string `json:"algorithms"`
    }

    AiJobLogReq {
        AdapterId string `path:"adapterId"`
        ClusterId string `path:"clusterId"`
        TaskId string `path:"taskId"`
        instanceNum string `path:"instanceNum"`
    }

    AiJobLogResp {
      Log string `json:"log"`
    }

    AiTaskDb {
        Id            string `json:"id,omitempty" db:"id"`
        TaskId     string `json:"taskId,omitempty" db:"task_id"`
        AdapterId          string `json:"adapterId,omitempty" db:"adapter_id"`
        ClusterId      string `json:"clusterId,omitempty" db:"cluster_id"`
        Name   string `json:"name,omitempty" db:"name"`
        Replica        string `json:"replica,omitempty" db:"replica"`
        ClusterTaskId string `json:"clusterTaskId,omitempty" db:"c_task_id"`
        Strategy      string `json:"strategy,omitempty" db:"strategy"`
        Status      string `json:"status,omitempty" db:"status"`
        Msg         string `json:"msg,omitempty" db:"msg"`
        CommitTime            string `json:"commitTime,omitempty" db:"commit_time"`
        StartTime            string `json:"startTime,omitempty" db:"start_time"`
        EndTime            string `json:"endTime,omitempty" db:"end_time"`
    }

    DownloadAlgorithmCodeReq {
        AdapterId string `form:"adapterId"`
        ClusterId string `form:"clusterId"`
        ResourceType string `form:"resourceType"`
        Card string `form:"card"`
        TaskType string `form:"taskType"`
        Dataset string `form:"dataset"`
        Algorithm string `form:"algorithm"`
    }

    DownloadAlgorithmCodeResp {
        Code string `json:"code"`
    }

    UploadAlgorithmCodeReq {
        AdapterId string `json:"adapterId"`
        ClusterId string `json:"clusterId"`
        ResourceType string `json:"resourceType"`
        Card string `json:"card"`
        TaskType string `json:"taskType"`
        Dataset string `json:"dataset"`
        Algorithm string `json:"algorithm"`
        Code string `json:"code"`
    }

    UploadAlgorithmCodeResp {
    }

    GetComputeCardsByClusterReq {
        AdapterId string `path:"adapterId"`
        ClusterId string `path:"clusterId"`
    }

    GetComputeCardsByClusterResp {
        Cards []string `json:"cards"`
    }

    GetClusterBalanceByIdReq{
        AdapterId string `path:"adapterId"`
        ClusterId string `path:"clusterId"`
    }

    GetClusterBalanceByIdResp{
        Balance float64 `json:"balance"`
    }
)