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

管道管理

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

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

搜索管道

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

  1. $region = '<region>';
  2. $accessKeyId = '<accessKeyId>';
  3. $accessKeySecret = '<accessKeySecret>';
  4. $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret);
  5. $client = new DefaultAcsClient($profile);
  6. $request = new Mts\SearchPipelineRequest();
  7. // 如果出错,可能会抛出ClientException或ServerException异常
  8. $response = $client->getAcsResponse($request);
  9. $pipelines = $response->PipelineList->Pipeline;
  10. foreach ($pipelines as $pipeline) {
  11. echo 'pipeline id:' . $pipeline->Id . ', name:' . $pipeline->Name . ', state:' . $pipeline->State . "\n";
  12. }

查询管道

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

  1. $region = '<region>';
  2. $accessKeyId = '<accessKeyId>';
  3. $accessKeySecret = '<accessKeySecret>';
  4. // 已知的管道ID,多个管道用','分隔
  5. $pipelineIds = '<pipelineIds>';
  6. $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret);
  7. $client = new DefaultAcsClient($profile);
  8. $request = new Mts\QueryPipelineListRequest();
  9. $request->setPipelineIds($pipelineIds);
  10. // 如果出错,可能会抛出ClientException或ServerException异常
  11. $response = $client->getAcsResponse($request);
  12. $pipelines = $response->PipelineList->Pipeline;
  13. foreach ($pipelines as $pipeline) {
  14. echo 'pipeline id:' . $pipeline->Id . ', name:' . $pipeline->Name . ', state:' . $pipeline->State . "\n";
  15. }

更新管道

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

  1. $region = '<region>';
  2. $accessKeyId = '<accessKeyId>';
  3. $accessKeySecret = '<accessKeySecret>';
  4. $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret);
  5. $client = new DefaultAcsClient($profile);
  6. $request = new Mts\SearchPipelineRequest();
  7. // 如果出错,可能会抛出ClientException或ServerException异常
  8. $response = $client->getAcsResponse($request);
  9. $pipelines = $response->PipelineList->Pipeline;
  10. $pipeline = $pipelines[0];
  11. $request = new Mts\UpdatePipelineRequest();
  12. $request->setPipelineId($pipeline->Id);
  13. $request->setName($pipeline->Name);
  14. $request->setState($pipeline->State == 'Paused' ? 'Active' : 'Paused');
  15. $response = $client->getAcsResponse($request);
  16. $pipeline = $response->Pipeline;
  17. echo 'pipeline id:' . $pipeline->Id . ', name:' . $pipeline->Name . ', state:' . $pipeline->State . "\n";
本文导读目录