Added support of new image_url field
[src/xds/xds-server.git] / lib / xsapiv1 / sdks.go
1 /*
2  * Copyright (C) 2017-2018 "IoT.bzh"
3  * Author Sebastien Douheret <sebastien@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package xsapiv1
19
20 // SDK status definition
21 const (
22         SdkStatusDisable      = "Disable"
23         SdkStatusNotInstalled = "Not Installed"
24         SdkStatusInstalling   = "Installing"
25         SdkStatusUninstalling = "Un-installing"
26         SdkStatusInstalled    = "Installed"
27 )
28
29 // SDK Define a cross tool chain used to build application
30 type SDK struct {
31         ID          string `json:"id" binding:"required"`
32         Name        string `json:"name"`
33         UUID        string `json:"uuid"`
34         Description string `json:"description"`
35         Profile     string `json:"profile"`
36         Version     string `json:"version"`
37         Arch        string `json:"arch"`
38         Path        string `json:"path"`
39         URL         string `json:"url"`
40         ImageURL    string `json:"image_url"`
41         Status      string `json:"status"`
42         Date        string `json:"date"`
43         Size        string `json:"size"`
44         Md5sum      string `json:"md5sum"`
45         SetupFile   string `json:"setupFile"`
46         LastError   string `json:"lastError"`
47
48         // Not exported fields
49         FamilyConf SDKFamilyConfig `json:"-"`
50 }
51
52 // SDKFamilyConfig Configuration structure to define a SDKs family
53 type SDKFamilyConfig struct {
54         FamilyName   string `json:"familyName"`
55         Description  string `json:"description"`
56         RootDir      string `json:"rootDir"`
57         EnvSetupFile string `json:"envSetupFilename"`
58         ScriptsDir   string `json:"scriptsDir"`
59 }
60
61 // SDKInstallArgs JSON parameters of POST /sdks or /sdks/abortinstall commands
62 type SDKInstallArgs struct {
63         ID          string   `json:"id"`          // install by ID (must be part of GET /sdks result)
64         Filename    string   `json:"filename"`    // install by using a file
65         Force       bool     `json:"force"`       // force SDK install when already existing
66         Timeout     int      `json:"timeout"`     // 1800 == default 30 minutes
67         InstallArgs []string `json:"installArgs"` // args directly passed to add/install script
68 }
69
70 // SDK SDKManagementMsg Actions
71 const (
72         SdkMgtActionInstall = "installing"
73         SdkMgtActionRemove  = "removing"
74 )
75
76 // SDKManagementMsg Message send during SDK installation or when installation is complete
77 type SDKManagementMsg struct {
78         CmdID     string `json:"cmdID"`
79         Timestamp string `json:"timestamp"`
80         Action    string `json:"action"`
81         Sdk       SDK    `json:"sdk"`
82         Stdout    string `json:"stdout"`
83         Stderr    string `json:"stderr"`
84         Progress  int    `json:"progress"` // 0 = not started to 100% = complete
85         Exited    bool   `json:"exited"`
86         Code      int    `json:"code"`
87         Error     string `json:"error"`
88 }