# 设置弹性公网IP的反向解析记录 - CreateEipRecordSet
#### 功能介绍
设置弹性公网IP的反向解析记录。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-dns/zh-cn_topic_0037134405.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-dns/dns_api_70000.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项            | 访问级别  | 资源类型（\*为必须） | 条件键                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | 别名          | 依赖的授权项                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
  |:---|:---|:---|:---|:---|:---|
  | dns:ptr:create | Write | ptr \*      | -                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | dns:ptr:set | - dns:tag:set  - eip:publicIps:get  - dns:quota:list   |
  | dns:ptr:create | Write | -           | - g:RequestTag/\<tag-key\>   - g:TagKeys   - g:EnterpriseProjectId    | dns:ptr:set | - dns:tag:set  - eip:publicIps:get  - dns:quota:list   |
     
  
 
#### URI
PATCH /v2/reverse/floatingips/{region}:{floatingip_id}
表1路径参数 
| 参数            | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|:---|:---|:---|:---|
| region        | 是    | String | **参数解释：** 租户的区域信息。 获取方式：通过查询区域列表接口或参见地区和终端节点获取。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值：** 不涉及。  |
| floatingip_id | 是    | String | **参数解释：** 弹性公网IP（EIP）的ID。 获取方式：通过查询弹性公网IP列表接口获取。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值：** 不涉及。 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | **参数解释：** 用户Token，用于用户身份认证，调用接口时需在请求头中携带该Token以验证用户身份。 通过调用IAM服务获取用户Token接口获取（响应消息头中X-Subject-Token的值）。 获取用户Token请参见[获取用户Token](https://support.huaweicloud.com/api-dns/dns_api_30003.html)。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值：** 不涉及。 |
   
表3请求Body参数 
| 参数                    | 是否必选 | 参数类型                                                                                        | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|:---|
| ptrdname              | 是    | String                                                                                      | **参数解释：** 反向解析记录对应的域名。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值：** 不涉及。                                                               |
| description           | 否    | String                                                                                      | **参数解释：** 对反向解析记录的描述。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值：** 不涉及。                                                                |
| ttl                   | 否    | Integer                                                                                     | **参数解释：** 反向解析记录在本地DNS服务器的缓存时间，缓存时间越长更新生效越慢，以秒为单位。 **约束限制：** 不涉及。 **取值范围：** 1\~2147483647。 **默认取值：** 不涉及。                         |
| enterprise_project_id | 否    | String                                                                                      | **参数解释：** 反向解析关联的企业项目ID。 获取方式：通过查询企业项目列表接口获取。 **约束限制：** 不涉及。 **取值范围：** 最大长度36字节，带"-"连字符的UUID格式，或者是字符串"0"。"0"表示默认企业项目。 **默认取值：** 0 |
| tags                  | 否    | Array of [tagReq] objects | **参数解释：** 资源标签。 该字段为数组，每个元素包含标签键和标签值，用于资源标签的分类管理与筛选。 **约束限制：** 不涉及。                                                                                                                                                                                                                                                                                                                                           |
   
 表4tagReq 
| 参数    | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|:---|
| key   | 是    | String | **参数解释：** 标签键。 **约束限制：** - 不能为空。   - 对于同一资源键的取值唯一。   - 首尾不能含有空格，不能以_sys_开头。    **取值范围：** - 长度不超过128个字符。   - 取值可以包含任意语种字母、数字、空格，以及_ . : = + - @特殊字符。    **默认取值：** 不涉及。 |
| value | 否    | String | **参数解释：** 标签值。 **约束限制：** - 可以为空。    **取值范围：** - 长度不超过255个字符。   - 取值可以包含任意语种字母、数字、空格，以及_ . : / = + - @特殊字符。    **默认取值：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
   
#### 响应参数
**状态码：202**
表5响应Body参数 
| 参数                    | 参数类型                                                                                   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|:---|:---|:---|
| id                    | String                                                                                 | **参数解释：** 反向解析记录的ID。 **取值范围：** 格式形如{region}:{floatingip_id}。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ptrdname              | String                                                                                 | **参数解释：** 反向解析记录对应的域名。 **取值范围：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| description           | String                                                                                 | **参数解释：** 对反向解析记录的描述。 **取值范围：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ttl                   | Integer                                                                                | **参数解释：** 反向解析记录在本地DNS服务器的缓存时间，缓存时间越长更新生效越慢，以秒为单位。 **取值范围：** 1\~2147483647。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| address               | String                                                                                 | **参数解释：** 弹性公网IP的IP地址。 **取值范围：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| status                | String                                                                                 | **参数解释：** 资源状态。 **取值范围：** - ACTIVE：正常   - PENDING_CREATE：创建中   - PENDING_UPDATE：更新中   - PENDING_DELETE：删除中   - PENDING_FREEZE：冻结中   - FREEZE：冻结   - ILLEGAL：违规冻结   - POLICE：公安冻结   - ERROR：失败    |
| action                | String                                                                                 | **参数解释：** 对该资源的当前操作。 **取值范围：** - CREATE：创建操作   - UPDATE：更新操作   - DELETE：删除操作   - NONE：无操作                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| links                 | [pageLink] object | **参数解释：** 指向当前页和下一页的链接。分页查询需要分页时，需要使用一个next字段指向下一页。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| enterprise_project_id | String                                                                                 | **参数解释：** 反向解析关联的企业项目ID。 **取值范围：** 最大长度36字节，带"-"连字符的UUID格式，或者是字符串"0"。"0"表示默认企业项目。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
   
 表6pageLink 
| 参数   | 参数类型   | 描述                                                                                                                                                                                                                                         |
|:---|:---|:---|
| self | String | **参数解释：** 当前页面的链接。 **取值范围：** 不涉及。 |
| next | String | **参数解释：** 下一页的链接。 **取值范围：** 不涉及。  |
   
#### 请求示例
设置弹性公网IP的反向解析记录，设置TTL为300秒。
```
PATCH https://{Endpoint}/v2/reverse/floatingips/{region}:{floatingip_id}
{
  "ptrdname" : "www.example.com",
  "description" : "Description for this PTR record",
  "ttl" : 300,
  "tags" : [ {
    "key" : "key1",
    "value" : "value1"
  } ]
}
```
#### 响应示例
**状态码：202**
```
{
  "id" : "{region_id}:c5504932-bf23-4171-b655-b87a6bc59334",
  "ptrdname" : "www.example.com.",
  "description" : "Description for this PTR record",
  "address" : "10.154.52.138",
  "action" : "CREATE",
  "ttl" : 300,
  "status" : "PENDING_CREATE",
  "links" : {
    "self" : "https://{Endpoint}/v2/reverse/floatingips/{region_id}:c5504932-bf23-4171-b655-b87a6bc59334"
  },
  "enterprise_project_id" : "0"
}
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  设置弹性公网IP的反向解析记录，设置TTL为300秒。
  ```
  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.dns.v2.region.DnsRegion;
  import com.huaweicloud.sdk.dns.v2.*;
  import com.huaweicloud.sdk.dns.v2.model.*;
  import java.util.List;
  import java.util.ArrayList;
  public class CreateEipRecordSetSolution {
      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);
          DnsClient client = DnsClient.newBuilder()
                  .withCredential(auth)
                  .withRegion(DnsRegion.valueOf("<YOUR REGION>"))
                  .build();
          CreateEipRecordSetRequest request = new CreateEipRecordSetRequest();
          request.withRegion("{region}");
          request.withFloatingipId("{floatingip_id}");
          CreatePtrReq body = new CreatePtrReq();
          List<Tag> listbodyTags = new ArrayList<>();
          listbodyTags.add(
              new Tag()
                  .withKey("key1")
                  .withValue("value1")
          );
          body.withTags(listbodyTags);
          body.withTtl(300);
          body.withDescription("Description for this PTR record");
          body.withPtrdname("www.example.com");
          request.withBody(body);
          try {
              CreateEipRecordSetResponse response = client.createEipRecordSet(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]
  设置弹性公网IP的反向解析记录，设置TTL为300秒。
  ```
  # coding: utf-8
  import os
  from huaweicloudsdkcore.auth.credentials import BasicCredentials
  from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
  from huaweicloudsdkcore.exceptions import exceptions
  from huaweicloudsdkdns.v2 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"]
      credentials = BasicCredentials(ak, sk)
      client = DnsClient.new_builder() \
          .with_credentials(credentials) \
          .with_region(DnsRegion.value_of("<YOUR REGION>")) \
          .build()
      try:
          request = CreateEipRecordSetRequest()
          request.region = "{region}"
          request.floatingip_id = "{floatingip_id}"
          listTagsbody = [
              Tag(
                  key="key1",
                  value="value1"
              )
          ]
          request.body = CreatePtrReq(
              tags=listTagsbody,
              ttl=300,
              description="Description for this PTR record",
              ptrdname="www.example.com"
          )
          response = client.create_eip_record_set(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]
  设置弹性公网IP的反向解析记录，设置TTL为300秒。
  ```
  package main
  import (
  "fmt"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
      dns "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dns/v2"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dns/v2/model"
      region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dns/v2/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, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := dns.DnsClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := dns.NewDnsClient(hcClient)
      request := &model.CreateEipRecordSetRequest{}
  request.Region = "{region}"
  request.FloatingipId = "{floatingip_id}"
  valueTags:= "value1"
  var listTagsbody = []model.Tag{
          {
              Key: "key1",
              Value: &valueTags,
          },
      }
  ttlCreatePtrReq:= int32(300)
  descriptionCreatePtrReq:= "Description for this PTR record"
  request.Body = &model.CreatePtrReq{
  Tags: &listTagsbody,
  Ttl: &ttlCreatePtrReq,
  Description: &descriptionCreatePtrReq,
  Ptrdname: "www.example.com",
  }
  response, err := client.CreateEipRecordSet(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/DNS/sdk?api=CreateEipRecordSet)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述                 |
|:---|:---|
| 202 | 设置弹性公网IP的反向解析记录响应。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-dns/ErrorCode.html)。
