---
# System prepended metadata

title: Build cluster restful APIs design for Wistron Software Smart Factory latest

---

Build cluster APIs design for Software Smart Factory(SSF)
 ===
 DRAFT rev.20230228. Continuous improvement and modification.

Copyright ©  Wistron Corporation.


# Table of Contents

[TOC]

# Release and Update Notes

:::info

| Updated DateTime   | Description |
| --------     | -------- |
| 2023-02-28   | Initial Created on hackmd |

:::

# 1. Introduction
## 1.1 Function Blocks Overview



# 2. SSF APIs
## 2.1 Project

### 2.1.1 getProjectsByEmployee
 #### Parameters ###

Name	|Type		|Description  
:----	|:---			|:---	
employee_name    |string            |Employee name


#### Returns ###
 
Name			           |Description  
:----				       |:---	
project_name			   |Project name

#### Sample ###

###### Function sample
```
/* get all projects under the Bob_X_Liu */
http://cm-server.wistron.com:15656/getProjectsByEmployee/Bob_X_Liu
```

###### Return sample

```
{"Test_Project3","Test_Project4"}

```


### 2.1.2 getProjectInfo

 #### Parameters ###

Name	|Type		|Description  
:----	|:---			|:---	
project_name    |string            |Project name


#### Returns ###
 
Name			           |Description  
:----				       |:---	
old_project_name		   |Old project name
project_name			   |Current project name
project_code               |Project code
year                       |The year of the project
os_type                    |OS type: 1- Android; 2- Linux;3- Others
leader_name                |The Project leader name
manager_name               |The project supervisor name
expect_clean_build_time    |The project expect clean build time(Unit: second)
expect_dirty_build_time    |The project expect dirty build time(Unit: second)
eol                        |Whether the project status  is end of line
project_photo              |The project photo(Base64 format)

#### Sample ###

###### Function sample
```
http://cm-server.wistron.com:15656/getProjectInfo/Test_Project3
```

###### Return sample

```
[
    {
        "old_project_name": "",
        "project_name": "Test_Project3",
        "project_code": "project3",
        "year": 2023,
        "os_type": 1,
        "leader_name": "Aaron_s_Chen",
        "manager_name": "Bob_X_Liu",
        "expect_clean_build_time": "720",
        "expect_dirty_build_time": "360",
        "eol": 1,
        "project_photo": "data:image/png;base64,iVBORw0KGgoAAAA...."
    }
]
```

### 2.1.3 getExpectedBuildTime

 #### Parameters 
 No parameters


#### Returns 
Returns an array contains the expected build time data of each project.
osType: 1- Android; 2- Linux;3- Others
All time units are seconds.



#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getExpectedBuildTime
```

###### Return sample

```
{
    "1": {
        "4350PRO_POC": {
            "clean": 45000,
            "dirty": 12600
        },
        "6490_A13": {
            "clean": 0,
            "dirty": 0
        }
    },
    "2": {
        "5G-TBOX": {
            "clean": 19200,
            "dirty": 3300
        }
    },
    "3": {
        "BC Internal": {
            "clean": 0,
            "dirty": 0
        },
        "FALCON_CAMERA": {
            "clean": 600,
            "dirty": 600
        }
    }
}
```


### 2.1.4 getAllProjects

 #### Parameters 
  Name		|Type	           |Description  
:----		|:---		       |:---	
scope		|string        |Date scope(date format: 2022-12-16)
 
 #### Returns 
Returns an array contains projects info for specified date range(for queuing, building, completed value, it only returns today's data).
photo: base64 format.
hasReservedBuildMachine: indicate that the project has reserved at least on a build machine to use in current time.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getAllProjects/2022-12-15/2022-12-16
```

###### Return sample
```
[
    {
        "name": "6490_A13",
        "photo": "",
        "hasReservedBuildMachine": false,
        "queuing": 0,
        "building": 0,
        "completed": 2
    },
    {
        "name": "R-ROSA VC BAR",
        "photo": "",
        "hasReservedBuildMachine": false,
        "queuing": 0,
        "building": 2,
        "completed": 1
    },
    {
        "name": "R5",
        "photo": "data:image/png;base64,xxxxx....",
        "hasReservedBuildMachine": false,
        "queuing": 0,
        "building": 1,
        "completed": 1
    }
]
```

