Interface
ListEventsRequest
Description
Indicates whether an Alibaba cloud service is healthy within a specified period in a region.
Request parameters
First name | Type | Meaning |
---|---|---|
regionId | String | The region ID, such as cn-shenzhen. |
productId | String | Product codes such as oss, ecs |
endDate | String | The end of the query time, for example, 2020-01-09 |
numOfDay | Integer | A few days before the deadline, such as 7 |
The ID of the unregionalized service is set to oo-region.
Response parameters
First name | Type | Meaning |
---|---|---|
Code | Integer | 200 indicates success, while the rest indicates failure. |
Data | Array | Event List of the product in this region |
startTime | Long | The start timestamp of the query. Unit: milliseconds. |
endTime | Long | The end timestamp of the query. Unit: milliseconds. If the query does not end, this parameter is null. |
Title | String | Status title |
currentStateSeverity | String | The status of the event. Valid values: ALARM, NOTIFICATION, and NORMAL. |
Sample requests
Dependency
<dependencies>
<dependency>
<groupId>com.aliyun
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>com.aliyun
<artifactId>aliyun-java-sdk-status</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
Code
import com.aliyuncs.DefaultAcsClient
import com.aliyuncs.IAcsClient
import com.aliyuncs.exceptions.ClientException
import com.aliyuncs.profile.DefaultProfile
import com.aliyuncs.status.model.v20200117.ListEventsRequest
import com.aliyuncs.status.model.v20200117.ListEventsResponse
import java.util.List
public class TestSdk {
public static void main (String[] args){
DefaultProfile profile = DefaultProfile.getProfile("","ak", "sk");
IAcsClient client = new DefaultAcsClient(profile);
ListEventsRequest request = new ListEventsRequest()
// Fixed. Write it properly
request.setEndpoint("status.aliyuncs.com");
// 4 parameters
request.setProductId("ecs");
request.setRegionId("cn-hangzhou");
request.setEndDate("2020-02-15");
request.setNumOfDay(6);
try {
ListEventsResponse response = client.getAcsResponse(request);
Integer code = response.getCode()
System.out.println(code);
System.out.println(response.getRequestId());
if (200==code){
List<ListEventsResponse.DataItem> dataItemList = response.getData();
// Traverse each event.
for (ListEventsResponse.DataItem dataItem : dataItemList) {
System.out.println(dataItem.getTitle());
System.out.println(dataItem.getCurrentStateSeverity());
System.out.println(dataItem.getSartTime());
System.out.println(dataItem.getEndTime());
}
}
} catch (ClientException e) {
System.out.println("ErrCode:" + e.getErrCode());
System.out.println("ErrMsg:" + e.getErrMsg());
System.out.println("RequestId:" + e.getRequestId());
}
}
}
Sample responses
200
C58EBAC5-3685-4B68-B162-253B4B3028F8
Test
ALARM
1581317483000
Null