private static void getRuleById(IoTDAClient client)
        {
            ShowRuleRequest req = new ShowRuleRequest
            {
                RuleId     = "5ea8ebe75d6efc01e5a022c8",
                InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0"
            };

            try
            {
                var resp = client.ShowRule(req);
                Console.WriteLine(resp.HttpStatusCode);
                Console.WriteLine(JsonConvert.SerializeObject(resp));
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 查询规则
        /// </summary>
        public async Task <ShowRuleResponse> ShowRuleAsync(ShowRuleRequest showRuleRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("rule_id", showRuleRequest.RuleId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v5/iot/{project_id}/rules/{rule_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, showRuleRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <ShowRuleResponse>(response));
        }