更新健康检查
功能介绍
更新健康检查。
接口约束
如果该健康检查绑定的负载均衡器的provisioning状态不是ACTIVE,不能更新该健康检查。
调用方法
请参见如何调用API。
URI
PUT /v3/{project_id}/elb/healthmonitors/{healthmonitor_id}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
healthmonitor_id |
是 |
String |
健康检查ID |
project_id |
是 |
String |
项目ID。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
IAM鉴权Token。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
healthmonitor |
是 |
UpdateHealthMonitorOption object |
健康检查对象。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
admin_state_up |
否 |
Boolean |
健康检查的管理状态。 取值:
|
delay |
否 |
Integer |
健康检查间隔。健康检查间隔。取值:1-50s。 最小值:1 最大值:50 |
domain_name |
否 |
String |
发送健康检查请求的域名。 取值:以数字或字母开头,只能包含数字、字母、’-’、’.’。 不能传空,但可传null或不传,表示使用负载均衡器的vip作为http请求的目的地址。 使用说明:当type为HTTP/HTTPS时生效。 最小长度:1 最大长度:100 |
expected_codes |
否 |
String |
期望响应状态码。 取值:
默认值:200。 仅支持HTTP/HTTPS设置该字段,其他协议设置不会生效。 最小长度:1 最大长度:64 |
http_method |
否 |
String |
HTTP请求方法。 取值:GET、HEAD、POST、PUT、DELETE、TRACE、OPTIONS、CONNECT、PATCH,默认GET。 使用说明:当type为HTTP/HTTPS时生效。 不支持该字段,请勿使用。 最小长度:1 最大长度:16 |
max_retries |
否 |
Integer |
健康检查连续成功多少次后,将后端服务器的健康检查状态由OFFLINE判定为ONLINE。取值范围:1-10。 最小值:1 最大值:10 |
max_retries_down |
否 |
Integer |
健康检查连续失败多少次后,将后端服务器的健康检查状态由ONLINE判定为OFFLINE。取值范围:1-10。 最小值:1 最大值:10 |
monitor_port |
否 |
Integer |
健康检查端口号。取值:1-65535,不可传入空,但可传入null,表示使用后端云服务器端口号。 最小值:1 最大值:65535 |
name |
否 |
String |
健康检查名称。 最小长度:0 最大长度:255 |
timeout |
否 |
Integer |
一次健康检查请求的超时时间。 建议该值小于delay的值。 最小值:1 最大值:50 |
url_path |
否 |
String |
健康检查请求的请求路径。以"/"开头,默认为"/"。 支持使用字母、数字和短划线(-)、正斜线(/)、半角句号(.)、百分号(%)、半角问号(?)、井号(#)和and(&)以及扩展字符集_;~!()*[]@$^:',+ 使用说明:当type为HTTP/HTTPS时生效。 最小长度:1 最大长度:80 |
type |
否 |
String |
健康检查请求协议。 取值:TCP、UDP_CONNECT、HTTP、HTTPS。 使用说明:
|
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
request_id |
String |
请求ID。 注:自动生成 。 |
healthmonitor |
HealthMonitor object |
健康检查对象。 |
参数 |
参数类型 |
描述 |
---|---|---|
admin_state_up |
Boolean |
健康检查的管理状态。 取值:
|
delay |
Integer |
健康检查间隔。取值:1-50s。 最小值:1 最大值:50 |
domain_name |
String |
发送健康检查请求的域名。 取值:以数字或字母开头,只能包含数字、字母、’-’、’.’。 默认为空,表示使用负载均衡器的vip作为http请求的目的地址。 使用说明:当type为HTTP/HTTPS时生效。 |
expected_codes |
String |
期望响应状态码。 取值:
默认值:200。 仅支持HTTP/HTTPS设置该字段,其他协议设置不会生效。 |
http_method |
String |
HTTP请求方法。 取值:GET、HEAD、POST、PUT、DELETE、TRACE、OPTIONS、CONNECT、PATCH,默认GET。 使用说明:当type为HTTP/HTTPS时生效。 不支持该字段,请勿使用。 |
id |
String |
健康检查ID |
max_retries |
Integer |
健康检查连续成功多少次后,将后端服务器的健康检查状态由OFFLINE判定为ONLINE。取值范围:1-10。 最小值:1 最大值:10 |
max_retries_down |
Integer |
健康检查连续失败多少次后,将后端服务器的健康检查状态由ONLINE判定为OFFLINE。取值范围:1-10,默认3。 最小值:1 最大值:10 |
monitor_port |
Integer |
健康检查端口号。取值:1-65535,默认为空,表示使用后端云服务器端口号。 最小值:1 最大值:65535 |
name |
String |
健康检查名称。 |
pools |
Array of PoolRef objects |
健康检查所在的后端云服务器组ID列表。实际只会有一个后端云服务器组ID。 |
project_id |
String |
健康检查所在的项目ID。 |
timeout |
Integer |
一次健康检查请求的超时时间。 建议该值小于delay的值。 最小值:1 最大值:50 |
type |
String |
健康检查请求协议。 取值:TCP、UDP_CONNECT、HTTP、HTTPS。 使用说明:
|
url_path |
String |
健康检查请求的请求路径。以"/"开头,默认为"/"。 支持使用字母、数字和短划线(-)、正斜线(/)、半角句号(.)、百分号(%)、半角问号(?)、井号(#)和and(&)以及扩展字符集_;~!()*[]@$^:',+ 使用说明:当type为HTTP/HTTPS时生效。 |
created_at |
String |
创建时间。格式:yyyy-MM-dd'T'HH:mm:ss'Z',UTC时区。 注意:独享型实例的历史数据以及共享型实例下的资源,不返回该字段。 |
updated_at |
String |
更新时间。格式:yyyy-MM-dd'T'HH:mm:ss'Z',UTC时区。 注意:独享型实例的历史数据以及共享型实例下的资源,不返回该字段。 |
请求示例
更新健康检查的检查间隔
PUT https://{ELB_Endpoint}/v3/99a3fff0d03c428eac3678da6a7d0f24/elb/healthmonitors/c2b210b2-60c4-449d-91e2-9e9ea1dd7441 { "healthmonitor" : { "name" : "My Healthmonitor update", "max_retries" : 10, "delay" : 10 } }
响应示例
状态码: 200
操作正常返回。
{ "request_id" : "08d6ffea-d092-4cfa-860a-e364f3bef1be", "healthmonitor" : { "monitor_port" : null, "id" : "c2b210b2-60c4-449d-91e2-9e9ea1dd7441", "project_id" : "99a3fff0d03c428eac3678da6a7d0f24", "domain_name" : null, "name" : "My Healthmonitor update", "delay" : 10, "max_retries" : 10, "pools" : [ { "id" : "488acc50-6bcf-423d-8f0a-0f4184f5b8a0" } ], "admin_state_up" : true, "timeout" : 30, "type" : "HTTP", "expected_codes" : "200", "url_path" : "/", "http_method" : "GET" } }
SDK代码示例
SDK代码示例如下。
更新健康检查的检查间隔
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class UpdateHealthMonitorSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); UpdateHealthMonitorRequest request = new UpdateHealthMonitorRequest(); UpdateHealthMonitorRequestBody body = new UpdateHealthMonitorRequestBody(); UpdateHealthMonitorOption healthmonitorbody = new UpdateHealthMonitorOption(); healthmonitorbody.withDelay(10) .withMaxRetries(10) .withName("My Healthmonitor update"); body.withHealthmonitor(healthmonitorbody); request.withBody(body); try { UpdateHealthMonitorResponse response = client.updateHealthMonitor(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
更新健康检查的检查间隔
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateHealthMonitorRequest() healthmonitorbody = UpdateHealthMonitorOption( delay=10, max_retries=10, name="My Healthmonitor update" ) request.body = UpdateHealthMonitorRequestBody( healthmonitor=healthmonitorbody ) response = client.update_health_monitor(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
更新健康检查的检查间隔
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateHealthMonitorRequest{} delayHealthmonitor:= int32(10) maxRetriesHealthmonitor:= int32(10) nameHealthmonitor:= "My Healthmonitor update" healthmonitorbody := &model.UpdateHealthMonitorOption{ Delay: &delayHealthmonitor, MaxRetries: &maxRetriesHealthmonitor, Name: &nameHealthmonitor, } request.Body = &model.UpdateHealthMonitorRequestBody{ Healthmonitor: healthmonitorbody, } response, err := client.UpdateHealthMonitor(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
操作正常返回。 |
400 |
1.无效的请求Body体。 2.无效的请求参数访问。 |
403 |
企业项目管理验证不过,token验证不过。 |
404 |
查找的资源不存在。 |
409 |
由于冲突,请求无法被完成。 |
431 |
请求头部太大。 |
494 |
请求头部字段太大或者cookie太大。 |
500 |
请求未完成,服务异常。 |
错误码
请参见错误码。