private static void batchDeleteInstanceTopic(KafkaClient client)
        {
            var req = new BatchDeleteInstanceTopicRequest()
            {
                InstanceId = instanceId,
                Body       = new BatchDeleteInstanceTopicReq
                {
                    Topics = new List <string>()
                    {
                        "topic-test"
                    },
                }
            };

            try
            {
                var resp = client.BatchDeleteInstanceTopic(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);
            }
        }
예제 #2
0
        /// <summary>
        /// Kafka实例批量删除Topic
        /// </summary>
        public BatchDeleteInstanceTopicResponse BatchDeleteInstanceTopic(BatchDeleteInstanceTopicRequest batchDeleteInstanceTopicRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("instance_id", batchDeleteInstanceTopicRequest.InstanceId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v2/{project_id}/instances/{instance_id}/topics/delete", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", batchDeleteInstanceTopicRequest);
            HttpResponseMessage response = DoHttpRequestSync("POST", request);

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