/// <summary> /// 创建云服务器(按需) /// </summary> public CreatePostPaidServersResponse CreatePostPaidServers(CreatePostPaidServersRequest createPostPaidServersRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createPostPaidServersRequest); SdkResponse response = DoHttpRequest("POST", request); return(JsonUtils.DeSerialize <CreatePostPaidServersResponse>(response)); }
private static void CreatePostPaidServers(EcsClient client) { var req = new CreatePostPaidServersRequest { Body = new CreatePostPaidServersRequestBody { Server = new PostPaidServer { ImageRef = "700d66bc-62e3-4ebd-a07c-2a9b5caaf792", FlavorRef = "s2.small.1", AvailabilityZone = "br-iaas-odin1a", Name = "net-sdk-test", Vpcid = "175cbaaa-cfc7-4f4b-8b58-3878cfd9a8d9", Nics = new List <PostPaidServerNic> { new PostPaidServerNic { SubnetId = "38f3b970-594c-489a-aadc-ac565f1f5b5d", } }, RootVolume = new PostPaidServerRootVolume { Volumetype = PostPaidServerRootVolume.VolumetypeEnum.SATA } } } }; try { var resp = client.CreatePostPaidServers(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); } }