### 2.1.5 saveProjectInfo

 #### Parameters 
 No parameters
 
 #### Post Key 
 Post a json data to API, do CREATE if no "old_project_name" field; do UPDATE if has "old_project_name" field, some fields can be missing if the operation is UPDATE.
 os_type: 1- Android; 2- Linux;3- Others
 All time units are seconds.
 
 Name			           |Description  
:----				       |:---	
old_project_name		   |Old project name
project_name			   |Current project name
project_code               |Project code
year                       |The year of the project
os_type                    |OS type: 1- Android; 2- Linux;3- Others
leader_name                |The Project leader name
manager_name               |The project supervisor name
expect_clean_build_time    |The project expect clean build time(Unit: second)
expect_dirty_build_time    |The project expect dirty build time(Unit: second)
eol                        |Whether the project status is end of line
project_photo              |The project photo(Base64 format)

#### Post Sample 
URL:
```
http://cm-server.wistron.com:15656/saveProjectInfo
```
Post Data
```
{
    "old_project_name":"Jaw0",
    "project_name":"Jaws",
    "project_code":"1PD062550001",
    "bu":"V-BU3",
    "year":"2021",
    "os_type":1,
    "leader_name":"Peter_Tseng",
    "manager_name":"Jack_Lin",
    "expect_clean_build_time":17000,
    "expect_dirty_build_time":1800,
    "eol":false,
    "project_photo":"data:image/png;base64,iVBORw0KGgo"
}
```



## 2.2 Machine

### 2.2.1 getMachineStatus

#### Parameters
No parameters

#### Returns
Name			           |Description  
:----				       |:---	
builder		        |Builder name
availability	    |The current builder state. 0- Busy; 1- Idle; 2- Offline
cpu                 |CPU model
cpu_usage           |CPU usage
memory              |Memory size
memory_usage        |Memory usage
hdd_size            |HDD size
hdd_usage           |HDD usage
ssd_size            |SSD size
ssd_usage           |SSD usage
network_bandwidth   |Network bandwidth of the builder
network_utilization |Network utilization of the builder
property_tag        |
keeper_name         |
admin_name          |Administrator name
current_job         |Current job name

#### Sample ###

###### Function sample
```
http://cm-server.wistron.com:15656/getMachineStatus
```

###### Return sample
```
[
    {
        "builder": "2S0210",
        "availability": 0,
        "cpu": "Intel i7-4770",
        "cpu_usage": 20,
        "memory": 32,
        "memory_usage": 100,
        "hdd_size": 3600,
        "hdd_usage": 46,
        "ssd_size": 1800,
        "ssd_usage": 50,
        "network_bandwidth": 1000,
        "network_utilization": 500,
        "property_tag": "TPER40008747",
        "keeper_name": "Jimmy_Chuang",
        "admin_name": "Jimmy_Chuang",
        "current_job": "Building VIP3"
    }
]
```

### 2.2.2 getBuilderDisplayName

 #### Parameters ###
No parameters

#### Returns ###
Return a json string of builder display name

#### Sample ###

###### Function sample
```
http://cm-server.wistron.com:15656/getBuilderDisplayName
```

###### Return sample
```
{
    "2S0210": "Builder03",
    "2S0220": "Builder04",
    "2S0230_1": "Builder05",
    "2S1200": "Builder06",
    "2S1600": "Builder07",
    "BC_Builder01": "Builder01",
    "BC_Builder02": "Builder02"
}
```

### 2.2.3 getMachineAvailability

 #### Parameters 
 Name		|Type	           |Description  
:----		|:---		       |:---	
scope		|string        |Date scope(date format: 2022-12-16)


#### Returns 
Returns the status of builders for the specified date range.(online/offline)

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getMachineAvailability/2022-12-15/2022-12-16
```

###### Return sample
```
{
    "2022-12-15": {
        "online": [
            "2S0210",
            "2S0220",
            "2S0230_1",
            "2S1600",
            "BC_Builder01",
            "BC_Builder02"
        ],
        "offline": [
            "2S1200"
        ]
    },
    "2022-12-16": {
        "online": [
            "2S0210",
            "2S0220",
            "2S0230_1",
            "2S1200",
            "2S1600",
            "BC_Builder01",
            "BC_Builder02"
        ],
        "offline": null
    }
}
```


## 2.3 Reservation

### 2.3.1 getMachineReservation

 #### Parameters 
No parameters

#### Returns ###

Name			           |Description  
:----				       |:---	
builder		        |Builder name
reservation	    |Return a json string of reservation

#### Sample ###
###### Function sample
```
http://cm-server.wistron.com:15656/getMachineReservation
```

##### Return sample
```
[
    {
        "builder": "2S0210",
        "reservation": null
    },
    {
        "builder": "2S0220",
        "reservation": {
              "builder": "2S0210", 
              "requester":"Bob_X_Liu",
              "start_time": "2022/7/18 08:00", 
              "end_time": "2022/7/22 17:00", 
              "project": "Jaws", 
              "reason": "xxxxxxx"
         }
    }
]
```

### 2.3.2 getAvailableProjectsForReservation

 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
employee_name		    |string    | The user name of current user.

#### Returns 
All projects name and reviewers info, which exists under the current projectLeader,
Return null if employee is a normal user, or without permisson to reserve.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getAvailableProjectsForReservation/Bob_X_Liu
```

###### Return sample

```
[
    {
        "projectName": "Test_Project_Bob",
        "CMManagerName": "Jimmy_Chuang",
        "CMManagerEmail": "Jimmy_Chuang@wistron.com",
        "managerName": "King_D_Liu",
        "managerEmail": "King_D_Liu@wistron.com"
    },
    {
        "projectName": "Test_Project_BU",
        "CMManagerName": "Jimmy_Chuang",
        "CMManagerEmail": "Jimmy_Chuang@wistron.com",
        "managerName": "King_D_Liu",
        "managerEmail": "King_D_Liu@wistron.com"
    }
]
```

### 2.3.3 getReservedBuildersByProject

 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
project		    |string    | Project name.
 
 #### Returns 
 Return the information of reserved builder for the specified project at the current time.
