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

搜索管道

可以直接通过 SearchPipeline接口搜索管道信息。
import json
    from aliyunsdkmts.request.v20140618 import SearchPipelineRequest
    from aliyunsdkcore import client
    region = '<region>'
    access_key_id = '<access_key_id>'
    access_key_secret = '<access_key_secret>'
    client = client.AcsClient(access_key_id, access_key_secret, region)
    request = SearchPipelineRequest.SearchPipelineRequest()
    response = client.do_action_with_exception(request);
    json_response = json.loads(response)
    pipelines = json_response['PipelineList']['Pipeline']
    for pipeline in pipelines:
        print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']

查询管道

如果已经知道pipelineId,可以通过pipelineId调用 QueryPipelineList接口查询管道信息。
import json
    from aliyunsdkmts.request.v20140618 import QueryPipelineListRequest
    from aliyunsdkcore import client
    region = '<region>'
    access_key_id = '<access_key_id>'
    access_key_secret = '<access_key_secret>'
    pipeline_id = '<pipeline_id>'
    client = client.AcsClient(access_key_id, access_key_secret, region)
    request = QueryPipelineListRequest.QueryPipelineListRequest()
    request.set_PipelineIds(pipeline_id)
    response = client.do_action_with_exception(request);
    json_response = json.loads(response)
    pipelines = json_response['PipelineList']['Pipeline']
    for pipeline in pipelines:
        print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']

更新管道

通过 UpdatePipeline更新管道信息,包括更新管道名称,状态。管道的状态包括Active、Paused。
import json
    from aliyunsdkmts.request.v20140618 import SearchPipelineRequest
    from aliyunsdkmts.request.v20140618 import UpdatePipelineRequest
    from aliyunsdkcore import client
    region = '<region>'
    access_key_id = '<access_key_id>'
    access_key_secret = '<access_key_secret>'
    client = client.AcsClient(access_key_id, access_key_secret, region)
    request = SearchPipelineRequest.SearchPipelineRequest()
    response = client.do_action_with_exception(request);
    json_response = json.loads(response)
    pipeline = json_response['PipelineList']['Pipeline'][0]
    request = UpdatePipelineRequest.UpdatePipelineRequest()
    request.set_PipelineId(pipeline['Id'])
    request.set_Name(pipeline['Name'])
    request.set_State('Paused' if pipeline['State'] == 'Active' else 'Active')
    response = client.do_action_with_exception(request);
    json_response = json.loads(response)
    pipeline = json_response['Pipeline']
    print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']