// DeleteScalingPolicy private static void DeleteScalingPolicy(AsClient asClient) { var deleteScalingPolicyRequest = new DeleteScalingPolicyRequest { ScalingPolicyId = "2e216c3a-406e-4c35-bc41-237664357932" }; try { var deleteScalingPolicyResponse = asClient.DeleteScalingPolicy(deleteScalingPolicyRequest); Console.WriteLine(deleteScalingPolicyResponse.HttpStatusCode); } 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); } }
// BatchDeleteScalingConfig private static void BatchDeleteScalingConfig(AsClient asClient) { var batchDeleteScalingConfigRequest = new BatchDeleteScalingConfigsRequest { Body = new BatchDeleteScalingConfigsRequestBody { ScalingConfigurationId = new List <string> { "085b99d1-c923-41ea-9d7e-35b3bdf1e583" } } }; try { var batchDeleteScalingConfigsResponse = asClient.BatchDeleteScalingConfigs(batchDeleteScalingConfigRequest); Console.WriteLine(batchDeleteScalingConfigsResponse.HttpStatusCode); } 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); } }
// updateScalingPolicyV1 private static void UpdateScalingPolicy(AsClient asClient) { var updateScalingPolicyRequest = new UpdateScalingPolicyRequest() { ScalingPolicyId = "0d930a61-3c83-43c9-a820-8686d0d4d42d", Body = new UpdateScalingPolicyRequestBody { ScalingPolicyName = "test_policyss", } }; try { var updateScalingPolicyResponse = asClient.UpdateScalingPolicy(updateScalingPolicyRequest); Console.WriteLine(updateScalingPolicyResponse.ScalingPolicyId); } 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); } }
// Scaling Policy V1 // actionScalingPolicy private static void ActionScalingPolicy(AsClient asClient) { var operateScalingPolicyRequest = new ExecuteScalingPolicyRequest { ScalingPolicyId = "0d930a61-3c83-43c9-a820-8686d0d4d42d", Body = new ExecuteScalingPolicyRequestBody { Action = ExecuteScalingPolicyRequestBody.ActionEnum.PAUSE } }; try { var actionScalingPolicyResponse = asClient.ExecuteScalingPolicy(operateScalingPolicyRequest); Console.WriteLine(actionScalingPolicyResponse.HttpStatusCode); } 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); } }
// ListScalingPoliciesV1 private static void ListScalingPolicies(AsClient asClient) { var listScalingPoliciesRequest = new ListScalingPoliciesRequest() { ScalingGroupId = "fa07d522-6794-4c1c-98be-c1c2c4d43fbe" }; try { var listScalingPoliciesResponse = asClient.ListScalingPolicies(listScalingPoliciesRequest); Console.WriteLine(listScalingPoliciesResponse.ScalingPolicies); } 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); } }
// showScalingPolicyV1 private static void ShowScalingPolicy(AsClient asClient) { var showScalingPolicyRequest = new ShowScalingPolicyRequest() { ScalingPolicyId = "0d930a61-3c83-43c9-a820-8686d0d4d42d", }; try { var showScalingPolicyResponse = asClient.ShowScalingPolicy(showScalingPolicyRequest); Console.WriteLine(showScalingPolicyResponse.ScalingPolicy); } 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); } }
// ListScalingGroups private static void ListScalingGroups(AsClient asClient) { var listScalingGroupsRequest = new ListScalingGroupsRequest { ScalingGroupName = "as-group-x2wd" }; try { var listScalingGroupsResponse = asClient.ListScalingGroups(listScalingGroupsRequest); Console.WriteLine(listScalingGroupsResponse.ScalingGroups); } 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); } }
// Scaling Configuration // ShowScalingConfig private static void ShowScalingConfiguration(AsClient asClient) { var showScalingConfigRequest = new ShowScalingConfigRequest { ScalingConfigurationId = "fee60fed-b04c-4ce1-9e6d-796999f76e28" }; try { var showScalingConfigResponse = asClient.ShowScalingConfig(showScalingConfigRequest); Console.WriteLine(showScalingConfigResponse.ScalingConfiguration); } 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); } }
// Scaling Group // showScalingGroup private static void ShowScalingGroup(AsClient asClient) { var showScalingGroupRequest = new ShowScalingGroupRequest { ScalingGroupId = "76411642-56e5-47b2-89a5-78578d91a3b2" }; try { var showScalingGroupResponse = asClient.ShowScalingGroup(showScalingGroupRequest); Console.WriteLine(showScalingGroupResponse.ScalingGroup); } 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); } }
// List Scaling Activity Log V1 private static void ListScalingActivityLogsV1(AsClient asClient) { var listScalingActivityLogsRequest = new ListScalingActivityLogsRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f" }; try { var listScalingActivityLogsResponse = asClient.ListScalingActivityLogs(listScalingActivityLogsRequest); Console.WriteLine(listScalingActivityLogsResponse.ScalingActivityLog); } 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); } }
// DeleteScalingNotification private static void DeleteScalingNotification(AsClient asClient) { var deleteScalingNotificationRequest = new DeleteScalingNotificationRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f", TopicUrn = "urn:smn:br-iaas-odin1:0605767fb000d5762ffcc00b78d8b511:DONOTDEL-AS-TOPIC01" }; try { var deleteScalingNotificationResponse = asClient.DeleteScalingNotification(deleteScalingNotificationRequest); Console.WriteLine(deleteScalingNotificationResponse.HttpStatusCode); } 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); } }
// deleteScalingInstances private static void DeleteScalingInstance(AsClient asClient) { var deleteScalingInstanceRequest = new DeleteScalingInstanceRequest { InstanceId = "a38d0579-2e93-461a-9a70-bc84660b215c", InstanceDelete = DeleteScalingInstanceRequest.InstanceDeleteEnum.YES }; try { var deleteScalingInstanceResponse = asClient.DeleteScalingInstance(deleteScalingInstanceRequest); Console.WriteLine(deleteScalingInstanceResponse.HttpStatusCode); } 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); } }
//UpdateScalingGroup private static void UpdateScalingGroup(AsClient asClient) { var updateScalingGroupRequest = new UpdateScalingGroupRequest { ScalingGroupId = "76411642-56e5-47b2-89a5-78578d91a3b2", Body = new UpdateScalingGroupRequestBody { ScalingGroupName = "test111", DesireInstanceNumber = 0, ScalingConfigurationId = "d62a8ec6-3f97-43f3-82a3-b62141ac3a87" } }; try { var updateScalingGroupsResponse = asClient.UpdateScalingGroup(updateScalingGroupRequest); Console.WriteLine(updateScalingGroupsResponse.ScalingGroupId); } 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); } }
// DeleteLifeCycleHook private static void DeleteLifecycleHook(AsClient asClient) { var deleteLifecycleHookRequest = new DeleteLifecycleHookRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f", LifecycleHookName = "test_hook" }; try { var deleteLifecycleHookResponse = asClient.DeleteLifecycleHook(deleteLifecycleHookRequest); Console.WriteLine(deleteLifecycleHookResponse.HttpStatusCode); } 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); } }
// CreateLifeCycleHook private static void CreateLifeCycleHook(AsClient asClient) { var createLifyCycleHookRequest = new CreateLifyCycleHookRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f", Body = new CreateLifeCycleHookRequestBody { LifecycleHookName = "test_hook", LifecycleHookType = CreateLifeCycleHookRequestBody.LifecycleHookTypeEnum.INSTANCE_TERMINATING, NotificationTopicUrn = "urn:smn:br-iaas-odin1:0605767fb000d5762ffcc00b78d8b511:TESTAS" } }; try { var createLifeCycleHookResponse = asClient.CreateLifyCycleHook(createLifyCycleHookRequest); Console.WriteLine(createLifeCycleHookResponse.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); } }
// Scaling Policy Execute Log // ListScalingPolicyExecuteLogs private static void ListScalingPolicyExecuteLogs(AsClient asClient) { var listScalingPolicyExecuteLogsRequest = new ListScalingPolicyExecuteLogsRequest { ScalingPolicyId = "19a06b0b-66cc-4059-95fa-ad35f7a33998" }; try { var listScalingPolicyExecuteLogsResponse = asClient.ListScalingPolicyExecuteLogs(listScalingPolicyExecuteLogsRequest); Console.WriteLine(listScalingPolicyExecuteLogsResponse.ScalingPolicyExecuteLog); } 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); } }
// UpdateLifeCycleHook private static void UpdateLifeCycleHook(AsClient asClient) { var updateLifeCycleHookRequest = new UpdateLifeCycleHookRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f", LifecycleHookName = "test_hook", Body = new UpdateLifeCycleHookRequestBody { LifecycleHookType = UpdateLifeCycleHookRequestBody.LifecycleHookTypeEnum.INSTANCE_LAUNCHING } }; try { var updateLifeCycleHookResponse = asClient.UpdateLifeCycleHook(updateLifeCycleHookRequest); Console.WriteLine(updateLifeCycleHookResponse.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); } }
// queryTagsByResourceId private static void ListScalingTagInfosByResourceId(AsClient asClient) { var listScalingTagInfosByResourceIdRequest = new ListScalingTagInfosByResourceIdRequest { ResourceType = ListScalingTagInfosByResourceIdRequest.ResourceTypeEnum.SCALING_GROUP_TAG, ResourceId = "2a8a1a58-077e-462e-ad50-d2283ebe607f" }; try { var listScalingTagInfosByResourceIdResponse = asClient.ListScalingTagInfosByResourceId(listScalingTagInfosByResourceIdRequest); Console.WriteLine(listScalingTagInfosByResourceIdResponse.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); } }
// Tags // queryTagsByTenantId private static void ListScalingTagInfosByTenantId(AsClient asClient) { var listScalingTagInfosByTenantIdRequest = new ListScalingTagInfosByTenantIdRequest { ResourceType = ListScalingTagInfosByTenantIdRequest.ResourceTypeEnum.SCALING_GROUP_TAG }; try { var listScalingTagInfosByTenantIdResponse = asClient.ListScalingTagInfosByTenantId(listScalingTagInfosByTenantIdRequest); Console.WriteLine(listScalingTagInfosByTenantIdResponse.Tags); } 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); } }
//ActionScalingGroup private static void ActionScalingGroup(AsClient asClient) { var enableOrDisableScalingGroupRequest = new EnableOrDisableScalingGroupRequest { ScalingGroupId = "76411642-56e5-47b2-89a5-78578d91a3b2", Body = new EnableOrDisableScalingGroupRequestBody { Action = EnableOrDisableScalingGroupRequestBody.ActionEnum.PAUSE } }; try { var actionScalingGroupsResponse = asClient.EnableOrDisableScalingGroup(enableOrDisableScalingGroupRequest); Console.WriteLine(actionScalingGroupsResponse); } 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); } }
// ShowPolicyAndInstanceQuota private static void ShowPolicyAndInstanceQuota(AsClient asClient) { var showPolicyAndInstanceQuotaRequest = new ShowPolicyAndInstanceQuotaRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f" }; try { var showPolicyAndInstanceQuotaResponse = asClient.ShowPolicyAndInstanceQuota(showPolicyAndInstanceQuotaRequest); Console.WriteLine(showPolicyAndInstanceQuotaResponse.AllQuotas); } 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); } }
// 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); } }
// CreateScalingGroup private static void CreateScalingGroup(AsClient asClient) { var createScalingGroupRequest = new CreateScalingGroupRequest { Body = new CreateScalingGroupRequestBody { ScalingGroupName = "test", DesireInstanceNumber = 0, MinInstanceNumber = 0, MaxInstanceNumber = 1, AvailableZones = new List <string> { "br-iaas-odin1a" }, Networks = new List <Networks> { new Networks { Id = "d26f9090-09ef-4159-9414-db5a84d496ab" } }, VpcId = "46ffdfe9-4154-4d68-875d-d52409c03e2b" } }; try { var createScalingGroupsResponse = asClient.CreateScalingGroup(createScalingGroupRequest); Console.WriteLine(createScalingGroupsResponse.ScalingGroupId); } 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); } }
private static void Main1(string[] args) { const string ak = "{your ak string}"; const string sk = "{your sk string}"; const string endpoint = "{your endpoint}"; const string projectId = "{your project id}"; var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk, projectId); var asClient = AsClient.NewBuilder() .WithCredential(auth) .WithEndPoint(endpoint) .WithHttpConfig(config).Build(); //scaling group test ListScalingActivityLogsV1(asClient); }
// ListResourceInstances private static void ListResourceInstances(AsClient asClient) { var listResourceInstancesRequest = new ListResourceInstancesRequest { ResourceType = ListResourceInstancesRequest.ResourceTypeEnum.SCALING_GROUP_TAG, Body = new ShowTagsRequestBody { Action = ShowTagsRequestBody.ActionEnum.FILTER, Tags = new List <TagsMultiValue> { new TagsMultiValue { Key = "key", Values = new List <string> { "value" } } } } }; try { var listResourceInstancesResponse = asClient.ListResourceInstances(listResourceInstancesRequest); Console.WriteLine(listResourceInstancesResponse.Resources); } 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); } }
// operateTags private static void OperateScalingTagInfo(AsClient asClient) { var operateScalingTagInfoRequest = new CreateScalingTagsRequest { ResourceType = CreateScalingTagsRequest.ResourceTypeEnum.SCALING_GROUP_TAG, ResourceId = "2a8a1a58-077e-462e-ad50-d2283ebe607f", Body = new CreateScalingTagsRequestBody { Action = CreateScalingTagsRequestBody.ActionEnum.CREATE, Tags = new List <TagsSingleValue> { new TagsSingleValue { Key = "key", Value = "value" } } } }; try { var operateScalingTagInfoResponse = asClient.CreateScalingTags(operateScalingTagInfoRequest); Console.WriteLine(operateScalingTagInfoResponse.HttpStatusCode); } 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); } }
private static void Main1(string[] args) { const string ak = "{your ak string}"; const string sk = "{your sk string}"; const string endpoint = "{your endpoint}"; const string projectId = "{your project id}"; var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk, projectId); var asClient = AsClient.NewBuilder() .WithCredential(auth) .WithEndPoint(endpoint) .WithHttpConfig(config).Build(); // tags test ListScalingTagInfosByTenantId(asClient); ListScalingTagInfosByResourceId(asClient); OperateScalingTagInfo(asClient); ListResourceInstances(asClient); }
// Scaling Policy V1 // createScalingPolicyV1 private static void CreateScalingPolicy(AsClient asClient) { var createScalingPolicyRequest = new CreateScalingPolicyRequest() { Body = new CreateScalingPolicyRequestBody { ScalingPolicyName = "test_policy", ScalingGroupId = "fa07d522-6794-4c1c-98be-c1c2c4d43fbe", ScalingPolicyType = CreateScalingPolicyRequestBody.ScalingPolicyTypeEnum.ALARM, AlarmId = "al1584674706316rxR3Rjz7x", ScalingPolicyAction = new ScalingPolicyAction() { Operation = ScalingPolicyAction.OperationEnum.ADD, InstanceNumber = 1 } } }; try { var createScalingPolicyResponse = asClient.CreateScalingPolicy(createScalingPolicyRequest); Console.WriteLine(createScalingPolicyResponse.ScalingPolicyId); } 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); } }
// BatchDeleteScalingInstance private static void BatchDeleteScalingInstances(AsClient asClient) { var batchOperateScalingInstancesRequest = new UpdateScalingGroupInstanceRequest { ScalingGroupId = "2a8a1a58-077e-462e-ad50-d2283ebe607f", Body = new UpdateScalingGroupInstanceRequestBody() { InstancesId = new List <string> { "8277a5cb-25c8-4026-98ca-f6fda3fa18ec" }, InstanceDelete = "yes", Action = UpdateScalingGroupInstanceRequestBody.ActionEnum.REMOVE } }; try { var batchOperateScalingInstancesResponse = asClient.UpdateScalingGroupInstance(batchOperateScalingInstancesRequest); Console.WriteLine(batchOperateScalingInstancesResponse.HttpStatusCode); } 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); } }
// Quota // ShowResourceQuota private static void ShowResourceQuota(AsClient asClient) { var showResourceQuotaRequest = new ShowResourceQuotaRequest(); try { var showResourceQuotaResponse = asClient.ShowResourceQuota(showResourceQuotaRequest); Console.WriteLine(showResourceQuotaResponse.Quotas); } 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); } }