Availability Machines status: 0- Busy; 1- Idle; 2- Offline

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getReservedBuildersByProject/VIP3
```

###### Return sample
```
{
    "availability": 0,
    "builder": "2S0210"
}
```

### 2.3.4 createAReservationRequest

 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
reserve_id		       |string    | The id of current reserve request
reserveRequesterName   |string    | The user name of current user.
buildMachine		   |string    | Select a machine to reserve.
startTime		       |string    | Start date and time for reservation.
endTime		           |string    | End date and time for reservation.
projectName		       |string    | Select a project.
reason		           |string    | The reason for application.
cmManagerName		   |string    | The name of cmManager.
supervisorName		   |string    | The name of supervisor.
reservationPassword	   |string    | The password for the reservation job.
 
 #### Returns 
No returns.

#### Sample

###### Function sample
```
http://cm-server.wistron.com:15656/createAReservationRequest/191/Bob_X_Liu/2S0230_1/2022-10-28 16:00:00/2022-10-28 17:00:00/Test_Project_Bob/roll out test 123/Bob_X_Liu/King_D_Liu/11e4e0
```

### 2.3.5 updateReviewerStatus

 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
reserve_id		     |string    | The id of current reserve request
cmManagerStatus      |string    | Approve status of cmManager. status contains (Pending, Accepted, Rejected).
cmManagerComment	 |string    | Comment of cmManager.
cmManagerSignTime	 |string    | Sign-off date-time of cmManager.
supervisorStatus	 |string    | Approve status of supervisor. status contains (Pending, Accepted, Rejected).
supervisorComment	 |string    | Comment of supervisor.
supervisorSignTime	 |string    | Sign-off date-time of supervisor.
isFinalApproved		 |string    | The final sign-off status, true or false.

 
 #### Returns 
No returns.

#### Sample

###### Function sample
```
http://cm-server.wistron.com:15656/updateReviewerStatus/191/Accepted/OK/2022-06-18 08:00/Accepted/OK/2022-06-22 08:00/true
```










## 2.4 Job
### 2.4.1 getJobsByStatus

 #### Parameters

Name	|Type		|Description  
:----	|:---			|:---	
status  |string  | 1. queuing - returns current queuing job info.<br> 2. building - returns current building job info.<br> 3. complete - returns today's complete job info


#### Returns 
 - queuing return
 
Name			           |Description  
:----				       |:---	
id			               |Job ID
name			           |owner
queue_time                 |The job queuing time(Unit: second)
estimated_to_start_time    |Estimated to start time(Unit: second)
projectName                |Queuing job project name
reserved_builder           |Reserved builder name
builder                    |Builder name


 - building return
 
Name			           |Description  
:----				       |:---	
id			               |Job ID
name			           |Job name
builder			           |Builder name
building_time              |The job building time(Unit: second)
isReserved                 |Whether the current job is reserved
estimated_to_finish_time   |Estimated to finish time(Unit: second)
projectName                |Building job project name

 - complete return
 
Name		 |Description  
:----		 |:---	
id			 |Job ID
employeeid	 |Employee ID
builder		 |Builder name
isReserved   |Whether the job is reserved
buildtime    |Build time(Unit: second)
finishtime   |Build finish date and time(e.g:2022-08-26 20:14:34)
projectname  |Complete job project name
result       |Job build result

#### Sample 

- #### queuing sample

###### Function sample 
```
http://cm-server.wistron.com:15656/getJobsByStatus/queuing
```

###### Return sample
```
[
       {
		"id": 1669,
		"name": "Peyton_Chang",
		"builder": "BC_Builder01",
		"queue_time": "2640",
		"estimated_to_start_time": "71050",
		"projectName": "Bobcat",
		"reserved_builder": "NA"
	},
	{
		"id": 1674,
		"name": "Timmy_Chen",
		"builder": "2S1200",
		"queue_time": "765",
		"estimated_to_start_time": "54265",
		"projectName": "Arashi",
		"reserved_builder": "2S1200"
	}
]
```

- ##### building sample

###### Function sample
```
http://cm-server.wistron.com:15656/getJobsByStatus/building
```

###### Return sample
```
[
    {
        "id": 6075,
        "name": "linda_chang",
        "builder": "2S1200",
        "building_time": "17634",
        "estimated_to_finish_time": "21827",
        "projectName": "Jaws"
    },
    {
        "id": 6090,
        "name": "David_Huang",
        "builder": "BC_Builder01",
        "building_time": "1887",
        "isReserved": "true",
        "estimated_to_finish_time": "9667",
        "projectName": "VIP3"
    }
]
```

- #### complete sample

###### Function sample
```
http://cm-server.wistron.com:15656/getJobsByStatus/complete
```

###### Return sample
```
[
    {
        "id": "2247",
        "employeeid": "TBD",
        "builder": "BC_Builder01",
        "isReserved": "false",
        "buildtime": "00:13:34",
        "finishtime": "2022-08-26 20:14:34",
        "projectname": "KDS",
        "result": "SUCCESS"
    },
    {
        "id": "312",
        "employeeid": "TBD",
        "builder": "2S1600",
        "isReserved": "false",
        "buildtime": "03:44:06",
        "finishtime": "2022-06-03 17:21:33",
        "projectname": "6490_factory",
        "result": "SUCCESS"
    }
]
```





### [Deprecated] 2.4.2 getBuildLog

 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
id		    |int    |The id of current job

 
 #### Returns 
Return the build log info of the specified job

#### Sample

###### Function sample
```
http://cm-server.wistron.com:15656/getBuildLog/6075
```

###### Return sample
```
{
    "message": "//hardware/interfaces/camera/device/3.5/default:camera.device@3.5-impl clang++ CameraDeviceSession.cpp [arm]\n[ 46% 28779/62519]"
}
```


### [Deprecated] 2.4.3 abortJob

 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
id		    |int    |The id of current job

 
 #### Returns
No Returns

#### Sample

###### Function sample
```
http://cm-server.wistron.com:15656/abortJob/6075
```






## 2.5 Analysis


### 2.5.1 getAverageUtilizationRateOfAllBuilders

 #### Parameters 
 Name			|Type           |Description  
:----			|:---	       |:---	
scope		    |string    |Optional. Date scope(date format: 2022-12-16)



#### Returns 
Returns an array containing the average utilization of all builders during the specified time.
The past 12 hours should contain current hour real-time data.

#### Sample 
###### Function sample
```
/* Get the data for the past 12 hours */
http://cm-server.wistron.com:15656/getAverageUtilizationRateOfAllBuilders

