diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..4621abeeb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: check-json + - id: end-of-file-fixer + - id: trailing-whitespace + - id: pretty-format-json + args: [--no-sort-keys, --autofix, --indent=4] + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + args: [--line-length=80, --skip-string-normalization] + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: [--profile=black, --line-length=80] + + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: + [ + "--ignore=E203,W503", + --max-complexity=10, + --max-line-length=80, + "--select=B,C,E,F,W,T4,B9", + ] diff --git a/api/design_api.partials.yml b/api/design_api.partials.yml index a40a45e23..8f5cde96f 100644 --- a/api/design_api.partials.yml +++ b/api/design_api.partials.yml @@ -167,6 +167,13 @@ schema: type: string style: simple + - in: header + name: X-API-KEY + schema: + type: string + style: simple + explode: false + required: true responses: '200': description: Deleted @@ -390,11 +397,6 @@ style: simple explode: false required: true - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/DesignSchema' responses: "200": description: Null response diff --git a/api/design_components.partials.yml b/api/design_components.partials.yml index ac1e4529b..8607903c1 100644 --- a/api/design_components.partials.yml +++ b/api/design_components.partials.yml @@ -31,7 +31,6 @@ DesignInfo: type: string required: - id - - name example: name: diabete predict description: Helps in quick diagnosis and prediction of diabetes among patients. @@ -80,7 +79,6 @@ DesignSchema: items: $ref: '#/components/schemas/Connector' required: - - version - name - roles - channels @@ -127,6 +125,10 @@ Role: replica: format: int32 type: integer + groupAssociation: + type: array + items: + $ref: '#/components/schemas/GroupAssociation' required: - name example: @@ -137,6 +139,17 @@ Role: description: These are responsible to aggregate the updates from trainer nodes. replica: 2 +######################### +# GroupAssociation +######################### +GroupAssociation: + type: object + additionalProperties: + type: string + example: + "param-channel": "red" + "global-channel": "black" + ######################### # Channel between roles ######################### diff --git a/cmd/controller/app/database/db_interfaces.go b/cmd/controller/app/database/db_interfaces.go index 501551dab..e23fb22cf 100644 --- a/cmd/controller/app/database/db_interfaces.go +++ b/cmd/controller/app/database/db_interfaces.go @@ -35,62 +35,132 @@ type DBService interface { // DatasetService is an interface that defines a collection of APIs related to dataset type DatasetService interface { - CreateDataset(string, openapi.DatasetInfo) (string, error) - GetDatasets(string, int32) ([]openapi.DatasetInfo, error) + // CreateDataset creates a new dataset in the db + CreateDataset(userId string, info openapi.DatasetInfo) (string, error) + + // GetDatasets returns a list of datasets associated with a user + GetDatasets(userId string, limit int32) ([]openapi.DatasetInfo, error) + + // GetDatasetById returns the details of a particular dataset GetDatasetById(string) (openapi.DatasetInfo, error) } // DesignService is an interface that defines a collection of APIs related to design type DesignService interface { + // CreateDesign adds a design to the db CreateDesign(userId string, info openapi.Design) error + + // GetDesign returns a design associated with the given user and design ids GetDesign(userId string, designId string) (openapi.Design, error) + + // DeleteDesign deletes the design from the db DeleteDesign(userId string, designId string) error + + // GetDesigns returns a list of designs associated with a user GetDesigns(userId string, limit int32) ([]openapi.DesignInfo, error) + // CreateDesignSchema adds a schema for a design to the db CreateDesignSchema(userId string, designId string, info openapi.DesignSchema) error + + // GetDesignSchema returns the schema of a design from the db GetDesignSchema(userId string, designId string, version string) (openapi.DesignSchema, error) + + // GetDesignSchemas returns all the schemas associated with the given designId GetDesignSchemas(userId string, designId string) ([]openapi.DesignSchema, error) + + // UpdateDesignSchema updates a schema for a design in the db UpdateDesignSchema(userId string, designId string, version string, info openapi.DesignSchema) error + + // DeleteDesignSchema deletes the schema of a design from the db DeleteDesignSchema(userId string, designId string, version string) error + // CreateDesignCode adds the code of a design to the db CreateDesignCode(userId string, designId string, fileName string, fileVer string, fileData *os.File) error + + // GetDesignCode retrieves the code of a design from the db GetDesignCode(userId string, designId string, version string) ([]byte, error) + + // DeleteDesignCode deletes the code of a design from the db DeleteDesignCode(userId string, designId string, version string) error } // JobService is an interface that defines a collection of APIs related to job type JobService interface { - CreateJob(string, openapi.JobSpec) (openapi.JobStatus, error) - DeleteJob(string, string) error - GetJob(string, string) (openapi.JobSpec, error) - GetJobById(string) (openapi.JobSpec, error) - GetJobStatus(string, string) (openapi.JobStatus, error) - GetJobs(string, int32) ([]openapi.JobStatus, error) - UpdateJob(string, string, openapi.JobSpec) error - UpdateJobStatus(string, string, openapi.JobStatus) error + // CreateJob creates a new job + CreateJob(userId string, spec openapi.JobSpec) (openapi.JobStatus, error) + + // DeleteJob deletes a given job + DeleteJob(userId string, jobId string) error + + // GetJob gets the job associated with the provided jobId + GetJob(userId string, jobId string) (openapi.JobSpec, error) + + // GetJobById gets the job associated with the provided jobId + GetJobById(jobId string) (openapi.JobSpec, error) + + // GetJobStatus get the status of a job + GetJobStatus(userId string, jobId string) (openapi.JobStatus, error) + + // GetJobs returns the list of jobs associated with a user + GetJobs(userId string, limit int32) ([]openapi.JobStatus, error) + + // UpdateJob updates the job with the given jobId + UpdateJob(userId string, jobId string, spec openapi.JobSpec) error + + // UpdateJobStatus updates the status of a job given the user Id, job Id and the openapi.JobStatus + UpdateJobStatus(userId string, jobId string, status openapi.JobStatus) error + + // GetTaskInfo gets the information of a task given the user Id, job Id and task Id GetTaskInfo(string, string, string) (openapi.TaskInfo, error) + + // GetTasksInfo gets the information of tasks given the user Id, job Id and a limit GetTasksInfo(string, string, int32, bool) ([]openapi.TaskInfo, error) + + // GetTasksInfoGeneric gets the information of tasks given the user Id, job Id, limit and an option to include completed tasks GetTasksInfoGeneric(string, string, int32, bool, bool) ([]openapi.TaskInfo, error) } // TaskService is an interface that defines a collection of APIs related to task type TaskService interface { + // CreateTasks creates tasks given a set of objects.Task and a flag CreateTasks([]objects.Task, bool) error + + // DeleteTasks deletes tasks given the job Id and a flag DeleteTasks(string, bool) error + + // GetTask gets the task given the user Id, job Id and task Id GetTask(string, string, string) (map[string][]byte, error) + + // IsOneTaskInState evaluates if one of the task is in a certain state given the job Id IsOneTaskInState(string, openapi.JobState) bool + + // IsOneTaskInStateWithRole evaluates if one of the tasks is in a certain state and with a specific role given the job Id IsOneTaskInStateWithRole(string, openapi.JobState, string) bool + + // MonitorTasks monitors the tasks and returns a TaskInfo channel MonitorTasks(string) (chan openapi.TaskInfo, chan error, context.CancelFunc, error) - SetTaskDirtyFlag(string, bool) error - UpdateTaskStateByFilter(string, openapi.JobState, map[string]interface{}) error - UpdateTaskStatus(string, string, openapi.TaskStatus) error + + // SetTaskDirtyFlag sets the dirty flag for tasks given the job Id and a flag + SetTaskDirtyFlag(jobId string, dirty bool) error + + // UpdateTaskStateByFilter updates the state of the task using a filter + UpdateTaskStateByFilter(jobId string, newState openapi.JobState, userFilter map[string]interface{}) error + + // UpdateTaskStatus updates the status of a task given the user Id, job Id, and openapi.TaskStatus + UpdateTaskStatus(jobId string, taskId string, taskStatus openapi.TaskStatus) error } // ComputeService is an interface that defines a collection of APIs related to computes type ComputeService interface { + // RegisterCompute registers a compute given a openapi.ComputeSpec RegisterCompute(openapi.ComputeSpec) (openapi.ComputeStatus, error) + + // GetComputeIdsByRegion gets all the compute Ids associated with a region GetComputeIdsByRegion(string) ([]string, error) + + // GetComputeById gets the compute info given the compute Id GetComputeById(string) (openapi.ComputeSpec, error) - // UpdateDeploymentStatus call replaces existing agent statuses with received statuses in collection. + + // UpdateDeploymentStatus updates the deployment status given the compute Id, job Id and agentStatuses map UpdateDeploymentStatus(computeId string, jobId string, agentStatuses map[string]openapi.AgentState) error } diff --git a/cmd/controller/app/database/mongodb/compute_test.go b/cmd/controller/app/database/mongodb/compute_test.go index 70614873c..605ba48ad 100644 --- a/cmd/controller/app/database/mongodb/compute_test.go +++ b/cmd/controller/app/database/mongodb/compute_test.go @@ -34,9 +34,8 @@ func TestMongoService_UpdateDeploymentStatus(t *testing.T) { deploymentCollection: mt.Coll, } mt.AddMockResponses(mtest.CreateSuccessResponse(), mtest.CreateCursorResponse(1, "flame.deployment", mtest.FirstBatch, bson.D{})) - err := db.UpdateDeploymentStatus("test jobid","test compute id", - map[string]openapi.AgentState{"test task id": openapi.AGENT_DEPLOY_SUCCESS, - }) + err := db.UpdateDeploymentStatus("test jobid", "test compute id", + map[string]openapi.AgentState{"test task id": openapi.AGENT_DEPLOY_SUCCESS}) assert.Nil(t, err) }) mt.Run("status update failure", func(mt *mtest.T) { diff --git a/cmd/controller/app/job/builder.go b/cmd/controller/app/job/builder.go index 89125d7d8..339300af7 100644 --- a/cmd/controller/app/job/builder.go +++ b/cmd/controller/app/job/builder.go @@ -171,19 +171,19 @@ func (b *JobBuilder) getTaskTemplates() ([]string, map[string]*taskTemplate) { for _, role := range b.schema.Roles { template := &taskTemplate{} - JobConfig := &template.JobConfig + jobConfig := &template.JobConfig - JobConfig.Configure(b.jobSpec, b.jobParams.Brokers, b.jobParams.Registry, role, b.schema.Channels) + jobConfig.Configure(b.jobSpec, b.jobParams.Brokers, b.jobParams.Registry, role, b.schema.Channels) - // check channels and set default group if channels don't have groupby attributes set - for i := range JobConfig.Channels { - if len(JobConfig.Channels[i].GroupBy.Value) > 0 { + // check channels and set default group if channels don't have groupBy attributes set + for i := range jobConfig.Channels { + if len(jobConfig.Channels[i].GroupBy.Value) > 0 { continue } - // since there is no groupby attribute, set default - JobConfig.Channels[i].GroupBy.Type = groupByTypeTag - JobConfig.Channels[i].GroupBy.Value = append(JobConfig.Channels[i].GroupBy.Value, defaultGroup) + // since there is no groupBy attribute, set default + jobConfig.Channels[i].GroupBy.Type = groupByTypeTag + jobConfig.Channels[i].GroupBy.Value = append(jobConfig.Channels[i].GroupBy.Value, defaultGroup) } template.isDataConsumer = role.IsDataConsumer @@ -192,7 +192,7 @@ func (b *JobBuilder) getTaskTemplates() ([]string, map[string]*taskTemplate) { } template.ZippedCode = b.roleCode[role.Name] template.Role = role.Name - template.JobId = JobConfig.Job.Id + template.JobId = jobConfig.Job.Id templates[role.Name] = template } @@ -205,9 +205,9 @@ func (b *JobBuilder) preCheck(dataRoles []string, templates map[string]*taskTemp // This function will evolve as more invariants are defined // Before processing templates, the following invariants should be met: // 1. At least one data consumer role should be defined. - // 2. a role shouled be associated with a code. + // 2. a role should be associated with a code. // 3. template should be connected. - // 4. when graph traversal starts at a data role template, the depth of groupby tag + // 4. when graph traversal starts at a data role template, the depth of groupBy tag // should strictly decrease from one channel to another. // 5. two different data roles cannot be connected directly. diff --git a/cmd/controller/app/objects/task.go b/cmd/controller/app/objects/task.go index 34021d8f0..a1e51b425 100644 --- a/cmd/controller/app/objects/task.go +++ b/cmd/controller/app/objects/task.go @@ -50,6 +50,7 @@ type JobConfig struct { Job JobIdName `json:"job"` Role string `json:"role"` Realm string `json:"realm"` + Groups map[string]string `json:"groups"` Channels []openapi.Channel `json:"channels"` MaxRunTime int32 `json:"maxRunTime,omitempty"` @@ -101,6 +102,22 @@ func (cfg *JobConfig) Configure(jobSpec *openapi.JobSpec, brokers []config.Broke // Realm will be updated when datasets are handled cfg.Realm = "" cfg.Channels = cfg.extractChannels(role.Name, channels) + + // configure the groups of the job based on the groups associated with the assigned role + cfg.Groups = cfg.extractGroups(role.GroupAssociation) +} + +// extractGroups - extracts the associated groups that a given role has of a particular job +func (cfg *JobConfig) extractGroups(groupAssociation []map[string]string) map[string]string { + groups := make(map[string]string) + + for _, ag := range groupAssociation { + for key, value := range ag { + groups[key] = value + } + } + + return groups } func (cfg *JobConfig) extractChannels(role string, channels []openapi.Channel) []openapi.Channel { diff --git a/cmd/deployer/app/resource_handler.go b/cmd/deployer/app/resource_handler.go index 82305d56b..eb12349c8 100644 --- a/cmd/deployer/app/resource_handler.go +++ b/cmd/deployer/app/resource_handler.go @@ -36,6 +36,7 @@ import ( "github.com/cisco-open/flame/cmd/deployer/app/deployer" "github.com/cisco-open/flame/cmd/deployer/config" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" pbNotify "github.com/cisco-open/flame/pkg/proto/notification" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" @@ -279,8 +280,8 @@ func (r *resourceHandler) postDeploymentStatus(jobId string, taskStatuses map[st taskStatuses, r.spec.ComputeId, jobId) // construct url uriMap := map[string]string{ - "computeId": r.spec.ComputeId, - "jobId": jobId, + constants.ParamComputeID: r.spec.ComputeId, + constants.ParamJobID: jobId, } url := restapi.CreateURL(r.apiserverEp, restapi.PutDeploymentStatusEndpoint, uriMap) @@ -296,8 +297,8 @@ func (r *resourceHandler) getDeploymentConfig(jobId string) (openapi.DeploymentC zap.S().Infof("Sending request to apiserver / controller to get deployment config") // construct url uriMap := map[string]string{ - "computeId": r.spec.ComputeId, - "jobId": jobId, + constants.ParamComputeID: r.spec.ComputeId, + constants.ParamJobID: jobId, } url := restapi.CreateURL(r.apiserverEp, restapi.GetDeploymentConfigEndpoint, uriMap) code, respBody, err := restapi.HTTPGet(url) @@ -355,9 +356,9 @@ func (r *resourceHandler) deployResources(deploymentConfig openapi.DeploymentCon } ctx := map[string]string{ - "imageLoc": deploymentConfig.ImageLoc, - "taskId": taskId, - "taskKey": deploymentConfig.AgentKVs[taskId], + "imageLoc": deploymentConfig.ImageLoc, + constants.ParamTaskID: taskId, + "taskKey": deploymentConfig.AgentKVs[taskId], } rendered, renderErr := mustache.RenderFile(r.jobTemplatePath, &ctx) diff --git a/cmd/flamectl/cmd/get_design.go b/cmd/flamectl/cmd/get_design.go index c162bbc30..e34e0c2e9 100644 --- a/cmd/flamectl/cmd/get_design.go +++ b/cmd/flamectl/cmd/get_design.go @@ -20,6 +20,7 @@ import ( "github.com/spf13/cobra" "github.com/cisco-open/flame/cmd/flamectl/resources/design" + "github.com/cisco-open/flame/pkg/openapi/constants" ) var getDesignCmd = &cobra.Command{ @@ -51,7 +52,7 @@ var getDesignsCmd = &cobra.Command{ flags := cmd.Flags() - limit, err := flags.GetString("limit") + limit, err := flags.GetString(constants.ParamLimit) if err != nil { return err } @@ -66,7 +67,7 @@ var getDesignsCmd = &cobra.Command{ } func init() { - getDesignsCmd.Flags().StringP("limit", "l", "100", "List of all the designs by this user") + getDesignsCmd.Flags().StringP(constants.ParamLimit, "l", "100", "List of all the designs by this user") getCmd.AddCommand(getDesignCmd, getDesignsCmd) } diff --git a/cmd/flamectl/resources/code/code.go b/cmd/flamectl/resources/code/code.go index 8d9287f1e..88ac2d120 100644 --- a/cmd/flamectl/resources/code/code.go +++ b/cmd/flamectl/resources/code/code.go @@ -27,6 +27,7 @@ import ( "strings" "github.com/cisco-open/flame/cmd/flamectl/resources" + "github.com/cisco-open/flame/pkg/openapi/constants" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" ) @@ -42,8 +43,8 @@ type Params struct { func Create(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, } url := restapi.CreateURL(params.Endpoint, restapi.CreateDesignCodeEndPoint, uriMap) @@ -87,9 +88,9 @@ func Create(params Params) error { func Get(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, - "version": params.CodeVer, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, + constants.ParamVersion: params.CodeVer, } url := restapi.CreateURL(params.Endpoint, restapi.GetDesignCodeEndPoint, uriMap) @@ -125,9 +126,9 @@ func mustOpen(f string) *os.File { func Remove(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, - "version": params.CodeVer, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, + constants.ParamVersion: params.CodeVer, } url := restapi.CreateURL(params.Endpoint, restapi.DeleteDesignCodeEndPoint, uriMap) diff --git a/cmd/flamectl/resources/dataset/dataset.go b/cmd/flamectl/resources/dataset/dataset.go index f930ac3bd..95d84d3b7 100644 --- a/cmd/flamectl/resources/dataset/dataset.go +++ b/cmd/flamectl/resources/dataset/dataset.go @@ -24,6 +24,7 @@ import ( "github.com/cisco-open/flame/cmd/flamectl/resources" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" "github.com/cisco-open/flame/pkg/restapi" "github.com/olekukonko/tablewriter" ) @@ -53,7 +54,7 @@ func Create(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, + constants.ParamUser: params.User, } url := restapi.CreateURL(params.Endpoint, restapi.CreateDatasetEndPoint, uriMap) @@ -87,8 +88,8 @@ func Get(params Params) error { func GetMany(params Params, flagAll bool) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "limit": params.Limit, + constants.ParamUser: params.User, + constants.ParamLimit: params.Limit, } endpoint := restapi.GetDatasetsEndPoint diff --git a/cmd/flamectl/resources/design/design.go b/cmd/flamectl/resources/design/design.go index 6eaf3b59a..9b4cad5bb 100644 --- a/cmd/flamectl/resources/design/design.go +++ b/cmd/flamectl/resources/design/design.go @@ -25,6 +25,7 @@ import ( "github.com/cisco-open/flame/cmd/flamectl/resources" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" ) @@ -40,7 +41,7 @@ type Params struct { func Create(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, + constants.ParamUser: params.User, } url := restapi.CreateURL(params.Endpoint, restapi.CreateDesignEndPoint, uriMap) @@ -66,8 +67,8 @@ func Create(params Params) error { func Remove(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, } url := restapi.CreateURL(params.Endpoint, restapi.DeleteDesignEndPoint, uriMap) @@ -98,8 +99,8 @@ func Remove(params Params) error { func Get(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, } url := restapi.CreateURL(params.Endpoint, restapi.GetDesignEndPoint, uriMap) @@ -129,8 +130,8 @@ func Get(params Params) error { func GetMany(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "limit": params.Limit, + constants.ParamUser: params.User, + constants.ParamLimit: params.Limit, } url := restapi.CreateURL(params.Endpoint, restapi.GetDesignsEndPoint, uriMap) diff --git a/cmd/flamectl/resources/job/job.go b/cmd/flamectl/resources/job/job.go index 8a99ce825..62422a72e 100644 --- a/cmd/flamectl/resources/job/job.go +++ b/cmd/flamectl/resources/job/job.go @@ -25,6 +25,7 @@ import ( "github.com/cisco-open/flame/cmd/flamectl/resources" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" ) @@ -54,7 +55,7 @@ func Create(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, + constants.ParamUser: params.User, } url := restapi.CreateURL(params.Endpoint, restapi.CreateJobEndpoint, uriMap) @@ -84,8 +85,8 @@ func Create(params Params) error { func Get(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, } url := restapi.CreateURL(params.Endpoint, restapi.GetJobEndPoint, uriMap) @@ -127,8 +128,8 @@ func Get(params Params) error { func GetMany(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "limit": params.Limit, + constants.ParamUser: params.User, + constants.ParamLimit: params.Limit, } url := restapi.CreateURL(params.Endpoint, restapi.GetJobsEndPoint, uriMap) @@ -163,8 +164,8 @@ func GetMany(params Params) error { func GetStatus(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, } url := restapi.CreateURL(params.Endpoint, restapi.GetJobStatusEndPoint, uriMap) @@ -212,8 +213,8 @@ func Update(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, } url := restapi.CreateURL(params.Endpoint, restapi.UpdateJobEndPoint, uriMap) @@ -234,8 +235,8 @@ func Update(params Params) error { func Remove(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, } url := restapi.CreateURL(params.Endpoint, restapi.DeleteJobEndPoint, uriMap) @@ -259,8 +260,8 @@ func Remove(params Params) error { func Start(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, } url := restapi.CreateURL(params.Endpoint, restapi.UpdateJobStatusEndPoint, uriMap) @@ -285,8 +286,8 @@ func Start(params Params) error { func Stop(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, } url := restapi.CreateURL(params.Endpoint, restapi.UpdateJobStatusEndPoint, uriMap) diff --git a/cmd/flamectl/resources/schema/schema.go b/cmd/flamectl/resources/schema/schema.go index 36ce95bdd..a903e8d6e 100644 --- a/cmd/flamectl/resources/schema/schema.go +++ b/cmd/flamectl/resources/schema/schema.go @@ -23,6 +23,7 @@ import ( "github.com/cisco-open/flame/cmd/flamectl/resources" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" ) @@ -51,8 +52,8 @@ func Create(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, } url := restapi.CreateURL(params.Endpoint, restapi.CreateDesignSchemaEndPoint, uriMap) @@ -73,9 +74,9 @@ func Create(params Params) error { func Get(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, - "version": params.Version, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, + constants.ParamVersion: params.Version, } url := restapi.CreateURL(params.Endpoint, restapi.GetDesignSchemaEndPoint, uriMap) @@ -105,8 +106,8 @@ func Get(params Params) error { func GetMany(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, } url := restapi.CreateURL(params.Endpoint, restapi.GetDesignSchemasEndPoint, uriMap) @@ -148,9 +149,9 @@ func Update(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, - "version": params.Version, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, + constants.ParamVersion: params.Version, } url := restapi.CreateURL(params.Endpoint, restapi.UpdateDesignSchemaEndPoint, uriMap) @@ -170,9 +171,9 @@ func Update(params Params) error { func Remove(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "designId": params.DesignId, - "version": params.Version, + constants.ParamUser: params.User, + constants.ParamDesignID: params.DesignId, + constants.ParamVersion: params.Version, } url := restapi.CreateURL(params.Endpoint, restapi.DeleteDesignSchemaEndPoint, uriMap) diff --git a/cmd/flamectl/resources/task/task.go b/cmd/flamectl/resources/task/task.go index 998266bb1..68b025826 100644 --- a/cmd/flamectl/resources/task/task.go +++ b/cmd/flamectl/resources/task/task.go @@ -25,6 +25,7 @@ import ( "github.com/cisco-open/flame/cmd/flamectl/resources" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" ) @@ -40,9 +41,9 @@ type Params struct { func Get(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, - "taskId": params.TaskId, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, + constants.ParamTaskID: params.TaskId, } url := restapi.CreateURL(params.Endpoint, restapi.GetTaskInfoEndpoint, uriMap) @@ -68,9 +69,9 @@ func Get(params Params) error { func GetMany(params Params) error { // construct URL uriMap := map[string]string{ - "user": params.User, - "jobId": params.JobId, - "limit": params.Limit, + constants.ParamUser: params.User, + constants.ParamJobID: params.JobId, + constants.ParamLimit: params.Limit, } url := restapi.CreateURL(params.Endpoint, restapi.GetTasksInfoEndpoint, uriMap) diff --git a/cmd/flamelet/app/taskhandler.go b/cmd/flamelet/app/taskhandler.go index 9dca409ed..4531617f1 100644 --- a/cmd/flamelet/app/taskhandler.go +++ b/cmd/flamelet/app/taskhandler.go @@ -36,6 +36,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "github.com/cisco-open/flame/pkg/openapi" + "github.com/cisco-open/flame/pkg/openapi/constants" pbNotify "github.com/cisco-open/flame/pkg/proto/notification" "github.com/cisco-open/flame/pkg/restapi" "github.com/cisco-open/flame/pkg/util" @@ -215,9 +216,9 @@ func (t *taskHandler) startJob(jobId string) { func (t *taskHandler) getTask() ([]string, error) { // construct URL uriMap := map[string]string{ - "jobId": t.jobId, - "taskId": t.taskId, - "key": t.taskKey, + constants.ParamJobID: t.jobId, + constants.ParamTaskID: t.taskId, + constants.ParamKey: t.taskKey, } url := restapi.CreateURL(t.apiserverEp, restapi.GetTaskEndpoint, uriMap) @@ -473,8 +474,8 @@ func (t *taskHandler) updateTaskStatus(state openapi.JobState, log string) { // construct URL uriMap := map[string]string{ - "jobId": t.jobId, - "taskId": t.taskId, + constants.ParamJobID: t.jobId, + constants.ParamTaskID: t.taskId, } url := restapi.CreateURL(t.apiserverEp, restapi.UpdateTaskStatusEndPoint, uriMap) diff --git a/docs/index.html b/docs/index.html index 48dae1365..336b4417f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,21 +31,27 @@ } -

