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

搜索管道

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

示例代码如下:
// 搜索管道
var RPCClient = require('@alicloud/pop-core').RPCClient;

function initMtsClient(accessKeyId, accessKeySecret, regionId) {
    var client = new RPCClient({
        accessKeyId: accessKeyId,
        accessKeySecret: accessKeySecret,
        endpoint: 'http://mts.' + regionId + '.aliyuncs.com',
        apiVersion: '2014-06-18'
    });
    return client;
}

var region = "xxx";
var accessKeyId = "xxx";
var accessKeySecret = "xxx";

var client = initMtsClient(accessKeyId, accessKeySecret, region);
client.request("SearchPipeline", {}, {}).then(function (response) {
    var pipelineList = response.PipelineList.Pipeline;
    for (var i = 0; i < pipelineList.length; i++) {
        console.log('PipelineName is: ' + pipelineList[i].Name);
        console.log('PipelineId is:' + pipelineList[i].Id);
    }
}).catch(function (response) {

    console.log(response);
});

查询管道

可以通过pipelineId调用查询管道接口,查询管道信息。

示例代码如下:
// 查询管道
var RPCClient = require('@alicloud/pop-core').RPCClient;
function initMtsClient(accessKeyId, accessKeySecret, regionId) {
    var client = new RPCClient({
        accessKeyId: accessKeyId,
        accessKeySecret: accessKeySecret,
        endpoint: 'http://mts.' + regionId + '.aliyuncs.com',
        apiVersion: '2014-06-18'
    });
    return client;
}
var region = "xxx";
var accessKeyId = "xxx";
var accessKeySecret = "xxx";
var pipelineIds = "xxx";
   
var client = initMtsClient(accessKeyId, accessKeySecret, region);

client.request("QueryPipelineList", {
    PipelineIds : pipelineIds
}, {}).then(function (response) {
                var pipelineList = response.PipelineList.Pipeline;
                for(var i=0; i < pipelineList.length; i++)
                {
                console.log('PipelineName is: ' + pipelineList[i].Name);
                console.log('PipelineId is:' + pipelineList[i].Id);
                }
    }).catch(function (response) {
       
        console.log(response);
    });

更新管道

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

示例代码如下:
//管道更新
var RPCClient = require('@alicloud/pop-core').RPCClient;

function initMtsClient(accessKeyId, accessKeySecret, regionId) {
    var client = new RPCClient({
        accessKeyId: accessKeyId,
        accessKeySecret: accessKeySecret,
        endpoint: 'http://mts.' + regionId + '.aliyuncs.com',
        apiVersion: '2014-06-18'
    });
    return client;
}

var region = "xxx";
var accessKeyId = "xxx";
var accessKeySecret = "xxx";

var client = initMtsClient(accessKeyId, accessKeySecret, region);


client.request("SearchPipeline", {}, {}).then(function (response) {
    var pipelineId = response.PipelineList.Pipeline[0].Id;
    var name = response.PipelineList.Pipeline[0].Name;
    client.request("UpdatePipeline", {
        PipelineId: pipelineId,
        Name: name,
        State: "Active"
    }, {}).then(function (response) {


        console.log('success');
        console.log('PipelineName is:' + response.Pipeline.Name);
        console.log('PipelineId is:' + response.Pipeline.Id);
        console.log('Pipeline State is:' + response.Pipeline.State);
    }).catch(function (response) {

        console.log(response);
    });
}).catch(function (response) {
    console.log(response);
});