/// <summary> /// 变更云服务器规格(按需) /// </summary> public ResizePostPaidServerResponse ResizePostPaidServer(ResizePostPaidServerRequest resizePostPaidServerRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("server_id", resizePostPaidServerRequest.ServerId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}/resize", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", resizePostPaidServerRequest); SdkResponse response = DoHttpRequest("POST", request); return(JsonUtils.DeSerialize <ResizePostPaidServerResponse>(response)); }
private static void ResizePostPaidServer(EcsClient client) { var req = new ResizePostPaidServerRequest { ServerId = "0bfacb9f-148a-4e39-8f6f-095a0600f141", Body = new ResizePostPaidServerRequestBody { Resize = new ResizePostPaidServerOption { FlavorRef = "s2.medium.4", Mode = "withStopServer" } } }; try { var resp = client.ResizePostPaidServer(req); var respStatusCode = resp.HttpStatusCode; var jobId = resp.JobId; Console.WriteLine(respStatusCode); Console.WriteLine(jobId); } 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); } }