/// <summary> /// 创建弹性伸缩配置 /// </summary> public CreateScalingConfigResponse CreateScalingConfig(CreateScalingConfigRequest createScalingConfigRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/autoscaling-api/v1/{project_id}/scaling_configuration", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createScalingConfigRequest); SdkResponse response = DoHttpRequest("POST", request); return(JsonUtils.DeSerialize <CreateScalingConfigResponse>(response)); }
// createScalingConfig private static void CreateScalingConfig(AsClient asClient) { var createScalingConfigRequest = new CreateScalingConfigRequest { Body = new CreateScalingConfigRequestBody { ScalingConfigurationName = "test_config", InstanceConfig = new InstanceConfig { FlavorRef = "s2.xlarge.2", ImageRef = "84663868-483c-4067-af7e-9d801e4a42f3", Disk = new List <Disk> { new Disk { Size = 40, VolumeType = Disk.VolumeTypeEnum.SATA, DiskType = Disk.DiskTypeEnum.SYS } }, KeyName = "KeyPair-lgj-no-delete" } } }; try { var createScalingConfigResponse = asClient.CreateScalingConfig(createScalingConfigRequest); Console.WriteLine(createScalingConfigResponse.ScalingConfigurationId); } 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); } }