Calls ListDataPipelineConfigurations through OSS Java SDK V2 to list all data pipeline (DataPipeline) rules of the current account in a specified region.
Prerequisites
OSS Java SDK V2 is installed. If you use Maven, add the
com.aliyun:alibabacloud-oss-v2dependency to your pom.xml.Access credentials are configured by using environment variables. The example in this topic uses
EnvironmentVariableCredentialsProviderto read credentials from theOSS_ACCESS_KEY_IDandOSS_ACCESS_KEY_SECRETenvironment variables.DataPipeline operations are forwarded by OSS to the underlying workflow service. Make sure that the source standard bucket and the destination vector bucket are located in the same region.
Sample code
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.dataprocess.OSSDataProcessClient;
import com.aliyun.sdk.service.oss2.dataprocess.models.*;
public class ListDataPipelineConfigurationsSample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSDataProcessClient client = OSSDataProcessClient.newBuilder()
.region("cn-hangzhou")
.credentialsProvider(provider)
.build()) {
String nextToken = null;
do {
ListDataPipelineConfigurationsRequest.Builder reqBuilder =
ListDataPipelineConfigurationsRequest.newBuilder().maxResults(100);
if (nextToken != null) {
reqBuilder.nextToken(nextToken);
}
ListDataPipelineConfigurationsResult result =
client.listDataPipelineConfigurations(reqBuilder.build());
System.out.printf("Status code:%d, request id:%s%n",
result.statusCode(), result.requestId());
if (result.dataPipelineConfigurations() != null) {
for (DataPipelineConfiguration cfg : result.dataPipelineConfigurations()) {
System.out.printf("Pipeline: name=%s, status=%s, createTime=%s%n",
cfg.dataPipelineName(), cfg.status(), cfg.createTime());
}
}
nextToken = result.nextToken();
} while (nextToken != null && !nextToken.isEmpty());
} catch (Exception e) {
System.out.printf("error:%n%s", e);
}
}
}References
For the synchronous sample code, see ListDataPipelineConfigurations.java.
For the asynchronous sample code, see ListDataPipelineConfigurationsAsync.java.