/* Get data for a date range */
http://cm-server.wistron.com:15656/getAverageUtilizationRateOfAllBuilders/2022-12-15/2022-12-17

```

###### Return sample
no scope parameter, return the data for the past 12 hours
```
{"03:00":0,"04:00":0,"05:00":0,"06:00":0,"07:00":0,"08:00":14,"09:00":14,"10:00":28,"11:00":28,"12:00":42,"13:00":28,"14:00":42}
```

Get data for a date range
```
{
    "2022-12-15": 15,
    "2022-12-16": 20,
    "2022-12-17": 3
}
```
### 2.5.2 getDetailUtilizationRateOfAllBuilders
 #### Parameters 
 Name			|Type           |Description  
:----			|:---	       |:---	
scope		    |string    |Date time scope:<br>(Date format: 2022-12-16 <br>Time format: 2022-12-16-14:00)

#### Returns 
Returns an array contains the data of each builder.


#### Sample 
###### Function sample
```
/* Get the data at the specified time */
http://cm-server.wistron.com:15656/getDetailUtilizationRateOfAllBuilders/2022-12-16-13:00/2022-12-16-14:00

/* Get data for the specified date  */
http://cm-server.wistron.com:15656/getDetailUtilizationRateOfAllBuilders/2022-12-15/2022-12-15

```

###### Return sample

```
{
    "Builder01": 15,
    "Builder02": 20,
    "Builder03": 30
}
```



### [TBD] 2.5.3 getUtilizationRateByBuilder
 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
builder		    |string    | Builder name.
scope		    |string    |Optional. Date scope(date format: 2022-12-16)
 
 #### Returns 
Returns the Utilization Rate information of the specified builder in the past 12 hours.
The past 12 hours should contain current hour real-time data.

#### Sample 
###### Function sample

```
/* Get the data for the past 12 hours */
http://cm-server.wistron.com:15656/getUtilizationRateByBuilder/Builder01

/* Get data for a date range */
http://cm-server.wistron.com:15656/getUtilizationRateByBuilder/Builder01/2022-12-15/2022-12-17
```

###### Return sample
no scope parameter, return the data for the past 12 hours
```
{"03:00":0,"04:00":0,"05:00":0,"06:00":0,"07:00":0,"08:00":14,"09:00":14,"10:00":28,"11:00":28,"12:00":42,"13:00":28,"14:00":42}
```
Get data for a date range
```
{
    "2022-12-15": 5,
    "2022-12-16": 10,
    "2022-12-17": 3
}
```


### 2.5.4 getCompletedBuilds

 #### Parameters
No parameters

#### Returns 
Returns an array contains the completed builds data(non-cumulative) of each hour for the past 12 hours.
The past 12 hours should contain current hour real-time data.

#### Sample
###### Function sample
```
http://cm-server.wistron.com:15656/getCompletedBuilds
```
###### Return sample
```
{"03:00":"1","04:00":"0","05:00":"0","06:00":"0","07:00":"0","08:00":"0","09:00":"1","10:00":"4","11:00":"5","12:00":"2","13:00":"5","14:00":"3"}
```

### 2.5.5 getDetailCompletedBuilds
 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
scope		|string        |Date scope(date format: 2022-12-16-13:00)
#### Returns 
Returns an array contains the completed builds data(non-cumulative) of each Builder for the specified hour.

#### Sample 
###### Function sample
```
/* Get the data for the specified hours */
http://cm-server.wistron.com:15656/getDetailCompletedBuilds/2022-12-10-13:00/2022-12-13-14:00