Flame REST API (1.0.0)

Download OpenAPI specification:Download

License: MIT

designs

Get list of all the designs created by the user.

path Parameters
user
required
string

user id

-
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

-

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create a new design template.

path Parameters
user
required
string

user name

-
Request Body schema: application/json

Collection of node information

-
name
required
string
description
string
id
required
string
userId
string

Responses

Request samples

Content type
application/json
{
  • "name": "diabete predict",
  • "description": "Helps in quick diagnosis and prediction of diabetes among patients.",
  • "id": "diabete-predict"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get design template information

path Parameters
user
required
string

user id

-
designId
required
string

design id

-

Responses

Response samples

Content type
application/json
{
  • "name": "diabete predict",
  • "description": "Helps in quick diagnosis and prediction of diabetes among patients.",
  • "id": "diabete-predict",
  • "schemas": [
    ]
}

designSchemas

Get all design schemas in a design

path Parameters
user
required
string

user id

-
designId
required
string

design id

-

Responses

Response samples

Content type
application/json
{
  • "schemas": [
    ]
}

Update a design schema

path Parameters
user
required
string

user id

-
designId
required
string

design id

-
Request Body schema: application/json
version
required
string
name
required
string
description
string
required
Array of objects (Role) [ items ]
required
Array of objects (Channel) [ items ]
Array of objects (Connector) [ items ]

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get a design schema owned by user

path Parameters
user
required
string

user id

-
designId
required
string

design id

-
version
required
string

version string

-

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Update a schema for a given design

path Parameters
user
required
string

user id

-
designId
required
string

design id

-
version
required
string

version string

-
Request Body schema: application/json
version
required
string
name
required
string
description
string
required
Array of objects (Role) [ items ]
required
Array of objects (Channel) [ items ]
Array of objects (Connector) [ items ]

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

designCodes

Upload a new design code

path Parameters
user
required
string

user id

-
designId
required
string

design id

-
Request Body schema: multipart/form-data
fileName
required
string
fileVer
required
string
fileData
required
string <binary> <= 10485760 characters

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get a zipped design code file owned by user

path Parameters
user
required
string

user name

-
designId
required
string

design id

-
version
required
string

version string

-

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Update a design code

path Parameters
user
required
string

user id

-
designId
required
string

design id

-
version
required
string

version string

-
Request Body schema: multipart/form-data
fileName
required
string
fileVer
required
string
fileData
required
string <binary> <= 10485760 characters

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

datasets

Get the meta info on all the datasets

query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

-

Responses

Response samples

Content type
application/json
[]

Get the meta info on all the datasets owned by user

path Parameters
user
required
string

user id

-
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

-

Responses

Response samples

Content type
application/json
[]

Create meta info for a new dataset.

path Parameters
user
required
string

user id

-
Request Body schema: application/json

dataset information

-
id
string
userId
string
name
string
description
string
url
required
string
dataFormat
required
string
realm
required
string
isPublic
boolean

Responses

Request samples

Content type
application/json
{}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get dataset meta information

path Parameters
user
required
string

user id

-
datasetId
required
string

dataset id

-

Responses

Response samples

Content type
application/json
{}

Update meta info for a given dataset

path Parameters
user
required
string

user id

-
datasetId
required
string

dataset id

-
Request Body schema: application/json
id
string
userId
string
name
string
description
string
url
required
string
dataFormat
required
string
realm
required
string
isPublic
boolean

Responses

Request samples

Content type
application/json
{}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

jobs

Create a new job specification

path Parameters
user
required
string

user id

-
Request Body schema: application/json
id
string
userId
string
designId
required
string
schemaVersion
required
string
codeVersion
required
string
object (DataSpec)
object (Selector)
priority
any (JobPriority)
Enum: "low" "medium" "high"
backend
any (CommBackend)
Enum: "mqtt" "p2p"
maxRunTime
int32
Default: 600
object (BaseModel)
hyperparameters
object
dependencies
Array of strings

Responses

Request samples

Content type
application/json
{
  • "userId": "john",
  • "designId": "60d0d66716af12b787d9ef0a",
  • "schemaVersion": "1",
  • "codeVersion": "1",
  • "selector": {
    },
  • "prority": "low",
  • "backend": "mqtt",
  • "maxRunTime": 600,
  • "baseModel": {
    },
  • "hyperparameters": [
    ],
  • "dependencies": [
    ]
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get status info on all the jobs owned by user

path Parameters
user
required
string

user id

-
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

-

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get a job specification

path Parameters
user
required
string

user id

-
jobId
required
string

job id

-

Responses

Response samples

Content type
application/json
{
  • "userId": "john",
  • "designId": "60d0d66716af12b787d9ef0a",
  • "schemaVersion": "1",
  • "codeVersion": "1",
  • "selector": {
    },
  • "prority": "low",
  • "backend": "mqtt",
  • "maxRunTime": 600,
  • "baseModel": {
    },
  • "hyperparameters": [
    ],
  • "dependencies": [
    ]
}

Update a job specification

path Parameters
user
required
string

user id

-
jobId
required
string

job id

-
Request Body schema: application/json
id
string
userId
string
designId
required
string
schemaVersion
required
string
codeVersion
required
string
object (DataSpec)
object (Selector)
priority
any (JobPriority)
Enum: "low" "medium" "high"
backend
any (CommBackend)
Enum: "mqtt" "p2p"
maxRunTime
int32
Default: 600
object (BaseModel)
hyperparameters
object
dependencies
Array of strings

Responses

Request samples

Content type
application/json
{
  • "userId": "john",
  • "designId": "60d0d66716af12b787d9ef0a",
  • "schemaVersion": "1",
  • "codeVersion": "1",
  • "selector": {
    },
  • "prority": "low",
  • "backend": "mqtt",
  • "maxRunTime": 600,
  • "baseModel": {
    },
  • "hyperparameters": [
    ],
  • "dependencies": [
    ]
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Delete job specification

path Parameters
user
required
string

user id

-
jobId
required
string

job id

-

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get job status of a given jobId

path Parameters
user
required
string

user id

-
jobId
required
string

job id

-

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "state": "ready",
  • "createdAt": "2019-08-24T14:15:22Z",
  • "startedAt": "2019-08-24T14:15:22Z",
  • "updatedAt": "2019-08-24T14:15:22Z",
  • "endedAt": "2019-08-24T14:15:22Z"
}

Update the status of a job

path Parameters
user
required
string

user id

-
jobId
required
string

job id

-
Request Body schema: application/json
id
required
string
state
required
any (JobState)
Enum: "ready" "starting" "applying" "deploying" "stopping" "running" "failed" "terminated" "completed"
createdAt
string <date-time>
startedAt
string <date-time>
updatedAt
string <date-time>
endedAt
string <date-time>

Responses

Request samples

Content type
application/json
{
  • "id": "string",
  • "state": "ready",
  • "createdAt": "2019-08-24T14:15:22Z",
  • "startedAt": "2019-08-24T14:15:22Z",
  • "updatedAt": "2019-08-24T14:15:22Z",
  • "endedAt": "2019-08-24T14:15:22Z"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get the info of tasks in a job

path Parameters
user
required
string

user id

-
jobId
required
string

job id

-
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

-

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get a job task for a given job and agent

path Parameters
jobId
required
string

job id

-
agentId
required
string

flamelet agent Id

-
query Parameters
key
required
string

A key for task authentication; once the key is recognized by the flame system for the first time, it can't be changed.

-

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Update the status of a task

path Parameters
jobId
required
string

job id

-
agentId
required
string

agent id

-
Request Body schema: application/json
state
any (JobState)
Enum: "ready" "starting" "applying" "deploying" "stopping" "running" "failed" "terminated" "completed"
timestamp
string <date-time>

Responses

Request samples

Content type
application/json
{
  • "state": "ready",
  • "timestamp": "2019-08-24T14:15:22Z"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}
+ " fill="currentColor">

Flame REST API (1.0.0)

Download OpenAPI specification:Download

License: MIT

designs

Get list of all the designs created by the user.

path Parameters
user
required
string

user id

+
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

+

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create a new design template.

path Parameters
user
required
string

user name

+
Request Body schema: application/json

Collection of node information

+
name
required
string
description
string
id
required
string
userId
string

Responses

Request samples

Content type
application/json
{
  • "name": "diabete predict",
  • "description": "Helps in quick diagnosis and prediction of diabetes among patients.",
  • "id": "diabete-predict"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get design template information

path Parameters
user
required
string

user id

+
designId
required
string

design id

+

Responses

Response samples

Content type
application/json
{
  • "name": "diabete predict",
  • "description": "Helps in quick diagnosis and prediction of diabetes among patients.",
  • "id": "diabete-predict",
  • "schemas": [
    ]
}

Delete design template

path Parameters
user
required
string

user id

+
designId
required
string

design id

+

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

designSchemas

Get all design schemas in a design

path Parameters
user
required
string

user id

+
designId
required
string

design id

+

Responses

Response samples

Content type
application/json
{
  • "schemas": [
    ]
}

Update a design schema

path Parameters
user
required
string

user id

+
designId
required
string

design id

+
Request Body schema: application/json
version
required
string
name
required
string
description
string
required
Array of objects (Role)
required
Array of objects (Channel)
Array of objects (Connector)

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get a design schema owned by user

path Parameters
user
required
string

user id

+
designId
required
string

design id

+
version
required
string

version string

+

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Update a schema for a given design

path Parameters
user
required
string

user id

+
designId
required
string

design id

+
version
required
string

version string

+
Request Body schema: application/json
version
required
string
name
required
string
description
string
required
Array of objects (Role)
required
Array of objects (Channel)
Array of objects (Connector)

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Delete a schema for a given design

path Parameters
user
required
string

user id

+
designId
required
string

design id

+
version
required
string

version string

+
Request Body schema: application/json
version
required
string
name
required
string
description
string
required
Array of objects (Role)
required
Array of objects (Channel)
Array of objects (Connector)

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

designCodes

Upload a new design code

path Parameters
user
required
string

user id

+
designId
required
string

design id

+
Request Body schema: multipart/form-data
fileName
required
string
fileVer
required
string
fileData
required
string <binary> <= 10485760 characters

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get a zipped design code file owned by user

path Parameters
user
required
string

user name

+
designId
required
string

design id

+
version
required
string

version string

+

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Update a design code

path Parameters
user
required
string

user id

+
designId
required
string

design id

+
version
required
string

version string

+
Request Body schema: multipart/form-data
fileName
required
string
fileVer
required
string
fileData
required
string <binary> <= 10485760 characters

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Delete code of a specified version from a given design

path Parameters
user
required
string

user name

+
designId
required
string

design id

+
version
required
string

version string

+

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

datasets

Get the meta info on all the datasets

query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

+

Responses

Response samples

Content type
application/json
[]

Get the meta info on all the datasets owned by user

path Parameters
user
required
string

user id

+
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

+

Responses

Response samples

Content type
application/json
[]

Create meta info for a new dataset.

path Parameters
user
required
string

user id

+
Request Body schema: application/json

dataset information

+
id
string
userId
string
name
string
description
string
url
required
string
dataFormat
required
string
realm
required
string
computeId
string
isPublic
boolean

Responses

Request samples

Content type
application/json
{}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get dataset meta information

path Parameters
user
required
string

user id

+
datasetId
required
string

dataset id

+

Responses

Response samples

Content type
application/json
{}

Update meta info for a given dataset

path Parameters
user
required
string

user id

+
datasetId
required
string

dataset id

+
Request Body schema: application/json
id
string
userId
string
name
string
description
string
url
required
string
dataFormat
required
string
realm
required
string
computeId
string
isPublic
boolean

Responses

Request samples

Content type
application/json
{}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

jobs

Create a new job specification

path Parameters
user
required
string

user id

+
Request Body schema: application/json
id
string
userId
string
designId
required
string
schemaVersion
required
string
codeVersion
required
string
object (DataSpec)
object (Optimizer)
object (Selector)
priority
any (JobPriority)
Enum: "low" "medium" "high"
backend
any (CommBackend)
Enum: "mqtt" "p2p"
maxRunTime
integer <int32>
Default: 600
object (BaseModel)
hyperparameters
object
dependencies
Array of strings

Responses

Request samples

Content type
application/json
{
  • "userId": "john",
  • "designId": "60d0d66716af12b787d9ef0a",
  • "schemaVersion": "1",
  • "codeVersion": "1",
  • "selector": {
    },
  • "prority": "low",
  • "backend": "mqtt",
  • "maxRunTime": 600,
  • "baseModel": {
    },
  • "hyperparameters": [
    ],
  • "dependencies": [
    ]
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get status info on all the jobs owned by user

path Parameters
user
required
string

user id

+
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

+

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get a job specification

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+

Responses

Response samples

Content type
application/json
{
  • "userId": "john",
  • "designId": "60d0d66716af12b787d9ef0a",
  • "schemaVersion": "1",
  • "codeVersion": "1",
  • "selector": {
    },
  • "prority": "low",
  • "backend": "mqtt",
  • "maxRunTime": 600,
  • "baseModel": {
    },
  • "hyperparameters": [
    ],
  • "dependencies": [
    ]
}

Update a job specification

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+
Request Body schema: application/json
id
string
userId
string
designId
required
string
schemaVersion
required
string
codeVersion
required
string
object (DataSpec)
object (Optimizer)
object (Selector)
priority
any (JobPriority)
Enum: "low" "medium" "high"
backend
any (CommBackend)
Enum: "mqtt" "p2p"
maxRunTime
integer <int32>
Default: 600
object (BaseModel)
hyperparameters
object
dependencies
Array of strings

Responses

Request samples

Content type
application/json
{
  • "userId": "john",
  • "designId": "60d0d66716af12b787d9ef0a",
  • "schemaVersion": "1",
  • "codeVersion": "1",
  • "selector": {
    },
  • "prority": "low",
  • "backend": "mqtt",
  • "maxRunTime": 600,
  • "baseModel": {
    },
  • "hyperparameters": [
    ],
  • "dependencies": [
    ]
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Delete job specification

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get job status of a given jobId

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "state": "ready",
  • "createdAt": "2019-08-24T14:15:22Z",
  • "startedAt": "2019-08-24T14:15:22Z",
  • "updatedAt": "2019-08-24T14:15:22Z",
  • "endedAt": "2019-08-24T14:15:22Z"
}

Update the status of a job

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+
Request Body schema: application/json
id
required
string
state
required
any (JobState)
Enum: "ready" "starting" "applying" "deploying" "stopping" "running" "failed" "terminated" "completed"
createdAt
string <date-time>
startedAt
string <date-time>
updatedAt
string <date-time>
endedAt
string <date-time>

Responses

Request samples

Content type
application/json
{
  • "id": "string",
  • "state": "ready",
  • "createdAt": "2019-08-24T14:15:22Z",
  • "startedAt": "2019-08-24T14:15:22Z",
  • "updatedAt": "2019-08-24T14:15:22Z",
  • "endedAt": "2019-08-24T14:15:22Z"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get the info of a task in a job

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+
taskId
required
string

task id

+

Responses

Response samples

Content type
application/json
{
  • "jobId": "string",
  • "taskId": "string",
  • "role": "string",
  • "type": "user",
  • "key": "string",
  • "state": "ready",
  • "computeId": "string",
  • "log": "string",
  • "timestamp": "2019-08-24T14:15:22Z"
}

Get the info of tasks in a job

path Parameters
user
required
string

user id

+
jobId
required
string

job id

+
query Parameters
limit
integer <int32>

How many items to return at one time (max 100)

+

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get a job task for a given job and task

path Parameters
jobId
required
string

job id

+
taskId
required
string

flamelet task Id

+
query Parameters
key
required
string

A key for task authentication; once the key is recognized by the flame system for the first time, it can't be changed.

+

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Update the status of a task

path Parameters
jobId
required
string

job id

+
taskId
required
string

task id

+
Request Body schema: application/json
state
any (JobState)
Enum: "ready" "starting" "applying" "deploying" "stopping" "running" "failed" "terminated" "completed"
log
string
timestamp
string <date-time>

Responses

Request samples

Content type
application/json
{
  • "state": "ready",
  • "log": "string",
  • "timestamp": "2019-08-24T14:15:22Z"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

computes

Register a new compute cluster

Request Body schema: application/json
adminId
string
region
string
apiKey
string
computeId
string

Responses

Request samples

Content type
application/json
{
  • "adminId": "admin-1",
  • "region": "us-east",
  • "apiKey": "apikey-1",
  • "computeId": "compute-1"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get status of a given compute cluster

path Parameters
computeId
required
string

compute id of compute cluster

+
header Parameters
X-API-KEY
required
string

Responses

Response samples

Content type
application/json
{
  • "computeId": "string",
  • "registeredAt": "2019-08-24T14:15:22Z",
  • "state": "up",
  • "updatedAt": "2019-08-24T14:15:22Z"
}

Update a compute cluster's specification

path Parameters
computeId
required
string

compute id of compute cluster

+
header Parameters
X-API-KEY
required
string
Request Body schema: application/json
adminId
string
region
string
apiKey
string
computeId
string

Responses

Request samples

Content type
application/json
{
  • "adminId": "admin-1",
  • "region": "us-east",
  • "apiKey": "apikey-1",
  • "computeId": "compute-1"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Delete compute cluster specification

path Parameters
computeId
required
string

compute id of compute cluster

+
header Parameters
X-API-KEY
required
string

Responses

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get configuration for a compute cluster

path Parameters
computeId
required
string

compute id of compute cluster

+
header Parameters
X-API-KEY
required
string

Responses

Response samples

Content type
application/json
{
  • "adminId": "admin-1",
  • "region": "us-east",
  • "apiKey": "apikey-1",
  • "computeId": "compute-1"
}

Get all deployments within a compute cluster

path Parameters
computeId
required
string

compute id of compute cluster

+
header Parameters
X-API-KEY
required
string

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get the deployment config for a job for a compute cluster

path Parameters
computeId
required
string

compute id of compute cluster

+
jobId
required
string

job id

+
header Parameters
X-API-KEY
required
string

Responses

Response samples

Content type
application/json
{
  • "jobId": "string",
  • "imageLoc": "string",
  • "agentKVs": {
    }
}

Add or update the deployment status for a job on a compute cluster

path Parameters
computeId
required
string

compute id of compute cluster

+
jobId
required
string

job id

+
header Parameters
X-API-KEY
required
string
Request Body schema: application/json

Status for agents in a job deployment

+
property name*
additional property
any (AgentState)
Enum: "agentDeploySuccess" "agentDeployFailed" "agentRevokeSuccess" "agentRevokeFailed"

Responses

Request samples

Content type
application/json
{
  • "property1": "agentDeploySuccess",
  • "property2": "agentDeploySuccess"
}

Response samples

Content type
application/json
{
  • "code": 0,
  • "message": "string"
}

Get the deployment status for a job on a compute cluster

path Parameters
computeId
required
string

compute id of compute cluster

+
jobId
required
string

job id

+
header Parameters
X-API-KEY
required
string

Responses

Response samples

Content type
application/json
{
  • "property1": "agentDeploySuccess",
  • "property2": "agentDeploySuccess"
}