在开通服务时,系统会自动创建一个用户管道。您还可以通过一系列接口管理管道(pipeline)。例如:SearchPipelineQueryPipelineListUpdatePipeline

搜索管道

可以直接通过 SearchPipeline接口搜索管道信息。
String region = "<region>";
    String accessKeyId = "<accessKeyId>";
    String accessKeySecret = "<accessKeySecret>";
    DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
    DefaultAcsClient client = new DefaultAcsClient(profile);
    SearchPipelineRequest request = new SearchPipelineRequest();
    // 如果出错,可能会抛出ClientException或ServerException异常
    SearchPipelineResponse response = client.getAcsResponse(request);
    List<SearchPipelineResponse.Pipeline> pipelines = response.getPipelineList();
    for (SearchPipelineResponse.Pipeline pipeline : pipelines) {
        System.out.println("pipeline id:" + pipeline.getId() + ", name:" + pipeline.getName() + ", state:" + pipeline.getState());
    }

查询管道

如果已经知道pipelineId,可以通过pipelineId调用 QueryPipelineList接口查询管道信息。
String region = "<region>";
    String accessKeyId = "<accessKeyId>";
    String accessKeySecret = "<accessKeySecret>";
    // 已知的管道ID,多个管道用','分隔
    String pipelineIds = "<pipelineIds>";
    DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
    DefaultAcsClient client = new DefaultAcsClient(profile);
    QueryPipelineListRequest request = new QueryPipelineListRequest();
    request.setPipelineIds(pipelineId);
    // 如果出错,可能会抛出ClientException或ServerException异常
    QueryPipelineListResponse response = client.getAcsResponse(request);
    List<QueryPipelineListResponse.Pipeline> pipelines = response.getPipelineList();
    for (QueryPipelineListResponse.Pipeline pipeline : pipelines) {
        System.out.println("pipeline id:" + pipeline.getId() + ", name:" + pipeline.getName() + ", state:" + pipeline.getState());
    }

更新管道

通过 UpdatePipeline更新管道信息,包括更新管道名称,状态。管道的状态包括Active、Paused。
String region = "<region>";
    String accessKeyId = "<accessKeyId>";
    String accessKeySecret = "<accessKeySecret>";
    DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
    DefaultAcsClient client = new DefaultAcsClient(profile);
    // 检索用户管道,默认只有一个。
    SearchPipelineRequest searchPipelineRequest = new SearchPipelineRequest();
    // 如果出错,可能会抛出ClientException或ServerException异常
    SearchPipelineResponse searchPipelineResponse = client.getAcsResponse(searchPipelineRequest);
    List<SearchPipelineResponse.Pipeline> pipelines = searchPipelineResponse.getPipelineList();
    SearchPipelineResponse.Pipeline queryPipeline = pipelines.get(0);
    // 更新管道状态
    UpdatePipelineRequest request = new UpdatePipelineRequest();
    request.setPipelineId(queryPipeline.getId());
    request.setState("Paused");
    request.setName(queryPipeline.getName());
    // 如果出错,会抛ClientException异常
    UpdatePipelineResponse response = client.getAcsResponse(request);
    UpdatePipelineResponse.Pipeline pipeline = response.getPipeline();
    System.out.println("pipeline id:" + pipeline.getId() + ", name:" + pipeline.getName() + ", state:" + pipeline.getState());