```
###### Return sample

```
[
    {
        "builderName": "Builder01",
        "number": 3
    },
    {
        "builderName": "Builder02",
        "number": 0
    },
    {
        "builderName": "Builder03",
        "number": 0
    }
]
```

### 2.5.6 getBCUsage

 #### Parameters 
  Name			|Type           |Description
:----			|:---	       |:---	
scope		    |string    | Date scope(date format: 2022-12-16)
name            |string    | Project name
 
 #### Returns 
Returns users BC usage for the project in the scope date, query only for the completed jobs.
Completed job: the jobs which have completed building, status contains both Success and Failed, exclude Abort.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getBCUsage/2022-07-01/2022-08-01/Bobcat
```

###### Return sample
```
{
    "Daily": 8,
    "Bob": 11,
    "Chris": 13,
    "King": 1
}
```

### 2.5.7 getCompletedBuildsDistribution

 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
scope		|string        |Optional. Date scope(date format: 2022-12-16)


#### Returns
Returns an array contains the completed builds data(non-cumulative) of each project; if no scope parameter, returns the completed builds data(non-cumulative) for the past 12 hours.
The past 12 hours should contain current hour real-time data.


#### Sample 
###### Function sample
```
/* Get the data for the past 12 hours */
http://cm-server.wistron.com:15656/getCompletedBuildsDistribution

/* Get data for a date range */
http://cm-server.wistron.com:15656/getCompletedBuildsDistribution/2022-12-10/2022-12-25
```
###### Return sample

```
[
    {
        "projectName": "R5",
        "number": 1
    },
    {
        "projectName": "R-ROSA VC BAR",
        "number": 3
    },
    {
        "projectName": "Arashi",
        "number": 1
    }
]
```

### 2.5.8 getDetailCompletedBuildsDistribution
 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
projectName |string        | project name
scope		|string        |Optional. Date scope(date format: 2022-12-16)

#### Returns
Returns an array contains the completed builds data(non-cumulative) for specified project; if no scope parameter, returns the completed builds data(non-cumulative) for the past 12 hours.
The past 12 hours should contain current hour real-time data.

#### Sample 
###### Function sample
```
/* Get the data for the past 12 hours */
http://cm-server.wistron.com:15656/getDetailCompletedBuildsDistribution/Arashi

/* Get data for a date range */
http://cm-server.wistron.com:15656/getDetailCompletedBuildsDistribution/Arashi/2022-12-10/2022-12-25
```
###### Return sample

```
[
    {
        "builderName": "Builder01",
        "number": 3
    },
    {
        "builderName": "Builder02",
        "number": 0
    },
    {
        "builderName": "Builder03",
        "number": 0
    }
]
```


### [TBD] 2.5.9 getCompletedBuildsDistributionByBuilder
 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
builder		    |string    | Builder name.
scope		|string        |Optional. Date scope(date format: 2022-12-16)

#### Returns
Returns an array contains the completed builds data(non-cumulative) of each builder; if no scope parameter, returns the completed builds data(non-cumulative) for the past 12 hours.
The past 12 hours should contain current hour real-time data.

#### Sample 
###### Function sample
```
/* Get the data for the past 12 hours */
http://cm-server.wistron.com:15656/getCompletedBuildsDistributionByBuilder/Builder01

/* Get data for a date range */
http://cm-server.wistron.com:15656/getCompletedBuildsDistributionByBuilder/Builder01/2022-12-15/2022-12-17
```
###### Return sample
Return the data for the past 12 hours
```
{"03:00":"1","04:00":"0","05:00":"0","06:00":"0","07:00":"0","08:00":"0","09:00":"1","10:00":"4","11:00":"5","12:00":"2","13:00":"5","14:00":"3"}
```
Return data for  a data range
```
{
    "2022-12-15": 15,
    "2022-12-16": 20,
    "2022-12-17": 3
}
```


