虚机执行Http请求
更新时间:2024-08-16
用途
用于在多台云服务器BCC实例内执行Http请求
参数
名称 | 类型 | 描述 |
---|---|---|
name | String | 模板任务名称,必填 |
operator | String | 模板任务类型,必填 |
properties | Map<String, Object> | 任务执行所需参数,必填,详细内容见下表 |
properties参数
名称 | 类型 | 描述 |
---|---|---|
__workerSelectors__ | List/Object | 实例ID,必填,支持多选 |
method | String | 请求方法类型,必填 |
url | String | 请求地址,必填 |
headers | Map<String, Object> | 请求头,选填 |
body | Object | 请求体,选填 |
timeoutMill | Integer | 请求连接超时时间,选填,默认10000ms |
示例
__workerSelectors__参数可以直接指定也可以引用模板中的全局参数,示例分别如下:
直接指定
JSON
1{
2 "name": "executeHttp",
3 "operator": "BCE::Agent::ExecuteHttp",
4 "properties": {
5 "method": "GET",
6 "url": "http://localhost:8080/api/getUser",
7 "body": {
8 },
9 "headers": {
10 "Content-Type": "application/json"
11 },
12 "timeoutMill": 5000,
13 "__workerSelectors__": [
14 {
15 "instanceId":"i-pqJV5Ptu" // BCC短ID
16 },
17 {
18 "instanceId":"i-rXV43yGW" // BCC短ID
19 }
20 ]
21 }
22}
引用全局参数
引用模板中的globalInstanceList全局参数
JSON
1{
2 "name": "executeHttp",
3 "operator": "BCE::Agent::ExecuteHttp",
4 "properties": {
5 "method": "GET",
6 "url": "http://localhost:8080/api/user/111",
7 "body": {
8 },
9 "headers": {
10 "Content-Type": "application/json"
11 },
12 "timeoutMill": 5000,
13 "__workerSelectors__": {
14 "Ref":"globalInstanceList"
15 }
16 }
17}