You need to enable JavaScript to run this app.
导航

修改一条伸缩规则

最近更新时间2023.07.19 17:54:46

首次发布时间2023.07.19 17:54:46

本文介绍如何获取修改一条伸缩规则。

示例代码

package com.volcengine.autoscaling.examples;

import com.volcengine.ApiClient;
import com.volcengine.ApiException;
import com.volcengine.sign.Credentials;

import com.volcengine.autoscaling.AutoScalingApi;
import com.volcengine.autoscaling.model.*;


public class TestModifyScalingPolicy {
    public static void main(String[] args) throws Exception {
        //设置您的ak
        String ak = "Your AK";
        //设置您的sk
        String sk = "Your SK";
        //设置您要访问的地域
        String region = "Your Region";

				//初始化apiclient
        ApiClient apiClient = new ApiClient()
                .setCredentials(Credentials.getCredentials(ak, sk))
                .setRegion(region);

        AutoScalingApi api = new AutoScalingApi(apiClient);

        //修改一条伸缩规则
        ModifyScalingPolicyRequest modifyScalingPolicyRequest = new ModifyScalingPolicyRequest();
        modifyScalingPolicyRequest.setScalingPolicyId("sp-ybmvamf8uql8j1fl****");//伸缩规则ID
        modifyScalingPolicyRequest.setScalingPolicyName("test1-policy");//修改后的伸缩规则的名称

        // 发起请求并处理返回或异常
        try {
            ModifyScalingPolicyResponse response = api.modifyScalingPolicy(modifyScalingPolicyRequest);
            System.out.println(response);
        } catch (ApiException e) {
            System.out.println(e.getResponseBody());
        }
    }
}

相关文档