全部产品
媒体转码

管道管理

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

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

搜索管道

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

  1. import json
  2. from aliyunsdkmts.request.v20140618 import SearchPipelineRequest
  3. from aliyunsdkcore import client
  4. region = '<region>'
  5. access_key_id = '<access_key_id>'
  6. access_key_secret = '<access_key_secret>'
  7. client = client.AcsClient(access_key_id, access_key_secret, region)
  8. request = SearchPipelineRequest.SearchPipelineRequest()
  9. response = client.do_action_with_exception(request);
  10. json_response = json.loads(response)
  11. pipelines = json_response['PipelineList']['Pipeline']
  12. for pipeline in pipelines:
  13. print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']

查询管道

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

  1. import json
  2. from aliyunsdkmts.request.v20140618 import QueryPipelineListRequest
  3. from aliyunsdkcore import client
  4. region = '<region>'
  5. access_key_id = '<access_key_id>'
  6. access_key_secret = '<access_key_secret>'
  7. pipeline_id = '<pipeline_id>'
  8. client = client.AcsClient(access_key_id, access_key_secret, region)
  9. request = QueryPipelineListRequest.QueryPipelineListRequest()
  10. request.set_PipelineIds(pipeline_id)
  11. response = client.do_action_with_exception(request);
  12. json_response = json.loads(response)
  13. pipelines = json_response['PipelineList']['Pipeline']
  14. for pipeline in pipelines:
  15. print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']

更新管道

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

  1. import json
  2. from aliyunsdkmts.request.v20140618 import SearchPipelineRequest
  3. from aliyunsdkmts.request.v20140618 import UpdatePipelineRequest
  4. from aliyunsdkcore import client
  5. region = '<region>'
  6. access_key_id = '<access_key_id>'
  7. access_key_secret = '<access_key_secret>'
  8. client = client.AcsClient(access_key_id, access_key_secret, region)
  9. request = SearchPipelineRequest.SearchPipelineRequest()
  10. response = client.do_action_with_exception(request);
  11. json_response = json.loads(response)
  12. pipeline = json_response['PipelineList']['Pipeline'][0]
  13. request = UpdatePipelineRequest.UpdatePipelineRequest()
  14. request.set_PipelineId(pipeline['Id'])
  15. request.set_Name(pipeline['Name'])
  16. request.set_State('Paused' if pipeline['State'] == 'Active' else 'Active')
  17. response = client.do_action_with_exception(request);
  18. json_response = json.loads(response)
  19. pipeline = json_response['Pipeline']
  20. print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']
本文导读目录
本文导读目录
以上内容是否对您有帮助?