### 2.5.10 getAverageBuildTimePerOsType

 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
scope		|string        |Date scope(date format: 2022-12-16)


#### Returns 
Returns an array contains the query data.
osType: 1- Android; 2- Linux;3- Others
All time units are seconds.
average time = total jobs build time / total jobs count.


#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getAverageBuildTimePerOsType/2022-12-10/2022-12-12
```
###### Return sample

```
{
    "1": {
        "2022-12-10": 1955.1071,
        "2022-12-11": 7694.3333,
        "2022-12-12": 8789
    },
    "2": {
        "2022-12-10": 361,
        "2022-12-11": 6216,
        "2022-12-12": 30
    },
    "3": {
        "2022-12-10": 361
    }
}
```

### 2.5.11 getDetailBuildTimePerOsType
 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
osType      |int           |1- Android; 2- Linux;3- Others
date		|string        |Date (date format: 2022-12-16)


#### Returns 
Returns an array contains the query data.
All time units are seconds.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getDetailBuildTimePerOsType/1/2022-12-10
```
###### Return sample

```
{
    "Builder01": 1955.1071,
    "Builder02": 2000,
    "Builder03": 1500
}
```


### [TBD] 2.5.12 getBuildTimeByBuilder
 #### Parameters 
 Name		|Type	           |Description
:----		|:---		       |:---	
builder      |string        |Builder name
scope		|string        |Date scope(date format: 2022-12-16)

#### Returns 
Returns an array contains the query data.
All time units are seconds.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getBuildTimeByBuilder/Builder01/2022-12-10/2022-12-12
```
###### Return sample

```
{
    "1": {
        "2022-12-10": 1000,
        "2022-12-11": 3000,
        "2022-12-12": 8789
    },
    "2": {
        "2022-12-10": 361,
        "2022-12-11": 6216,
        "2022-12-12": 30
    },
    "3": {
        "2022-12-10": 361
    }
}
```

### 2.5.13 getAverageQueueTime

 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
scope		    |string    |Optional. Date scope(date format: 2022-12-16)


#### Returns
Returns an array containing the average queue time for each of the last xx days or hourly for the last 12 hours.
All time units are seconds.
The past 12 hours should contain current hour real-time data.


#### Sample 
###### Function sample
```
/* Get the data for the past 12 hours */
http://cm-server.wistron.com:15656/getAverageQueueTime

/* Get data for a date range */
http://cm-server.wistron.com:15656/getAverageQueueTime/2022-12-10/2022-12-12
```
###### Return sample
no scope parameter, return the data for the past 12 hours

```
{"05:00":"0","06:00":"0","07:00":"0","08:00":"0","09:00":"0","10:00":"0","11:00":"0","12:00":"0","13:00":"0","14:00":"0","15:00":"0","16:00":"0"}
```

Get data for a date range
```
{
    "2022-12-10": "0",
    "2022-12-11": "0",
    "2022-12-12": "0"
}
```

### 2.5.14 getDetailQueueTime

 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
scope		    |string    |Date time scope:<br>(Date format: 2022-12-16 <br>Time format: 2022-12-16-14:00)


#### Returns
Returns an array containing the queuing time on each builder for a specified day or a specified hour.
All time units are seconds.

#### Sample 
###### Function sample
```
/* Get the data for the specified hours */
http://cm-server.wistron.com:15656/getDetailQueueTime/2022-12-16-13:00/2022-12-16-14:00

/* Get data for a date range */
http://cm-server.wistron.com:15656/getDetailQueueTime/2022-12-10/2022-12-10
```
###### Return sample

```
{
    "Builder01": 5000,
    "Builder02": "0",
    "Builder03": "0"
}
```



### [TBD] 2.5.15 getQueueTimeByBuilder
 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
builder         |string    |Builder name
scope		    |string    |Optional. Date scope(date format: 2022-12-16)

#### Returns
Returns the queue time for each builder within a specified time.
All time units are seconds.
The past 12 hours should contain current hour real-time data.

#### Sample 
###### Function sample
```
/* Get the data of Bulder01 for the past 12 hours */
http://cm-server.wistron.com:15656/getQueueTimeByBuilder/Builder01

