private static void listInstanceTopics(KafkaClient client)
        {
            var req = new ListInstanceTopicsRequest()
            {
                InstanceId = instanceId
            };

            try
            {
                var resp = client.ListInstanceTopics(req);
                Console.WriteLine(resp.GetHttpBody());
            }
            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);
            }
        }
Example #2
0
        /// <summary>
        /// Kafka实例查询Topic
        /// </summary>
        public async Task <ListInstanceTopicsResponse> ListInstanceTopicsAsync(ListInstanceTopicsRequest listInstanceTopicsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("instance_id", listInstanceTopicsRequest.InstanceId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v2/{project_id}/instances/{instance_id}/topics", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", listInstanceTopicsRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

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