网流管理接口
本节介绍网流管理接口。
查询设备信息
接口功能
查询eSight 网流监控的设备信息。
URI路径
/rest/openapi/network/nta/devicemgr/deviceinfo
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求头参数列表 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用安全管理登录接口获取openid。 |
nedn |
可选 |
请求实体参数列表 |
String |
设备DN。 该参数可以设置为多个设备DN,不同DN间使用“;”分隔,最大数目为10。 |
neid |
可选 |
请求实体参数列表 |
String |
设备ID,网流子系统的设备标识。 该参数可以设置为多个设备ID,不同ID间使用“;”分隔,最大数目为10。 |
aliasname |
可选 |
请求实体参数列表 |
String |
设备别名,网管侧。 该参数可以设置为多个设备名称,不同名称间使用“;”分隔,最大数目为10。 |
nename |
可选 |
请求实体参数列表 |
String |
设备名称,设备侧。 该参数可以设置为多个主机名称,不同主机名称间使用“;”分隔,最大数目为10。 |
neip |
可选 |
请求实体参数列表 |
String |
设备IP地址。 该参数可以设置为多个设备IP地址,不同设备IP地址间使用“;”分隔,最大数目为10。 |
nestate |
可选 |
请求实体参数列表 |
int |
设备管理状态。可以是如下值之一: ·0 不区分状态,默认 ·1 管理 ·2 去管理 ·3 其他 |
page_size |
可选 |
请求实体参数列表 |
int |
返回每页记录数量。 默认为20条记录,最大可设置为100条 |
page_num |
可选 |
请求实体参数列表 |
int |
分页页码。 默认为1,最大可设置为21474836。 1代表第一页,2代表第二页,以此类推。 |
请求示例
curl -X get -k -H 'openid: 6c719e7633c0194237f5ae4aa5f45f4def2bf323c5d21fb4' -i 'https://10.120.66.130:32102/rest/openapi/network/nta/devicemgr/deviceinfo'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
String |
查询得到的信息,json格式。 |
description |
String |
接口调用结果的描述信息。 |
data包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
page_size |
int |
当前页的记录数 |
total_page |
int |
符合查询条件的记录总页数 |
current_page |
int |
当前页,从1开始 |
device_infos |
List<DeviceInfo> |
已管理设备列表 |
DeviceInfo包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
nedn |
int |
设备DN |
deviceid |
int |
设备ID |
aliasname |
String |
设备名称 |
nename |
String |
主机名称 |
neip |
String |
设备IP地址 |
nestate |
int |
设备管理状态。可以是如下值之一:
|
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 306 {"code":0,"data":{"device_infos":[{"nedn":"NE=34603109","neip":"10.134.23.105","nestate":1,"deviceid":1,"aliasname":"nkgy4l004032591.china.huawei.com","nenameInOpenApi":"nkgy4l004032591.china.huawei.com"}],"total_page":1,"current_page":1,"page_size":1},"description":"Operation success."}
注意事项
不支持并发。
使用示例
import org.apache.http.HttpResponse; import org.apache.http.message.BasicNameValuePair; public class Query { private static final String EAM_TYPE = "/rest/openapi/network/nta/devicemgr/deviceinfo"; public static void main(String[] args) throws Exception { Login.login(); queryTest(); } public static void queryTest() throws Exception { //set the URL and method String openidURL = EAM_TYPE; String method = "GET"; //set headers BasicNameValuePair[] headers = NewRosSecurity.getRosHttpHeader(openidURL, method); //set parameters BasicNameValuePair[] parameters = { new BasicNameValuePair("neid", 1) }; //send the request HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP, GlobalVar.GLOBAL_PORT, openidURL, method, headers, parameters); //get the result String body = NewHttpsAccess.getResult(response); System.out.println(body); } } 执行结果如下: { "code": 0, "data": { "page_size": 1, "total_page": 1, "current_page": 1, "device_infos": [ { "aliasname": "nkgy5dwx3800661.china.huawei.com", "nedn": "NE=34603009", "nename": "nkgy5dwx3800661.china.huawei.com", "nestate": 1, "deviceid": 1, "neip": "10.134.122.185" } ] }, "description": "Operation success." }
查询接口信息
接口功能
查询eSight网流系统接口信息。
URI路径
/rest/openapi/network/nta/ifmgr/interfaceinfo
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求头参数列表 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用安全管理登录接口获取openid。 |
neid |
必选 |
请求实体参数列表 |
String |
设备ID,网流子系统的设备标识。 该参数就是查询设备信息返回的deviceid。 |
ifid |
可选 |
请求实体参数列表 |
String |
接口ID,网流子系统的接口标识。 该参数可以设置为多个接口ID,不同ID间使用“;”分隔,最大数目为10。 |
ifindex |
可选 |
请求实体参数列表 |
String |
接口索引,设备单板上的接口索引号。 该参数可以设置为多个接口索引,不同索引间使用“;”分隔,最大数目为10。 |
ifstate |
可选 |
请求实体参数列表 |
int |
接口监控状态。可以是如下值之一:
|
page_size |
可选 |
请求实体参数列表 |
int |
返回每页记录数量。 默认为20条记录,最大可设置为100条 |
page_num |
可选 |
请求实体参数列表 |
int |
分页页码。 默认为1,最大可设置为21474836。 1代表第一页,2代表第二页,以此类推。 |
请求示例
curl -X get -k -H 'openid: 15cf17442da21b3cce78315b60854a35ea4992204eaa1cde' -i 'https://10.120.66.130:32102/rest/openapi/network/nta/ifmgr/interfaceinfo?neid=1'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
String |
查询得到的信息,json格式。 |
description |
String |
接口调用结果的描述信息。 |
data包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
page_size |
int |
当前页的记录数 |
total_page |
int |
符合查询条件的记录总页数 |
current_page |
int |
当前页,从1开始 |
interface_infos |
List<InterfaceInfo> |
已监控接口列表 |
InterfaceInfo包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
ifid |
int |
接口ID |
ifindex |
int |
接口索引 |
ifname |
String |
接口名称 |
ifalias |
String |
接口别名 |
sample_rate_in |
int |
流入采样比 |
sample_rate_out |
int |
流出采样比 |
ifstate |
int |
接口监控状态。可以是如下值之一:
|
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 990 {"code":0,"data":{"interface_infos":[{"ifid":1},{"ifindex":20},{"ifalias":"IfIndex_20"},{"sample_rate_in":1000},{"sample_rate_out":1000},{"ifstate":1},{"ifnameInOpenApi":"IfIndex_20"},{"ifid":2},{"ifindex":21},{"ifalias":"IfIndex_21"},{"sample_rate_in":1000},{"sample_rate_out":1000},{"ifstate":1},{"ifnameInOpenApi":"IfIndex_21"},{"ifid":3},{"ifindex":1},{"ifalias":"IfIndex_1"},{"sample_rate_in":1000},{"sample_rate_out":1000},{"ifstate":1},{"ifnameInOpenApi":"IfIndex_1"},{"ifid":4},{"ifindex":2},{"ifalias":"IfIndex_2"},{"sample_rate_in":1000},{"sample_rate_out":1000},{"ifstate":1},{"ifnameInOpenApi":"IfIndex_2"},{"ifid":5},{"ifindex":4},{"ifalias":"IfIndex_4"},{"sample_rate_in":1000},{"sample_rate_out":1000},{"ifstate":1},{"ifnameInOpenApi":"IfIndex_4"},{"ifid":6},{"ifindex":3},{"ifalias":"IfIndex_3"},{"sample_rate_in":1000},{"sample_rate_out":1000},{"ifstate":1},{"ifnameInOpenApi":"IfIndex_3"}],"total_page":1,"current_page":1,"page_size":6},"description":"Operation success."}
注意事项
不支持并发。
使用示例
import org.apache.http.HttpResponse; import org.apache.http.message.BasicNameValuePair; public class Query { private static final String EAM_TYPE = "/rest/openapi/network/nta/ifmgr/interfaceinfo"; public static void main(String[] args) throws Exception { Login.login(); queryTest(); } public static void queryTest() throws Exception { //set the URL and method String openidURL = EAM_TYPE; String method = "GET"; //set headers BasicNameValuePair[] headers = NewRosSecurity.getRosHttpHeader(openidURL, method); //set parameters BasicNameValuePair[] parameters = { new BasicNameValuePair("neid", 1) }; //send the request HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP, GlobalVar.GLOBAL_PORT, openidURL, method, headers, parameters); //get the result String body = NewHttpsAccess.getResult(response); System.out.println(body); } }
执行结果如下:
{ "code": 0, "data": { "page_size": 3, "total_page": 1, "current_page": 1, "interface_infos": [ { "ifindex": 1, "ifstate": 1, "ifalias": "", "ifname": "Software Loopback Interface 1", "sample_rate_in": 1000, "ifid": 1, "sample_rate_out": 1000 }, { "ifindex": 2, "ifstate": 2, "ifalias": "", "ifname": "WAN Miniport (SSTP)", "sample_rate_in": 1000, "ifid": 2, "sample_rate_out": 1000 }, { "ifindex": 3, "ifstate": 1, "ifalias": "", "ifname": "WAN Miniport (L2TP)", "sample_rate_in": 1000, "ifid": 3, "sample_rate_out": 1000 } ] }, "description": "Operation success." }
查询应用信息
接口功能
查询应用名称。
URI路径
/rest/openapi/network/nta/appmgr/appinfo
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求头参数列表 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用安全管理登录接口获取openid。 |
appid |
可选 |
请求实体参数列表 |
String |
应用索引,网流子系统的应用索引。 该参数可以设置为多个应用索引,不同索引间使用“;”分隔,最大数目为10。 |
appname |
可选 |
请求实体参数列表 |
String |
应用名称。 该参数可以设置为多个应用名称,不同名称间使用“;”分隔,最大数目为10。 |
page_size |
可选 |
请求实体参数列表 |
int |
返回每页记录数量。 默认为20条记录,最大可设置为100条 |
page_num |
可选 |
请求实体参数列表 |
int |
分页页码。 默认为1,最大可设置为21474836。 1代表第一页,2代表第二页,以此类推。 |
请求示例
curl -X get -k -H 'openid: 15cf17442da21b3cce78315b60854a35ea4992204eaa1cde' -i 'https://10.120.66.130:32102/rest/openapi/network/nta/appmgr/appinfo'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
String |
查询得到的信息,json格式。 |
description |
String |
接口调用结果的描述信息。 |
data包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
page_size |
int |
当前页的记录数 |
total_page |
int |
符合查询条件的记录总页数 |
current_page |
int |
当前页,从1开始 |
app_infos |
List<AppInfo> |
应用列表 |
AppInfo包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
appid |
int |
应用索引 |
appname |
String |
应用名称 |
appdesc |
String |
应用描述 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 1659 {"code":0,"data":{"app_infos":[{"appsid":2137,"appsname":"mpls","appsdesc":"MPLS in IP"},{"appsid":2253,"appsname":"test1","appsdesc":"Used for experimentation and testing"},{"appsid":2254,"appsname":"test2","appsdesc":"Used for experimentation and testing"},{"appsid":2255,"appsname":"reserved","appsdesc":"Reserved by IANA"},{"appsid":10000007,"appsname":"echo","appsdesc":"Echo Protocol"},{"appsid":10000009,"appsname":"discard","appsdesc":"Discard Protocol"},{"appsid":10000011,"appsname":"systat","appsdesc":"Active Users Protocol"},{"appsid":10000013,"appsname":"daytime","appsdesc":"Daytime Protocol"},{"appsid":10000017,"appsname":"qotd","appsdesc":"Quote of the Day Protocol"},{"appsid":10000019,"appsname":"chargen","appsdesc":"Character Generator Protocol"},{"appsid":10000020,"appsname":"ftp-data","appsdesc":"File Transfer Protocol (FTP) Data traffic"},{"appsid":10000021,"appsname":"ftp","appsdesc":"File Transfer Protocol (FTP) Control traffic"},{"appsid":10000022,"appsname":"ssh","appsdesc":"Secure Shell (SSH) Remote Login Protocol"},{"appsid":10000023,"appsname":"telnet","appsdesc":"Telnet Protocol"},{"appsid":10000025,"appsname":"smtp","appsdesc":"Simple Mail Transfer Protocol (SMTP)"},{"appsid":10000037,"appsname":"time","appsdesc":"Time Protocol"},{"appsid":10000038,"appsname":"rap","appsdesc":"Route Access Protocol"},{"appsid":10000040,"appsname":"rlp","appsdesc":"Resource Location Protocol"},{"appsid":10000042,"appsname":"nameserver","appsdesc":"Host Name Server"},{"appsid":10000043,"appsname":"nicname","appsdesc":"NICNAME/WHOIS Protocol"}],"total_page":28,"current_page":1,"page_size":20},"description":"Operation success."}
注意事项
不支持并发。
使用示例
import org.apache.http.HttpResponse; import org.apache.http.message.BasicNameValuePair; public class Query { private static final String EAM_TYPE = "/rest/openapi/network/nta/appmgr/appinfo"; public static void main(String[] args) throws Exception { Login.login(); queryTest(); } public static void queryTest() throws Exception { //set the URL and method String openidURL = EAM_TYPE; String method = "GET"; //set headers BasicNameValuePair[] headers = NewRosSecurity.getRosHttpHeader(openidURL, method); //set parameters BasicNameValuePair[] parameters = { new BasicNameValuePair("appid", 2000) }; //send the request HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP, GlobalVar.GLOBAL_PORT, openidURL, method, headers, parameters); //get the result String body = NewHttpsAccess.getResult(response); System.out.println(body); } } 执行结果如下: { "code": 0, "data": { "page_size": 1, "total_page": 1, "current_page": 1, "app_infos": [ { "appname": "hopopt", "appdesc": "IP逐跳选项协议应用", "appid": 2000 } ] }, "description": "Operation success." }
查询运营商基本信息
接口功能
一次返回所有运营商基本信息。
URI路径
/rest/openapi/nta/carrier/basicInfo
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
string |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取。 |
请求示例
curl -X get -k -H 'openid: 15cf17442da21b3cce78315b60854a35ea4992204eaa1cde' -i 'https://10.120.66.130:32102/rest/openapi/nta/carrier/basicInfo'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
List<CarrierData> |
运营商基本信息列表 |
description |
string |
接口调用结果的描述信息 |
CarrierData对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
carrierID |
string |
运营商的唯一标识 |
name |
string |
运营商名称 |
description |
string |
运营商描述 |
ipRangeDataList |
IpRangeData[] |
租用运营商的IP地址列表 |
inBandwidth |
long |
流入方向总带宽,单位Bps(字节/秒) |
outBandwidth |
long |
流出方向总带宽,单位Bps(字节/秒) |
IpRangeData对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
ipRangeID |
string |
运营商的唯一标识 |
type |
int |
类型。
|
startIpAddr |
string |
起始地址/网段地址。 仅IP地址范围有效,其他为空。 |
endIpAddr |
string |
终止地址。 仅IP地址范围有效,其他为空。 |
maskLen |
int |
掩码长度。 仅IP地址范围和网段有效。 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 538 {"code":0,"data":[{"carrierID":"1","name":"CHINA TELECOM","description":"CHINA TELECOM","ipRangeDataList":null,"inBandwidth":0,"outBandwidth":0},{"carrierID":"2","name":"CHINA UNICOM","description":"CHINA UNICOM","ipRangeDataList":null,"inBandwidth":0,"outBandwidth":0},{"carrierID":"3","name":"CHINA MOBILE","description":"CHINA MOBILE","ipRangeDataList":null,"inBandwidth":0,"outBandwidth":0},{"carrierID":"4","name":"BGP","description":"BGP","ipRangeDataList":null,"inBandwidth":0,"outBandwidth":0}],"description":"Operation success."}
注意事项
未定义运营商信息,不报告异常,返回空数据;不支持并发。
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryCarrierInfoDemo { public static String queryCarrierBasicInfo(String ip, int port, Map<String,String> header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://").append(ip).append(":").append(port).append("/rest/openapi/nta/carrier/basicInfo"); String url = sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client = HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In QueryCarrierBasicInfo:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP,Constants.SERVER_PORT, Constants.LOGIN_INFO); Map<String, String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryCarrierBasicInfo(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下:
{ "code": 0, "data": [ { "carrierID": "1", "name": "CHINA TELECOM", "description": "CHINA TELECOM", "ipRangeDataList": [ { "ipRangeID": "7", "type": 2, "startIpAddr": "10.137.62.1", "endIpAddr": "10.137.63.1", "maskLen": 23 }, { "ipRangeID": "8", "type": 3, "startIpAddr": "10.137.61.2", "endIpAddr": null, "maskLen": 24 }, { "ipRangeID": "9", "type": 1, "startIpAddr": "10.137.66.2", "endIpAddr": null, "maskLen": 0 } ], "inBandwidth": 1000, "outBandwidth": 1000 }, { "carrierID": "2", "name": "CHINA UNICOM", "description": "CHINA UNICOM", "ipRangeDataList": [ { "ipRangeID":"10", "type": 3, "startIpAddr": "10.137.61.11", "endIpAddr": null, "maskLen": 23 } ], "inBandwidth": 1000000, "outBandwidth": 1000000 }, { "carrierID": "3", "name": "CHINA MOBILE", "description": "CHINA MOBILE", "ipRangeDataList": [ { "ipRangeID": "11", "type": 1, "startIpAddr": "10.137.61.21", "endIpAddr": null, "maskLen": 0 } ], "inBandwidth": 2000000, "outBandwidth": 2000000 }, { "carrierID": "4", "name": "BGP", "description": "BGP", "ipRangeDataList": null, "inBandwidth": 0, "outBandwidth": 0 } ], "description": "Operation success." }
查询运营商当前流量
接口功能
查询运营商入出方向流量最后一次1分钟统计。
URI路径
/rest/openapi/nta/carrier/last1MinTrafficStat
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
string |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取。 |
请求示例
curl -X get -k -H 'openid: 15cf17442da21b3cce78315b60854a35ea4992204eaa1cde' -i 'https://10.120.66.130:32102/rest/openapi/nta/carrier/last1MinTrafficStat'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
CarrierTrafficStatModel |
运营商当前流量数据。 |
description |
string |
接口调用结果的描述信息 |
CarrierTrafficStatModel对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
carrierTraffic |
List<CarrierTrafficModel> |
各运营商的最近1分钟流量数据 |
summary |
SummaryTrafficData |
流量统计信息 |
CarrierTrafficModel对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
lastCollectTime |
long |
最后一次1分钟流量统计时间点,毫秒单位UTC时间。 |
totalBytes |
long |
1分钟内字节总数,单位Byte。 |
totalPackets |
long |
1分钟内包总数,单位个。 |
totalBandwidthUsage |
float |
1分钟内字节带宽利用率,小数点后保留两位小数,单位%。 |
totalBandwidth |
long |
运营商总带宽,单位Bps(字节/秒)。 |
trafficOrder |
int |
该运营商流量在所有运营商中排序序号(按totalBandwidthUsage排序) |
trafficOrderPercent |
float |
该运营商流量在所有运营商流量中的占比(按totalBytes/Sum(all)计算占比),小数点后保留两位小数,单位%。 |
SummaryTrafficData对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
totalBytes |
long |
1分钟内字节总数,单位Byte。 |
totalPackets |
long |
1分钟内包总数,单位个。 |
totalBandwidthUsage |
float |
1分钟内字节带宽利用率,小数点后保留两位小数,单位%。 |
totalBandwidth |
long |
所有运营商总带宽之和,单位Bps(字节/秒)。 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 732 {"code":0,"data":{"carrierTraffic":[{"carrierID":"4","name":"BGP","inTrafficData":{"lastCollectTime":1534921200000,"totalBytes":97815000000,"totalPackets":87000300000,"totalBandwidthUsage":0.0,"totalBandwidth":0,"trafficOrder":2,"trafficOrderPercent":100.0},"outTrafficData":{"lastCollectTime":1534921200000,"totalBytes":96915000000,"totalPackets":78000300000,"totalBandwidthUsage":0.0,"totalBandwidth":0,"trafficOrder":1,"trafficOrderPercent":100.0}}],"summary":{"inTrafficData":{"totalBytes":97815000000,"totalPackets":87000300000,"totalBandwidthUsage":0.0,"totalBandwidth":0},"outTrafficData":{"totalBytes":96915000000,"totalPackets":78000300000,"totalBandwidthUsage":0.0,"totalBandwidth":0}}},"description":"Operation success."}
注意事项
- 未定义运营商信息,不报告异常,返回空数据,汇总流量也不需要返回数据
- 带宽未定义或者为0,不计算带宽利用率(处理为 0 )
- 运营商不存在,返回空数据
- 不支持并发
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryCarrierTrafficDemo { public static String queryCarrierTraffic(String ip, int port, Map<String, String>header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://") .append(ip) .append(":") .append(port) .append("/rest/openapi/nta/carrier/last1MinTrafficStat"); String url= sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client = HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In queryCarrierTraffic:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP, Constants.SERVER_PORT,Constants.LOGIN_INFO); Map<String, String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryCarrierTraffic(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下:
{ "code": 0, "data": { "carrierTraffic": [ { "carrierID": "3", "name": "CHINA MOBILE", "inTrafficData": { "lastCollectTime": 1445339760000, "totalBytes": 58315000, "totalPackets": 3673000, "totalBandwidthUsage": 48.6, "totalBandwidth": 2000000, "trafficOrder": 4, "trafficOrderPercent": 39.39 }, "outTrafficData": { "lastCollectTime": 1445339760000, "totalBytes": 105507000, "totalPackets": 6391000, "totalBandwidthUsage": 87.92, "totalBandwidth": 2000000, "trafficOrder": 2, "trafficOrderPercent": 38.02 } }, { "carrierID": "2", "name": "CHINA UNICOM", "inTrafficData": null, "outTrafficData": { "lastCollectTime": 1445339760000, "totalBytes": 47026000, "totalPackets": 2336000, "totalBandwidthUsage": 78.38, "totalBandwidth": 1000000, "trafficOrder": 3, "trafficOrderPercent": 16.95 } }, { "carrierID": "1", "name": "CHINA TELECOM", "inTrafficData": null, "outTrafficData": { "lastCollectTime": 1445339760000, "totalBytes": 50380000, "totalPackets": 2974000, "totalBandwidthUsage": 83966.67, "totalBandwidth": 1000, "trafficOrder": 1, "trafficOrderPercent": 18.16 } }, { "carrierID": "4", "name": "BGP", "inTrafficData": { "lastCollectTime": 1445339760000, "totalBytes":89729000, "totalPackets": 6599000, "totalBandwidthUsage": 0, "totalBandwidth": 0, "trafficOrder": 6, "trafficOrderPercent": 60.61 }, "outTrafficData": { "lastCollectTime": 1445339760000, "totalBytes": 74561000, "totalPackets": 5658000, "totalBandwidthUsage": 0, "totalBandwidth": 0, "trafficOrder": 5, "trafficOrderPercent": 26.87 } } ], "summary": { "inTrafficData": { "totalBytes": 148044000, "totalPackets": 10272000, "totalBandwidthUsage": 82.22, "totalBandwidth": 3001000 }, "outTrafficData": { "totalBytes": 277474000, "totalPackets": 17359000, "totalBandwidthUsage": 154.1, "totalBandwidth": 3001000 } } }, "description": "Operation success." }
查询EIP TopN流量
接口功能
设置N值、统计范围、运营商ID、流量方向等查询参数,仅统计所有EIP最后一分钟统计数据。
URI路径
/rest/openapi/nta/eip/last1MinTrafficStat
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
string |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取。 |
topnValue |
必选 |
请求实体参数列表 |
int |
TopN N大小。返回1~100。 |
rangeType |
可选 |
请求实体参数列表 |
int |
统计范围。
|
carrierID |
可选 |
请求实体参数列表 |
string |
指定运营商ID。 说明:
当rangeType=2时生效,必须和rangeType同时提供。 |
deviceIP |
可选 |
请求实体参数列表 |
string |
指定设备IP。 说明:
deviceIP不能和rangeType同时提供。 |
interfaceName |
可选 |
请求实体参数列表 |
string |
eSight 网络流量分析管理的接口名称。 说明:
必须和deviceIP同时提供。 |
trafficDirection |
必选 |
请求实体参数列表 |
int |
流量方向。
|
请求示例
curl -X get -k -H 'openid: a12e0f067fcb8c1f6a7cacb5dd41592eadee4a804be34e7e' -i 'https://10.120.66.130:32102/rest/openapi/nta/eip/last1MinTrafficStat?topnValue=5&trafficDirection=1'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
List<HostEIPTrafficModel> |
EIP流量信息。 |
description |
string |
接口调用结果的描述信息 |
HostEIPTrafficModel对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
eipAddr |
string |
EIP的IP地址 |
carrierID |
string |
EIP所属运营商ID |
carrierName |
string |
EIP所属运营商名称 |
customerID |
string |
EIP所属客户ID |
customerName |
string |
EIP所属客户名称 |
carGroupID |
string |
EIP所属限流组ID |
carGroupName |
string |
EIP所属限流组名称 |
lastCollectTime |
long |
最后一次1分钟流量统计时间点。毫秒单位UTC时间 |
totalBytes |
long |
1分钟内字节总数,单位Byte。 |
totalPackets |
long |
1分钟内包总数,单位个。 |
trafficOrder |
int |
该EIP流量在所有TopN+其他中排序序号(按totalBytes排序) |
trafficOrderPercent |
float |
该EIP流量在所有opN+其他流量中的占比(按totalBytes计算占比),小数点后保留两位小数,单位%。 |
interfaceTraffic |
InterfaceTrafficModel |
返回接口下的流量,当没有提供deviceIP时,该值为空。 |
InterfaceTrafficModel对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
inPackets |
long |
在lastCollectTime这一统计周期下指定接口的所有流入包数 |
outPackets |
long |
在lastCollectTime这一统计周期下指定接口的所有流出包数 |
inTotalBytes |
long |
在lastCollectTime这一统计周期下指定接口的所有流入字节数 |
outTotalBytes |
long |
在lastCollectTime这一统计周期下指定接口的所有流出字节数 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 1804 {"code":0,"data":{"eipTraffic":[{"eipAddr":"192.168.1.4","carrierID":"4","carrierName":"BGP","customerID":"575","customerName":"testDomain4","carGroupID":"4","carGroupName":"testBandwidth4","lastCollectTime":1534937760000,"totalBytes":36000000000,"totalPackets":3600000000,"trafficOrder":1,"trafficOrderPercent":90.9},{"eipAddr":"Other","carrierID":null,"carrierName":null,"customerID":null,"customerName":null,"carGroupID":null,"carGroupName":null,"lastCollectTime":1534937760000,"totalBytes":2406000000,"totalPackets":24000120000,"trafficOrder":2,"trafficOrderPercent":6.07},{"eipAddr":"192.168.1.87","carrierID":"4","carrierName":"BGP","customerID":"763","customerName":"testDomain487","carGroupID":"487","carGroupName":"testBandwidth487","lastCollectTime":1534937760000,"totalBytes":300000000,"totalPackets":3000000000,"trafficOrder":3,"trafficOrderPercent":0.76},{"eipAddr":"192.168.1.190","carrierID":"4","carrierName":"BGP","customerID":"562","customerName":"testDomain190","carGroupID":"190","carGroupName":"testBandwidth190","lastCollectTime":1534937760000,"totalBytes":300000000,"totalPackets":3000000000,"trafficOrder":4,"trafficOrderPercent":0.76},{"eipAddr":"192.168.1.86","carrierID":"4","carrierName":"BGP","customerID":"761","customerName":"testDomain486","carGroupID":"486","carGroupName":"testBandwidth486","lastCollectTime":1534937760000,"totalBytes":300000000,"totalPackets":3000000000,"trafficOrder":5,"trafficOrderPercent":0.76},{"eipAddr":"192.168.1.181","carrierID":"4","carrierName":"BGP","customerID":"553","customerName":"testDomain181","carGroupID":"181","carGroupName":"testBandwidth181","lastCollectTime":1534937760000,"totalBytes":300000000,"totalPackets":3000000000,"trafficOrder":6,"trafficOrderPercent":0.76}],"interfaceTraffic":null},"description":"Operation success."}
注意事项
运营商ID不存在、指定方向流量无1分钟统计数据,直接返回空数据;不支持并发。
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryEIPTopNTrafficDemo { public static String queryEIPTopNTraffic(String ip, int port, Map<String, String>header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://").append(ip).append(":").append(port).append("/rest/openapi/nta/eip/last1MinTrafficStat"); sb.append("?"); sb.append("topnValue=5"); sb.append("&deviceIP=10.137.63.103"); sb.append("&interfaceName=IfIndex_1"); sb.append("&trafficDirection=1"); String url= sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client = HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In QueryEIPTopNTrafficTest:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP, Constants.SERVER_PORT,Constants.LOGIN_INFO); Map<String, String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryEIPTopNTraffic(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下:
{ "code": 0, "data": { "interfaceTraffic": { "inPackets": 946000, "inTotalBytes": 10098000, "outPackets": 582000, "outTotalBytes": 7422000 }, "eipTraffic": [{ "eipAddr": "其他", "carrierID": null, "carrierName": null, "customerID": null, "customerName": null, "carGroupID": null, "carGroupName": null, "lastCollectTime": 1449725700000, "totalBytes": 4065000, "totalPackets": 563000, "trafficOrder": 1, "trafficOrderPercent": 40.26 }, { "eipAddr": "172.16.185.166", "carrierID": "2", "carrierName": "CHINA UNICOM", "customerID": "335", "customerName": "Customer_666", "carGroupID": "5335", "carGroupName": "CarGroup_1666", "lastCollectTime": 1449725700000, "totalBytes": 1477000, "totalPackets": 48000, "trafficOrder": 2, "trafficOrderPercent": 14.63 }, { "eipAddr": "172.16.185.168", "carrierID": "4", "carrierName": "BGP", "customerID": "333", "customerName": "Customer_668", "carGroupID": "5333", "carGroupName": "CarGroup_1668", "lastCollectTime": 1449725700000, "totalBytes": 1302000, "totalPackets": 82000, "trafficOrder": 3, "trafficOrderPercent": 12.89 }, { "eipAddr": "172.16.182.241", "carrierID": "3", "carrierName": "CHINA MOBILE", "customerID": "10", "customerName": "Customer_991", "carGroupID":"6010", "carGroupName": "CarGroup_991", "lastCollectTime": 1449725700000, "totalBytes": 1235000, "totalPackets": 10000, "trafficOrder": 4, "trafficOrderPercent": 12.23 }, { "eipAddr": "172.16.184.221", "carrierID": "3", "carrierName": "CHINA MOBILE", "customerID": "530", "customerName": "Customer_471", "carGroupID": "5530", "carGroupName": "CarGroup_1471", "lastCollectTime": 1449725700000, "totalBytes": 1051000, "totalPackets": 131000, "trafficOrder": 5, "trafficOrderPercent": 10.41 }, { "eipAddr": "172.16.185.163", "carrierID": "3", "carrierName": "CHINA MOBILE", "customerID": "338", "customerName": "Customer_663", "carGroupID": "5338", "carGroupName": "CarGroup_1663", "lastCollectTime": 1449725700000, "totalBytes": 968000, "totalPackets": 112000, "trafficOrder": 6, "trafficOrderPercent": 9.59 }] }, "description": "Operation success." }
查询EIP TopN会话流量
接口功能
设置N值、指定EIP、流量方向等查询参数,仅统计指定EIP最后一分钟会话统计数据。
URI路径
/rest/openapi/nta/eipSession/last1MinTrafficStat
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
string |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取。 |
topnValue |
必选 |
请求实体参数列表 |
int |
TopN N大小。返回1~100。 |
eipAddr |
必选 |
请求实体参数列表 |
string |
指定EIP地址,仅指定一个。 |
trafficDirection |
必选 |
请求实体参数列表 |
int |
流量方向。
|
请求示例
curl -X get -k -H 'openid: 61cc470305e7f473b4fcc2ed9e5a4b673dee59a88226049c' -i 'https://10.120.66.130:32102/rest/openapi/nta/eipSession/last1MinTrafficStat?topnValue=5&trafficDirection=1&eipAddr=192.168.1.4'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
List<EIPSessionModel> |
EIP会话流量信息。 |
description |
string |
接口调用结果的描述信息 |
EIPSessionModel对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
lastCollectTime |
long |
最后一次1分钟流量统计时间点。毫秒单位UTC时间 |
eipDirectionType |
int |
EIP在会话中类型
|
sessionName |
string |
会话名称/其他 |
srcIpAddr |
string |
源地址 |
dstIpAddr |
string |
目的地址 |
srcPort |
int |
源端口 |
dstPort |
int |
目的端口 |
tosValue |
int |
TOS/DSCP值 |
protocolName |
string |
协议名称 |
protocolDesc |
string |
协议描述 |
appName |
string |
应用名称 |
appDesc |
string |
应用描述 |
carrierID |
string |
EIP所属运营商ID |
carrierName |
string |
EIP所属运营商名称 |
customerID |
string |
EIP所属客户ID |
customerName |
string |
EIP所属客户名称 |
carGroupID |
string |
EIP所属限流组ID |
carGroupName |
string |
EIP所属限流组名称 |
totalBytes |
long |
1分钟内字节总数,单位Byte。 |
totalPackets |
long |
1分钟内包总数,单位个。 |
trafficOrder |
int |
该EIP流量在所有TopN+其他中排序序号(按totalBytes排序) |
trafficOrderPercent |
float |
该EIP流量在所有opN+其他流量中的占比(按totalBytes计算占比),小数点后保留两位小数,单位%。 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 976 {"code":0,"data":[{"lastCollectTime":1534922700000,"eipDirectionType":2,"appName":"BT","appDesc":"BT_desc","carrierID":"4","carrierName":"BGP","customerID":"575","customerName":"testDomain4","carGroupID":"74","carGroupName":"testBandwidth74","totalBytes":90000000000,"totalPackets":9000000000,"trafficOrder":1,"trafficOrderPercent":100.0,"sessionName":"192.168.1.2 to 192.168.1.4","srcIpAddr":"192.168.1.2","dstIpAddr":"192.168.1.4","srcPort":80,"dstPort":33584,"tosValue":8,"protocolName":"tcp","protocolDesc":"Transmission Control"},{"lastCollectTime":1534922700000,"eipDirectionType":0,"appName":null,"appDesc":null,"carrierID":null,"carrierName":null,"customerID":null,"customerName":null,"carGroupID":null,"carGroupName":null,"totalBytes":0,"totalPackets":0,"trafficOrder":2,"trafficOrderPercent":0.0,"sessionName":"Other","srcIpAddr":null,"dstIpAddr":null,"srcPort":0,"dstPort":0,"tosValue":0,"protocolName":null,"protocolDesc":null}],"description":"Operation success."}
注意事项
EIP不存在、指定方向流量无1分钟统计数据,不返回异常,直接返回空数据;不支持并发。
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryEIPTopNConvDemo { public static String queryEIPTopNConv(String ip, int port, Map<String, String> header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://") .append(ip) .append(":") .append(port) .append("/rest/openapi/nta/eipSession/last1MinTrafficStat"); sb.append("?"); sb.append("topnValue=3"); sb.append("&eipAddr=172.16.180.76"); sb.append("&trafficDirection=1"); String url= sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client = HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In QueryEIPTopNConvTest:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP, Constants.SERVER_PORT,Constants.LOGIN_INFO); // 将OpenID放入头部 Map<String, String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryEIPTopNConv(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下:
{ "code": 0, "data": [ { "lastCollectTime": 1445345220000, "eipDirectionType": 0, "sessionName": "Other", "srcIpAddr": null, "dstIpAddr": null, "srcPort": 0, "dstPort": 0, "tosValue": 0, "protocolName": null, "protocolDesc": null, "appName": null, "appDesc": null, "carrierID": null, "carrierName": null, "customerID": null, "customerName": null, "carGroupID": null, "carGroupName": null, "totalBytes": 52941000, "totalPackets": 3558000, "trafficOrder": 1, "trafficOrderPercent": 86.1 }, { "lastCollectTime": 1445345220000, "eipDirectionType": 2, "sessionName": "10.26.54.110 to 127.16.180.76", "srcIpAddr": "10.26.54.110", "dstIpAddr": "172.16.180.76", "srcPort": 37, "dstPort": 0, "tosValue": 8, "protocolName": "tcp", "protocolDesc": "传输控制", "appName": "time", "appDesc": "时间协议服务", "carrierID": "3", "carrierName": "CHINA MOBILE", "customerID": "675", "customerName":"Customer_326", "carGroupID": "1675", "carGroupName": "CarGroup_326", "totalBytes": 3115000, "totalPackets": 116000, "trafficOrder": 2, "trafficOrderPercent": 5.07 } // 此处省略其他数据 ], "description": "Operation success." }
查询EIP TopN应用流量
接口功能
设置N值、指定EIP、流量方向等查询参数,仅统计指定EIP最后一分钟应用统计数据。
URI路径
/rest/openapi/nta/eipApp/last1MinTrafficStat
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
string |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取。 |
topnValue |
必选 |
请求实体参数列表 |
int |
TopN N大小。返回1~100。 |
eipAddr |
必选 |
请求实体参数列表 |
string |
指定EIP地址,仅指定一个。 |
trafficDirection |
必选 |
请求实体参数列表 |
int |
流量方向。
|
请求示例
curl -X get -k -H 'openid: f88a25205a54a114e9e56559c24c74022ac2a1e802b7d4cf' -i 'https://10.120.66.130:32102/rest/openapi/nta/eipApp/last1MinTrafficStat?topnValue=5&trafficDirection=1&eipAddr=192.168.1.4'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
List<EIPAppTrafficModel> |
EIP应用流量信息。 |
description |
string |
接口调用结果的描述信息 |
EIPAppTrafficModel对象包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
lastCollectTime |
long |
最后一次1分钟流量统计时间点。毫秒单位UTC时间 |
eipDirectionType |
int |
EIP在会话中类型
|
appName |
string |
应用名称 |
appDesc |
string |
应用描述 |
carrierID |
string |
EIP所属运营商ID |
carrierName |
string |
EIP所属运营商名称 |
customerID |
string |
EIP所属客户ID |
customerName |
string |
EIP所属客户名称 |
carGroupID |
string |
EIP所属限流组ID |
carGroupName |
string |
EIP所属限流组名称 |
totalBytes |
long |
1分钟内字节总数,单位Byte。 |
totalPackets |
long |
1分钟内包总数,单位个。 |
trafficOrder |
int |
该EIP流量在所有TopN+其他中排序序号(按totalBytes排序) |
trafficOrderPercent |
float |
该EIP流量在所有opN+其他流量中的占比(按totalBytes计算占比),小数点后保留两位小数,单位%。 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 976 {"code":0,"data":[{"lastCollectTime":1534922880000,"eipDirectionType":1,"appName":"BT","appDesc":"BT_desc","carrierID":"4","carrierName":"BGP","customerID":"575","customerName":"testDomain4","carGroupID":"74","carGroupName":"testBandwidth74","totalBytes":90000000000,"totalPackets":9000000000,"trafficOrder":1,"trafficOrderPercent":99.67},{"lastCollectTime":1534922880000,"eipDirectionType":1,"appName":"eSight","appDesc":"eSight_desc","carrierID":"4","carrierName":"BGP","customerID":"575","customerName":"testDomain4","carGroupID":"74","carGroupName":"testBandwidth74","totalBytes":300000000,"totalPackets":3000000000,"trafficOrder":2,"trafficOrderPercent":0.33},{"lastCollectTime":1534922880000,"eipDirectionType":0,"appName":"Other","appDesc":null,"carrierID":null,"carrierName":null,"customerID":null,"customerName":null,"carGroupID":null,"carGroupName":null,"totalBytes":0,"totalPackets":0,"trafficOrder":3,"trafficOrderPercent":0.0}],"description":"Operation success."}
注意事项
EIP不存在、指定方向流量无1分钟统计数据,不返回异常,直接返回空数据;不支持并发。
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryEIPTopNConvDemo { public static String queryEIPTopNConv(String ip, int port, Map<String, String> header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://") .append(ip) .append(":") .append(port) .append("/rest/openapi/nta/eipSession/last1MinTrafficStat"); sb.append("?"); sb.append("topnValue=3"); sb.append("&eipAddr=172.16.180.76"); sb.append("&trafficDirection=1"); String url= sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client =HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In QueryEIPTopNConvTest:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP, Constants.SERVER_PORT,Constants.LOGIN_INFO); // 将OpenID放入头部 Map<String,String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryEIPTopNConv(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下:
{ "code": 0, "data": [ { "lastCollectTime": 1445345640000, "eipDirectionType": 0, "appName": "Other", "appDesc": null, "carrierID": null, "carrierName": null, "customerID": null, "customerName": null, "carGroupID": null, "carGroupName": null, "totalBytes": 47701000, "totalPackets": 3162000, "trafficOrder": 1, "trafficOrderPercent": 84.99 }, { "lastCollectTime": 1445345640000, "eipDirectionType": 2, "appName": "time", "appDesc": "时间协议服务", "carrierID": "3", "carrierName": "CHINA MOBILE", "customerID": "675", "customerName": "Customer_326", "carGroupID": "1675", "carGroupName": "CarGroup_326", "totalBytes": 3079000, "totalPackets": 173000, "trafficOrder": 2, "trafficOrderPercent": 5.49 } // 此处省略其他数据 ], "description": "Operation success." }
EIP信息通知接口
接口功能
云数据中心中VPC主动通知EIP信息接口。
URI路径
/rest/openapi/network/nta/eip
访问方法
POST
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取openid。 |
changeType |
必选 |
请求实体参数列表 |
String |
通知消息类型: ADD 新增 DELETE 删除 |
id |
必选 |
请求实体参数列表 |
String |
EIP的ID信息 |
publicIpAddress |
必选 |
请求实体参数列表 |
String |
公网IP地址,合法的IPv4地址 |
createBandwidth |
可选 |
请求实体参数列表 |
boolean |
是否创建带宽 |
billing |
可选 |
请求实体参数列表 |
boolean |
是否有订单 |
type |
必选 |
请求实体参数列表 |
String |
类型,BGP,MOBILE,TELCOM,UNION,双线等 |
privateIpAddress |
必选 |
请求实体参数列表 |
String |
私有IP地址 |
portId |
可选 |
请求实体参数列表 |
String |
端口ID |
status |
可选 |
请求实体参数列表 |
String |
状态:ACTIVE,DOWN,ERROE |
profile |
可选 |
请求实体参数列表 |
Dictionary |
公网IP扩展字段 |
tenantId |
必选 |
请求实体参数列表 |
String |
EIP对应的租户Id |
createTime |
可选 |
请求实体参数列表 |
String |
EIP创建的时间 |
bandwidthId |
必选 |
请求实体参数列表 |
String |
EIP对应的带宽Id |
bandwidthType |
可选 |
请求实体参数列表 |
String |
带宽类型 |
bandwidthNum |
可选 |
请求实体参数列表 |
Int |
带宽大小 |
name |
可选 |
请求实体参数列表 |
String |
带宽名称 |
size |
可选 |
请求实体参数列表 |
String |
字符串表示的带宽大小 |
shareType |
可选 |
请求实体参数列表 |
String |
带宽共享类型 |
userId |
可选 |
请求实体参数列表 |
String |
用户Id |
orderId |
可选 |
请求实体参数列表 |
String |
订单Id |
productId |
可选 |
请求实体参数列表 |
String |
产品Id |
regionId |
可选 |
请求实体参数列表 |
String |
区域ID |
请求示例
curl -i -k -H 'Accept:application/json' -H 'Content-Type:application/json;charset=utf8' -H 'openid: fc18c7cd4cc0d5a262ce8049d78daedb6570990c1a472e53' -X post -d'{"vpcrestdata": {"changeType":"ADD","id":"tt123","publicIpAddress":"10.10.10.10","type":"BGP","privateIpAddress":"10.10.10.11","tenantId":"testTent","bandwidthId":"bandwidthId002"}}' https://10.120.66.130:32102/rest/openapi/network/nta/eip
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
Int |
操作返回码。可以是如下值之一:
|
data |
List |
此处为null。 |
description |
String |
接口调用结果的描述信息。 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 57 {"code":0,"data":null,"description":"Operation success."}
注意事项
该接口仅在云数据中心中使用,VPC在EIP信息发生变更时调用;不支持并发。
使用示例
import org.apache.http.HttpResponse; import org.apache.http.message.BasicNameValuePair; import com.huawei.oms.ros.test.GlobalVar; import com.huawei.oms.ros.test.Login; import com.huawei.oms.ros.test.NewHttpsAccess; import com.huawei.oms.ros.test.NewRosSecurity; public class NotifyEIPInfo { private static final String NTA_EIP = "/rest/openapi/network/nta/eip"; public static void main(final String[] args) throws Exception { Login.login(); NotifyEIPfromVPC(); } public static void NotifyEIPfromVPC() throws Exception { //set the URL and method final String openidURL = NTA_EIP; final String method = "POST"; //set headers final BasicNameValuePair[] headers = NewRosSecurity.getRosHttpHeader(openidURL, method); // eip json data final String jsonStr = "{\"changeType\":\"ADD\",\"id\":\"123\",\"publicIpAddress\":\"10.135.18.22\",\"type\":\"bgp\",\"privateIpAddress\":\"192.168.18.223\",\"tenantId\":\"testTent\",\"bandwidthId\":\"testBandwidth\"}"; //set parameters final BasicNameValuePair[] parameters = {new BasicNameValuePair("vpcrestdata", jsonStr)}; //send the request final HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP, GlobalVar.GLOBAL_PORT, openidURL, method, headers, parameters); //get the result final String body = NewHttpsAccess.getResult(response); System.out.println(body); } }
执行结果如下:
{ https://10.137.59.61:32102/rest/openapi/network/nta/eip {"code":0,"data":null,"description":"Operation success."} }
限速组信息通知接口
接口功能
云数据中心中VPC主动通知限速组信息接口。
URI路径
/rest/openapi/network/nta/cargroup
访问方法
POST
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求消息头 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用登录接口获取openid。 |
changeType |
必选 |
请求实体参数列表 |
String |
通知消息类型: ADD: 新增 UPDATE :变更 DELETE: 删除 |
id |
必选 |
请求实体参数列表 |
String |
带宽ID |
name |
必选 |
请求实体参数列表 |
String |
带宽名称(限速组名称) |
size |
必选 |
请求实体参数列表 |
int |
带宽大小:单位MB |
bandwidthType |
必选 |
请求实体参数列表 |
String |
带宽类型: telecom、unicom、double、bgp |
shareType |
可选 |
请求实体参数列表 |
String |
带宽共享类型: PER—非共享;WHOLE—共享 |
publicIpIds |
可选 |
请求实体参数列表 |
List[Dictionary] |
带宽关联的公网IP相关属性 |
billingInfo |
可选 |
请求实体参数列表 |
String |
订单计费相关属性(EP字段) |
tenantId |
必选 |
请求实体参数列表 |
String |
带宽所对应的租户Id |
请求示例
curl -i -k -H 'Accept:application/json' -H 'Content-Type:application/json;charset=utf8' -H 'openid: e296f52a3fda3e18d9dcde5a17898671e2958c8fbeb3675e' -X post -d'{"vpcrestdata": {"changeType":"ADD","id":"456","name":"cargroup1","size":"12","bandwidthType":"bgp","tenantId":"Testuser"}}' https://10.120.66.130:32102/rest/openapi/network/nta/cargroup
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
Int |
操作返回码。可以是如下值之一:
|
data |
List |
此处为null。 |
description |
String |
接口调用结果的描述信息。 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 57 {"code":0,"data":null,"description":"Operation success."}
注意事项
该接口仅在云数据中心中使用,VPC在限速组信息发生变更时调用;不支持并发。
使用示例
import org.apache.http.HttpResponse; import org.apache.http.message.BasicNameValuePair; import com.huawei.oms.ros.test.GlobalVar; import com.huawei.oms.ros.test.Login; import com.huawei.oms.ros.test.NewHttpsAccess; import com.huawei.oms.ros.test.NewRosSecurity; public class NotifyCarGroupInfo { private static final String NTA_CARGP = "/rest/openapi/network/nta/cargroup"; public static void main(final String[] args) throws Exception { Login.login(); NotifyCarGroupfromVPC(); } public static void NotifyCarGroupfromVPC() throws Exception { //set the URL and method final String openidURL = NTA_CARGP; final String method = "POST"; //set headers final BasicNameValuePair[] headers = NewRosSecurity.getRosHttpHeader(openidURL, method); // eip json data final String jsonStr = "{\"changeType\":\"ADD\",\"id\":\"456\",\"name\":\"cargroup1\",\"size\":\"12\",\"bandwidthType\":\"bgp\",\"tenantId\":\"Testuser\"}"; //set parameters final BasicNameValuePair[] parameters = {new BasicNameValuePair("vpcrestdata", jsonStr)}; //send the request final HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP, GlobalVar.GLOBAL_PORT, openidURL, method, headers, parameters); //get the result final String body = NewHttpsAccess.getResult(response); System.out.println(body); } }
执行结果如下:
{ https://10.137.59.61:32102/rest/openapi/network/nta/cargroup {"code":0,"data":null,"description":"Operation success."} }
查询WLAN TopN应用客户端数目信息
接口功能
查询WLAN TopN应用客户端数目信息。
URI路径
/rest/openapi/nta/wlan/top10AppByClientCount
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求头参数列表 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用安全管理登录接口获取openid。 |
deviceid |
可选 |
请求实体参数列表 |
String |
设备ID,网流子系统的设备标识。该参数就是查询设备信息返回的deviceid |
topnValue |
必选 |
请求实体参数列表 |
String |
1到10 |
beginTime |
必选 |
请求实体参数列表 |
long |
开始时间(UTC时间,精确到毫秒) |
endTime |
必选 |
请求实体参数列表 |
long |
结束时间(UTC时间,精确到毫秒) |
trafficDirection |
必选 |
请求实体参数列表 |
String |
必选参数,(上行0、下行1,上行或下行2) |
请求示例
curl -X get -k -H 'openid: e296f52a3fda3e18d9dcde5a17898671e2958c8fbeb3675e' -i 'https://10.120.66.130:32102/rest/openapi/nta/wlan/top10AppByClientCount?topnValue=5&trafficDirection=0&beginTime=1531816200001&endTime=1531816250000'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
String |
查询得到的信息,json格式。 |
description |
String |
接口调用结果的描述信息。 |
data包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
page_size |
int |
当前页的记录数 |
total_page |
int |
符合查询条件的记录总页数 |
current_page |
int |
当前页,从1开始 |
app_infos |
List<AppInfo> |
应用列表 |
AppInfo包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
clientnum |
int |
客户端数目 |
appid |
int |
应用索引 |
appname |
String |
应用名称 |
appdesc |
String |
应用描述 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 526 {"code":0,"data":{"app_infos":[{"clientnum":603,"appsid":10001812,"appsname":"radius","appsdesc":"Remote Authentication Dial In User Service (RADIUS)"},{"clientnum":526,"appsid":10001813,"appsname":"radius","appsdesc":"RADIUS Accounting"},{"clientnum":456,"appsid":10001814,"appsname":null,"appsdesc":null},{"clientnum":399,"appsid":10001815,"appsname":null,"appsdesc":null},{"clientnum":333,"appsid":10001816,"appsname":null,"appsdesc":null}],"total_page":1,"current_page":1,"page_size":5},"description":"Operation success."}
注意事项
不支持并发;只支持查询一年的数据。
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryEIPTopNTrafficDemo { public static String queryEIPTopNTraffic(String ip, int port, Map<String, String>header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://").append(ip).append(":").append(port).append("/rest/openapi/nta/wlan/top10AppByClientCount"); sb.append("?"); sb.append("topnValue=10"); sb.append("&deviceid=1"); sb.append("&beginTime=1531816200000"); sb.append("&endTime=1531847700000"); sb.append("&trafficDirection=0"); String url= sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client = HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In QueryEIPTopNTrafficTest:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP, Constants.SERVER_PORT,Constants.LOGIN_INFO); Map<String, String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryEIPTopNTraffic(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下: { "code": 0, "data": { "app_infos": [ { "clientnum": 2, "appid": 70000069, "appname": "BT", "appdesc": "" }, { "clientnum": 1, "appid": 70000042, "appname": "qqdownload", "appdesc": "A download manager and BitTorrent client" }, { "clientnum": 1, "appid": 70000062, "appname": "uusee", "appdesc": "A piece of IPTV software" }, { "clientnum": 1, "appid": 70000070, "appname": "BaiBao", "appdesc": "" }, { "clientnum": 1, "appid": 70000072, "appname": "POCO", "appdesc": "" }, { "clientnum": 1, "appid": 70000073, "appname": "Fring_VoIP", "appdesc": "" }, { "clientnum": 1, "appid": 70000074, "appname": "KuGoo", "appdesc": "" }, { "clientnum": 1, "appid": 70000075, "appname": "PPGou", "appdesc": "" }, { "clientnum": 1, "appid": 70000076, "appname": "TVAnts", "appdesc": "" }, { "clientnum": 1, "appid": 70000077, "appname": "Soulseek", "appdesc": "" } ], "total_page": 1, "current_page": 1, "page_size": 10 }, "description": "Operation success." }
查询WLAN TopN应用流量信息
接口功能
查询WLAN TopN应用流量信息。
URI路径
/rest/openapi/nta/wlan/top10AppByTraffic
访问方法
GET
参数说明
参数名 |
必选/可选 |
参数位置 |
参数类型 |
参数说明 |
---|---|---|---|---|
openid |
必选 |
请求头参数列表 |
String |
会话标识,用于Open API的鉴权。 说明:
该参数由第三方调用安全管理登录接口获取openid。 |
topnValue |
必选 |
请求实体参数列表 |
String |
1到10 |
beginTime |
必选 |
请求实体参数列表 |
long |
开始时间(UTC时间,精确到毫秒) |
endTime |
必选 |
请求实体参数列表 |
long |
结束时间(UTC时间,精确到毫秒) |
trafficDirection |
必选 |
请求实体参数列表 |
String |
必选参数,(上行0、下行1,上行或下行2) |
请求示例
curl -X get -k -H 'openid: e296f52a3fda3e18d9dcde5a17898671e2958c8fbeb3675e' -i 'https://10.120.66.130:32102/rest/openapi/nta/wlan/top10AppByTraffic?topnValue=5&trafficDirection=0&beginTime=1534937940000&endTime=1534938180000'
返回结果
字段名 |
类型 |
说明 |
---|---|---|
code |
int |
操作返回码。可以是如下值之一:
|
data |
List<AppTrafficData> |
查询得到的信息,json格式。 |
description |
String |
接口调用结果的描述信息。 |
AppTrafficData包含以下字段:
字段名 |
类型 |
说明 |
---|---|---|
appName |
String |
应用名称 |
appDesc |
String |
应用描述 |
totalBytes |
long |
指定范围内的总字节数,单位:Btyes |
totalPackets |
long |
指定范围内的总字节数,单位:个 |
响应示例
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 516 {"code":0,"data":[{"appName":"Fring_VoIP","appDesc":null,"totalBytes":14002000,"totalPackets":2800400},{"appName":"PPGou","appDesc":null,"totalBytes":13000000,"totalPackets":2600000},{"appName":"BaiBao","appDesc":null,"totalBytes":12001000,"totalPackets":2400200},{"appName":"DirectConnect","appDesc":null,"totalBytes":11001000,"totalPackets":2200200},{"appName":"ppstream","appDesc":"A piece of P2P streaming video network software","totalBytes":11001000,"totalPackets":2200200}],"description":"Operation success."}
注意事项
不支持并发;不支持查询时间跨度超过一年的数据。
使用示例
package com.huawei.esight.openapi.demo.rest; import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; import com.huawei.esight.openapi.demo.client.HttpClientUtil; import com.huawei.esight.openapi.demo.client.HttpMethod; import com.huawei.esight.openapi.demo.client.ParseResponse; public class QueryTopNAppTrafficDemo { public static String queryTopNAppTraffic(String ip, int port, Map<String, String>header) throws Exception { StringBuffer sb = new StringBuffer(); sb.append("https://").append(ip).append(":").append(port).append("/rest/openapi/nta/wlan/top10AppByTraffic"); sb.append("?"); sb.append("topnValue=10"); sb.append("&beginTime=1531816200000"); sb.append("&endTime=1531847700000"); sb.append("&trafficDirection=0"); String url= sb.toString(); HttpRequestBase request = HttpClientUtil.createHttpRequest(url,HttpMethod.GET, null, header); HttpClient client = HttpClientUtil.getHttpClient(port); HttpResponse response = client.execute(request); Map<String, String> result =ParseResponse.parseResponse(response); System.out.println("In queryTopNAppTraffic:" + result); return result.get("data"); } public static void main(String[] args) throws Exception { String openId = GetOpenIdDemo.getOpenId(Constants.SERVER_IP, Constants.SERVER_PORT,Constants.LOGIN_INFO); Map<String, String> header = new HashMap<String, String>(); header.put("openid", openId); System.out.println(queryTopNAppTraffic(Constants.SERVER_IP,Constants.SERVER_PORT, header)); } }
执行结果如下: { "code": 0, "data": [ { "appName": "POCO", "appDesc": "", "totalBytes": 18000000, "totalPackets": 3600000 }, { "appName": "ppstream", "appDesc": "免费的P2P网络视频软件", "totalBytes": 18000000, "totalPackets": 3600000 }, { "appName": "PPGou", "appDesc": "", "totalBytes": 16000000, "totalPackets": 3200000 }, { "appName": "Fring_VoIP", "appDesc": "", "totalBytes": 14000000, "totalPackets": 2800000 }, { "appName": "KuGoo", "appDesc": "", "totalBytes": 14000000, "totalPackets": 2800000 }, { "appName": "BaiBao", "appDesc": "", "totalBytes": 12000000, "totalPackets": 2400000 }, { "appName": "DirectConnect", "appDesc": "", "totalBytes": 6000000, "totalPackets": 1200000 } ], "description": "Operation success." }