/* Get data of Builder01 for a date range */
http://cm-server.wistron.com:15656/getQueueTimeByBuilder/Builder01/2022-12-10/2022-12-12
```
###### Return sample
no scope parameter, return the data for the past 12 hours

```
{"05:00":"0","06:00":"0","07:00":"0","08:00":"0","09:00":"0","10:00":"0","11:00":"0","12:00":"0","13:00":"0","14:00":"0","15:00":"0","16:00":"0"}
```

Get data for a date range
```
{
    "2022-12-10": "0",
    "2022-12-11": "0",
    "2022-12-12": "0"
}
```

### 2.5.16 getTimeDistribution

 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
scope		    |string    | Date scope(date format: 2022-12-16)


#### Returns 
Returns an array contains the data of each project.
All time units are seconds.
For project time distribution, it's build-time, doesn't contain queue-time.


#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getTimeDistribution/2022-12-10/2022-12-25
```

###### Return sample

```
{
    "6490_A13": 383988,
    "6490_factory": 857387,
    "660_A13": 17577,
    "660_factory": 299943,
    "Arashi": 522134,
    "HDPS2": 15111,
    "Horus": 2257,
    "Idle": 9504000,
    "Jaws": 23485,
    "KDS": 419926,
    "R5": 13917,
    "VIP3": 3503,
    "glasgow": 194813
}
```
### 2.5.17 getDetailTimeDistribution

 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
project         |string          | Project name
scope		    |string    | Date scope(date format: 2022-12-16)

#### Returns 
Returns an array containing the build time of the specified project on each builder within the specified time.
All time units are seconds.
For project time distribution, it's build-time, doesn't contain queue-time.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getDetailTimeDistribution/6490_factory/2022-12-10/2022-12-12
```

###### Return sample

```
{
    "Builder01": {
        "2022-12-10": 1000,
        "2022-12-11": 3000,
        "2022-12-12": 8789
    },
    "Builder02": {
        "2022-12-10": 361,
        "2022-12-11": 6216,
        "2022-12-12": 30
    },
    "Builder03": {
        "2022-12-10": 361
    }
}
```


### [TBD] 2.5.18 getTimeDistributionByBuilder
 #### Parameters 
 Name			|Type           |Description
:----			|:---	       |:---	
builder         |string    |Builder name
scope		    |string    | Date scope(date format: 2022-12-16)

#### Returns 
Returns an array of specified builder data.
All time units are seconds.

#### Sample 
###### Function sample
```
http://cm-server.wistron.com:15656/getTimeDistributionByBuilder/Builder01/2022-12-10/2022-12-25
```

###### Return sample

```
{
    "Builder01": 3839883,
    "Builder02": 857387,
    "Builder03": 17577
}
```







### 2.5.19 getCompletedBuildsDistributionByProject

 #### Parameters
  Name			|Type           |Description
:----			|:---	       |:---	
scope		    |string    | Date scope(date format: 2022-12-16)
name            |string    | Project name
 
 #### Returns
Returns builds distribution for the project in the scope date, query only for the completed jobs.
All time units are seconds
Completed jobs: the jobs which have completed building, contains both Success and Failed, exclude Abort.

#### Sample
###### Function sample
```
http://cm-server.wistron.com:15656/getCompletedBuildsDistributionByProject/2022-07-01/2022-07-06/Bobcat
```

###### Return sample
```
{
    "2022-07-01": {
        "totalCount": 11,
        "totalBuildTime": 1792
    },
    "2022-07-04": {
        "totalCount": 3,
        "totalBuildTime": 4700
    },
    "2022-07-05": {
        "totalCount": 2,
        "totalBuildTime": 1143
    },
    "2022-07-06": {
        "totalCount": 9,
        "totalBuildTime": 53323
    }
}
```



