Exemplo n.º 1
0
        private static void updatePlugins(RabbitmqClient client)
        {
            var req = new UpdatePluginsRequest()
            {
                InstanceId = instanceId,
                Body       = new UpdatePluginsReq
                {
                    Enable  = true,
                    Plugins = "rabbitmq_sharding,rabbitmq_federation",
                }
            };

            try
            {
                var resp = client.UpdatePlugins(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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 开启或关闭插件
        /// </summary>
        public async Task <UpdatePluginsResponse> UpdatePluginsAsync(UpdatePluginsRequest updatePluginsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

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

            return(JsonUtils.DeSerialize <UpdatePluginsResponse>(response));
        }
        /// <summary>
        /// 变更插件列表
        /// </summary>
        /// <param name="req"><see cref="UpdatePluginsRequest"/></param>
        /// <returns><see cref="UpdatePluginsResponse"/></returns>
        public UpdatePluginsResponse UpdatePluginsSync(UpdatePluginsRequest req)
        {
            JsonResponseModel <UpdatePluginsResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "UpdatePlugins");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <UpdatePluginsResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }