
# 配置系统默认的负载均衡器域名解析 - UpdateSystemDefaultDomainConfig
#### 功能介绍
配置系统默认的负载均衡器域名解析。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-elb/elb_dy_0000.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-elb/elb_sq_0001.html)。
- 如果使用身份策略授权，当前API调用无需身份策略权限。
 
#### URI
POST /v3/{project_id}/elb/loadbalancers/{loadbalancer_id}/dns/system-default-config
表1路径参数 
| 参数              | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| project_id      | 是    | String | **参数解释** ：项目ID。获取方式请参见[获取项目ID](https://support.huaweicloud.com/api-elb/elb_fl_0008.html)。 **约束限制**：不涉及 **取值范围**：长度为32个字符，由小写字母和数字组成。 **默认取值**：不涉及 |
| loadbalancer_id | 是    | String | **参数解释**：负载均衡器ID。 **约束限制**：不涉及 **取值范围**：不涉及 **默认取值**：不涉及                                                                                          |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                   |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | **参数解释**：IAM鉴权Token。 **约束限制**：不涉及 **取值范围**：不涉及 **默认取值**：不涉及 |
   
表3请求Body参数 
| 参数           | 是否必选 | 参数类型                                                                                                                    | 描述                              |
|:---|:---|:---|:---|
| loadbalancer | 是    | [SystemDefaultDnsConfigRequestBody] object | **参数解释**：配置负载均衡器系统默认域名解析相关配置参数。 |
   
 表4SystemDefaultDnsConfigRequestBody 
| 参数                         | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|:---|:---|:---|:---|
| private_domain_name_enable | 否    | Boolean | **参数解释**：是否启用私网域名解析。 **约束限制**：不涉及 **取值范围**： - true：开启私网域名解析。   - false：关闭私网域名解析。    **默认取值**：false |
| private_dns_record_set_ttl | 否    | Integer | **参数解释**：私网域名解析记录在本地DNS服务器的缓存超时时间，单位：秒。域名解析信息更新后，需要等待DNS服务器上的缓存超时才会生效。如果您的域名解析信息经常变更，建议TTL值设置相对小些，反之建议设置相对大些。 **约束限制**：不涉及 **取值范围**：1-2147483647 **默认取值**：300                                                                                                                                                                                                                                                                                                                                               |
| public_domain_name_enable  | 否    | Boolean | **参数解释**：是否启用公网域名解析。 **约束限制**：不涉及 **取值范围**： - true：开启公网域名解析。   - false：关闭公网域名解析。    **默认取值**：false |
| public_dns_record_set_ttl  | 否    | Integer | **参数解释**：公网域名解析记录在本地DNS服务器的缓存超时时间，单位：秒。域名解析信息更新后，需要等待DNS服务器上的缓存超时才会生效。如果您的域名解析信息经常变更，建议TTL值设置相对小些，反之建议设置相对大些。 **约束限制**：不涉及 **取值范围**：1-2147483647 **默认取值**：300                                                                                                                                                                                                                                                                                                                                               |
   
#### 响应参数
**状态码：200**
表5响应Body参数 
| 参数           | 参数类型                                                                                             | 描述                                                                                                     |
|:---|:---|:---|
| loadbalancer | [DnsConfigResponseBody] object | **参数解释**：负载均衡器域名解析配置。                                                                                  |
| request_id   | String                                                                                           | **参数解释**：请求ID。 **取值范围**：由数字、小写字母和中划线（-）组成的字符串，自动生成。 |
   
 表6DnsConfigResponseBody 
| 参数                         | 参数类型                                                                                       | 描述                                                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|
| id                         | String                                                                                     | **参数解释**：自定义域名解析配置ID。                                                                                                                                                                                                                                                                                                                                                                      |
| vip_address                | String                                                                                     | **参数解释**：负载均衡器的IPv4虚拟IP地址。                                                                                                                                                                                                                                                                                                                                                                 |
| ipv6_vip_address           | String                                                                                     | **参数解释**：双栈类型负载均衡器的IPv6地址。                                                                                                                                                                                                                                                                                                                                                                 |
| eips                       | Array of [EipInfo] objects             | **参数解释**：负载均衡器绑定的EIP。 注：该字段与publicips一致。                                                                                                                                                                                                                                                                                                |
| global_eips                | Array of [GlobalEipInfo] objects | **参数解释**：负载均衡器绑定的GEIP。                                                                                                                                                                                                                                                                                                                                                                     |
| public_domain_name_enable  | Boolean                                                                                    | **参数解释**：是否配置公网域名。 **取值范围**： true：开启公网域名 false：关闭公网域名                                                                                                                                                                             |
| public_dns_zone_name       | String                                                                                     | **参数解释**：公网域名所使用的zone名称。                                                                                                                                                                                                                                                                                                                                                                   |
| public_domain_name         | String                                                                                     | **参数解释**： 负载均衡实例的公网域名。                                                                                                                                                                                                                                                                                                                  |
| public_dns_record_set_ttl  | Integer                                                                                    | 参数解释: 公网解析记录集超时时间。 解析记录在本地DNS服务器的缓存时间，缓存时间越长更新生效越慢，以秒为单位。 如果您的服务地址经常更换，建议TTL值设置相对小些，反之，建议设置相对大些。 **取值范围**： 1-2147483647     |
| private_domain_name_enable | Boolean                                                                                    | **参数解释**： 是否配置私网域名。 **取值范围**： true：开启私网域名 false：关闭私网域名                                                                                                                         |
| private_dns_zone_name      | String                                                                                     | **参数解释**： 私网域名所使用的zone的名称。                                                                                                                                                                                                                                                                                                              |
| private_domain_name        | String                                                                                     | **参数解释**：负载均衡实例的私网域名。                                                                                                                                                                                                                                                                                                                                                                      |
| private_dns_zone_type      | String                                                                                     | **参数解释**：私网域名所使用的zone的类型。 **取值范围**：private public                                                                                                                                                                                                                                                                                       |
| private_dns_record_set_ttl | Integer                                                                                    | **参数解释**： 私网解析记录集超时时间。 解析记录在本地DNS服务器的缓存时间，缓存时间越长更新生效越慢，以秒为单位。 如果您的服务地址经常更换，建议TTL值设置相对小些，反之，建议设置相对大些。 **取值范围**： 1-2147483647 |
   
 表7EipInfo 
| 参数          | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|
| eip_id      | String  | **参数解释**：弹性IP的ID。 **取值范围**：不涉及                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| eip_address | String  | **参数解释**：弹性IP的IP地址。 **取值范围**：不涉及                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ip_version  | Integer | **参数解释**：IP版本号。 **取值范围**： - 4：表示IPv4地址。   - 6：表示IPv6地址。    |
   
 表8GlobalEipInfo 
| 参数                 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|:---|:---|:---|
| global_eip_id      | String  | **参数解释**：global eip的ID。 **取值范围**：不涉及                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| global_eip_address | String  | **参数解释**：global eip的ip地址。 **取值范围**：不涉及                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ip_version         | Integer | **参数解释**：IP版本信息。 **取值范围**： - 4，表示IPv4   - 6，表示IPv6    |
   
#### 请求示例
配置系统默认的负载均衡器域名解析
```
POST https://{ELB_Endpoint}/v3/{project_id}/elb/loadbalancers/{loadbalancer_id}/dns/system-default-config
{
  "loadbalancer" : {
    "public_dns_record_set_ttl" : 300,
    "public_domain_name_enable" : true,
    "private_dns_record_set_ttl" : 300,
    "private_domain_name_enable" : true
  }
}
```
#### 响应示例
**状态码：200**
操作正常返回。
```
{
  "request_id" : "722834ebe55f6bf9ebe7ee9a21be4934",
  "loadbalancer" : {
    "id" : "737b61b6-ff56-4112-a14a-c7abaa4e58bf",
    "vip_address" : "192.168.0.166",
    "ipv6_vip_address" : null,
    "global_eips" : [ ],
    "eips" : [ {
      "eip_id" : "0e2749aa-15ca-4826-91e8-d944086b452f",
      "eip_address" : "10.83.50.35",
      "ip_version" : 4
    } ],
    "public_dns_zone_name" : "elb.my-elb.com",
    "public_domain_name_enable" : true,
    "public_domain_name" : "737b61b6-ff56-4112-a14a-c7abaa4e58bf.elb.my-elb.com",
    "public_dns_record_set_ttl" : 300,
    "private_dns_zone_name" : "elb.my-elb.com",
    "private_dns_zone_type" : "public",
    "private_domain_name_enable" : true,
    "private_domain_name" : "737b61b6-ff56-4112-a14a-c7abaa4e58bf-internal.elb.my-elb.com",
    "private_dns_record_set_ttl" : 300
  }
}
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  配置系统默认的负载均衡器域名解析
  ```
  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 UpdateSystemDefaultDomainConfigSolution {
      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");
          String projectId = "{project_id}";
          ICredential auth = new BasicCredentials()
                  .withProjectId(projectId)
                  .withAk(ak)
                  .withSk(sk);
          ElbClient client = ElbClient.newBuilder()
                  .withCredential(auth)
                  .withRegion(ElbRegion.valueOf("<YOUR REGION>"))
                  .build();
          UpdateSystemDefaultDomainConfigRequest request = new UpdateSystemDefaultDomainConfigRequest();
          request.withLoadbalancerId("{loadbalancer_id}");
          UpdateSystemDefaultDomainConfigRequestBody body = new UpdateSystemDefaultDomainConfigRequestBody();
          SystemDefaultDnsConfigRequestBody loadbalancerbody = new SystemDefaultDnsConfigRequestBody();
          loadbalancerbody.withPrivateDomainNameEnable(true)
              .withPrivateDnsRecordSetTtl(300)
              .withPublicDomainNameEnable(true)
              .withPublicDnsRecordSetTtl(300);
          body.withLoadbalancer(loadbalancerbody);
          request.withBody(body);
          try {
              UpdateSystemDefaultDomainConfigResponse response = client.updateSystemDefaultDomainConfig(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());
          }
      }
  }
  ```
- [Python]
  配置系统默认的负载均衡器域名解析
  ```
  # coding: utf-8
  import os
  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 = os.environ["CLOUD_SDK_AK"]
      sk = os.environ["CLOUD_SDK_SK"]
      projectId = "{project_id}"
      credentials = BasicCredentials(ak, sk, projectId)
      client = ElbClient.new_builder() \
          .with_credentials(credentials) \
          .with_region(ElbRegion.value_of("<YOUR REGION>")) \
          .build()
      try:
          request = UpdateSystemDefaultDomainConfigRequest()
          request.loadbalancer_id = "{loadbalancer_id}"
          loadbalancerbody = SystemDefaultDnsConfigRequestBody(
              private_domain_name_enable=True,
              private_dns_record_set_ttl=300,
              public_domain_name_enable=True,
              public_dns_record_set_ttl=300
          )
          request.body = UpdateSystemDefaultDomainConfigRequestBody(
              loadbalancer=loadbalancerbody
          )
          response = client.update_system_default_domain_config(request)
          print(response)
      except exceptions.ClientRequestException as e:
          print(e.status_code)
          print(e.request_id)
          print(e.error_code)
          print(e.error_msg)
  ```
- [Go]
  配置系统默认的负载均衡器域名解析
  ```
  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")
      projectId := "{project_id}"
      auth, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          WithProjectId(projectId).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := elb.ElbClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := elb.NewElbClient(hcClient)
      request := &model.UpdateSystemDefaultDomainConfigRequest{}
  request.LoadbalancerId = "{loadbalancer_id}"
  privateDomainNameEnableLoadbalancer:= true
  privateDnsRecordSetTtlLoadbalancer:= int32(300)
  publicDomainNameEnableLoadbalancer:= true
  publicDnsRecordSetTtlLoadbalancer:= int32(300)
  loadbalancerbody := &model.SystemDefaultDnsConfigRequestBody{
  PrivateDomainNameEnable: &privateDomainNameEnableLoadbalancer,
  PrivateDnsRecordSetTtl: &privateDnsRecordSetTtlLoadbalancer,
  PublicDomainNameEnable: &publicDomainNameEnableLoadbalancer,
  PublicDnsRecordSetTtl: &publicDnsRecordSetTtlLoadbalancer,
  }
  request.Body = &model.UpdateSystemDefaultDomainConfigRequestBody{
  Loadbalancer: loadbalancerbody,
  }
  response, err := client.UpdateSystemDefaultDomainConfig(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/ELB/sdk?api=UpdateSystemDefaultDomainConfig&version=v3)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述      |
|:---|:---|
| 200 | 操作正常返回。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-elb/ErrorCode.html)。
