Ejemplo n.º 1
0
        //创建规则转发错误数据目的地,转发到其他Topic
        public void TestCreateErrorRuleAction()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();
            long             ruleId    = 321103;

            var Configuration = new
            {
                topic     = "/a163Bcy1oyR/secondDevice/user/update",
                topicType = 1
            };
            String configJson = JsonConvert.SerializeObject(Configuration);

            CreateRuleActionRequest request = new CreateRuleActionRequest();

            request.RuleId          = ruleId;
            request.Type            = "REPUBLISH";
            request.Configuration   = configJson;
            request.ErrorActionFlag = true;

            CreateRuleActionResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Create Rule Action: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
                return;
            }
            Console.WriteLine("Rule ActionId: " + response.ActionId);
        }
Ejemplo n.º 2
0
        //{
        //   "primaryKeys": [{
        //      "columnType": "STRING",
        //      "columnValue": "${province}",
        //      "columnName": "province",
        //      "option": ""
        //    }],
        // "role": {
        //      "roleName": "AliyunIOTAccessingOTSRole",
        //      "roleArn": "acs:ram::1371643086916874:role/aliyuniotaccessingotsrole"
        // },
        // "instanceName": "zengxg-ots0620",
        // "regionName": "us-east-1",
        // "tableName": "china"
        //}创建转发目的地,流转消息数据到存储表格云产品OTS中
        public void TestCreateOtsRuleAction()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();
            long             ruleId    = 321103;

            var roleObj = new
            {
                roleName = "AliyunIOTAccessingOTSRole",
                roleArn  = "acs:ram::13716430869xxxx:role/aliyuniotaccessingotsrole"
            };

            var primaryKeyObj = new
            {
                columnType  = "STRING",
                columnName  = "province",
                columnValue = "${province}",
                option      = ""
            };
            List <Object> primaryKeyList = new List <Object>();

            primaryKeyList.Add(primaryKeyObj);

            var Configuration = new
            {
                regionName   = "cn-shanghai",
                instanceName = "instance0826",
                tableName    = "china",
                role         = roleObj,
                primaryKeys  = primaryKeyList
            };
            String configJson = JsonConvert.SerializeObject(Configuration);

            Console.WriteLine(configJson);

            CreateRuleActionRequest request = new CreateRuleActionRequest();

            request.RuleId        = ruleId;
            request.Type          = "OTS";
            request.Configuration = configJson;

            CreateRuleActionResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Create Rule Action: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
                Console.ReadKey();
                return;
            }
            Console.WriteLine("Rule ActionId: " + response.ActionId);
        }
Ejemplo n.º 3
0
        //创建转发目的地,流转到流式计算产品中,前提是要授权物联网平台访问自己的云产品Datahub
        //        {
        //	        "regionName": "cn-shanghai",
        //	        "projectName": "yanglv_test",
        //	        "topicName": "test",
        //	        "role": {
        //		        "roleName": "AliyunIOTAccessingOTSRole",
        //		        "roleArn": "acs:ram::1232303971449186:role/aliyuniotaccessingotsrole"
        //	        },
        //          "schemaVals": [{
        //		    "type": "STRING",
        //		    "name": "notice",
        //		    "value": "${message}"
        //          }]
        //        }
        public void TestCreateDatahubRuleAction()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();
            long             ruleId    = 321103;

            var roleObj = new
            {
                roleName = "AliyunIOTAccessingDataHubRole",
                roleArn  = "acs:ram::123230397144xxxx:role/aliyuniotaccessingdatahubrole"
            };

            var schemaValObj = new
            {
                type  = "STRING",
                name  = "notice",
                value = "${message}"
            };
            List <Object> schemaValList = new List <Object>();

            schemaValList.Add(schemaValObj);

            var Configuration = new
            {
                regionName  = "cn-shanghai",
                projectName = "yanglv_test",
                topicName   = "test",
                role        = roleObj,
                schemaVals  = schemaValList
            };
            String configJson = JsonConvert.SerializeObject(Configuration);

            Console.WriteLine(configJson);

            CreateRuleActionRequest request = new CreateRuleActionRequest();

            request.RuleId        = ruleId;
            request.Type          = "DATAHUB";
            request.Configuration = configJson;

            CreateRuleActionResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Create Rule Action: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
                Console.ReadKey();
                return;
            }
            Console.WriteLine("Rule ActionId: " + response.ActionId);
        }
Ejemplo n.º 4
0
        //创建转发目的地,消息数据转发到函数计算云产品FC中
        public void TestCreateFcRuleAction()
        {
            DefaultAcsClient acsClient = Demo.IotClient.GetClient();
            long             ruleId    = 321103;

            var roleObj = new
            {
                roleName = "AliyunIOTAccessingFCRole",
                roleArn  = "acs:ram::12323039714xxxxx:role/aliyuniotaccessingfcrole"
            };

            var Configuration = new
            {
                regionName   = "cn-shanghai",
                serviceName  = "xizitest",
                functionName = "junit",
                role         = roleObj
            };
            String configJson = JsonConvert.SerializeObject(Configuration);

            Console.WriteLine(configJson);

            CreateRuleActionRequest request = new CreateRuleActionRequest();

            request.RuleId        = ruleId;
            request.Type          = "FC";
            request.Configuration = configJson;

            CreateRuleActionResponse response = acsClient.GetAcsResponse(request);

            Console.WriteLine("Create Rule Action: " + response.Success);
            if (!(bool)response.Success)
            {
                Console.WriteLine(response.Code + ", " + response.ErrorMessage);
                Console.ReadKey();
                return;
            }
            Console.WriteLine("Rule ActionId: " + response.ActionId);
        }