private static void listProperties(IoTDAClient client)
        {
            ListPropertiesRequest req = new ListPropertiesRequest
            {
                InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0",
                DeviceId   = "",
                ServiceId  = ""
            };

            try
            {
                var resp = client.ListProperties(req);
                Console.WriteLine(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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询设备属性
        /// </summary>
        public async Task <ListPropertiesResponse> ListPropertiesAsync(ListPropertiesRequest listPropertiesRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("device_id", listPropertiesRequest.DeviceId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v5/iot/{project_id}/devices/{device_id}/properties", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, listPropertiesRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <ListPropertiesResponse>(response));
        }
        /// <summary>Snippet for ListPropertiesAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListPropertiesRequestObjectAsync()
        {
            // Create client
            AnalyticsAdminServiceClient analyticsAdminServiceClient = await AnalyticsAdminServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListPropertiesRequest request = new ListPropertiesRequest
            {
                Filter      = "",
                ShowDeleted = false,
            };
            // Make the request
            PagedAsyncEnumerable <ListPropertiesResponse, Property> response = analyticsAdminServiceClient.ListPropertiesAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Property item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListPropertiesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Property item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int             pageSize   = 10;
            Page <Property> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Property item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
        }
 /// <summary>
 /// Retrieve list of properties for a resource. Resulting list may require paging.
 /// </summary>
 public ListPropertiesResponse ListPropertiesForResource(ListPropertiesRequest request, IRequestOptions options = null)
 {
     return WebClient.Send(request, options);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Retrieve list of properties for a resource. Resulting list may require paging.
 /// </summary>
 public ListPropertiesResponse ListPropertiesForResource(ListPropertiesRequest request, IRequestOptions options = null)
 {
     return(WebClient.Send(request, options));
 }