全部产品
存储与CDN 数据库 安全 应用服务 数加·人工智能 数加·大数据基础服务 互联网中间件 视频服务 开发者工具 解决方案 物联网
媒体转码

管道管理

更新时间:2017-06-30 18:26:05

用户管道会在开通服务时自动创建一个。用户还可以通过一系列接口管理管道(pipeline),比如SearchPipeline,QueryPipelineList,UpdatePipeline。

搜索管道

可以直接通过SearchPipeline接口搜索管道信息。

  1. String region = "<region>";
  2. String accessKeyId = "<accessKeyId>";
  3. String accessKeySecret = "<accessKeySecret>";
  4. DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
  5. DefaultAcsClient client = new DefaultAcsClient(profile);
  6. SearchPipelineRequest request = new SearchPipelineRequest();
  7. // 如果出错,可能会抛出ClientException或ServerException异常
  8. SearchPipelineResponse response = client.getAcsResponse(request);
  9. List<SearchPipelineResponse.Pipeline> pipelines = response.getPipelineList();
  10. for (SearchPipelineResponse.Pipeline pipeline : pipelines) {
  11. System.out.println("pipeline id:" + pipeline.getId() + ", name:" + pipeline.getName() + ", state:" + pipeline.getState());
  12. }

查询管道

如果已经知道pipelineId,可以通过pipelineId调用QueryPipelineList接口查询管道信息。

  1. String region = "<region>";
  2. String accessKeyId = "<accessKeyId>";
  3. String accessKeySecret = "<accessKeySecret>";
  4. // 已知的管道ID,多个管道用','分隔
  5. String pipelineIds = "<pipelineIds>";
  6. DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
  7. DefaultAcsClient client = new DefaultAcsClient(profile);
  8. QueryPipelineListRequest request = new QueryPipelineListRequest();
  9. request.setPipelineIds(pipelineId);
  10. // 如果出错,可能会抛出ClientException或ServerException异常
  11. QueryPipelineListResponse response = client.getAcsResponse(request);
  12. List<QueryPipelineListResponse.Pipeline> pipelines = response.getPipelineList();
  13. for (QueryPipelineListResponse.Pipeline pipeline : pipelines) {
  14. System.out.println("pipeline id:" + pipeline.getId() + ", name:" + pipeline.getName() + ", state:" + pipeline.getState());
  15. }

更新管道

通过UpdatePipeline更新管道信息,包括更新管道名称,状态。管道的状态包括Active、Paused

  1. String region = "<region>";
  2. String accessKeyId = "<accessKeyId>";
  3. String accessKeySecret = "<accessKeySecret>";
  4. DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
  5. DefaultAcsClient client = new DefaultAcsClient(profile);
  6. // 检索用户管道,默认只有一个。
  7. SearchPipelineRequest searchPipelineRequest = new SearchPipelineRequest();
  8. // 如果出错,可能会抛出ClientException或ServerException异常
  9. SearchPipelineResponse searchPipelineResponse = client.getAcsResponse(searchPipelineRequest);
  10. List<SearchPipelineResponse.Pipeline> pipelines = searchPipelineResponse.getPipelineList();
  11. SearchPipelineResponse.Pipeline queryPipeline = pipelines.get(0);
  12. // 更新管道状态
  13. UpdatePipelineRequest request = new UpdatePipelineRequest();
  14. request.setPipelineId(queryPipeline.getId());
  15. request.setState("Paused");
  16. request.setName(queryPipeline.getName());
  17. // 如果出错,会抛ClientException异常
  18. UpdatePipelineResponse response = client.getAcsResponse(request);
  19. UpdatePipelineResponse.Pipeline pipeline = response.getPipeline();
  20. System.out.println("pipeline id:" + pipeline.getId() + ", name:" + pipeline.getName() + ", state:" + pipeline.getState());
本文导读目录