# ModifyNatGatewayAttribute

## 1. API Description

This API (ModifyNatGatewayAttribute) is used to modify the attributes of the NAT gateway.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name   | Required | Type            | Description                                                                                                                                                                                                                        |
| ---------------- | -------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| natGatewayId     | Yes      | String          | NAT gateway ID.                                                                                                                                                                                                                    |
| name             | No       | String          | <p>NAT gateway name.</p><p>The length is 2 to 63 characters.</p>                                                                                                                                                                   |
| subnetIds        | No       | Array of String | Subnet ID associated withe the NAT gateway.                                                                                                                                                                                        |
| isAllSubnet      | No       | Boolean         | <p>Whether the NAT gateway applies to all subnets.</p><p>This field cannot be set together with subnetIds .</p>                                                                                                                    |
| icmpReplyEnabled | No       | Boolean         | Whether to enable ICMP echo reply or not.                                                                                                                                                                                          |
| securityGroupId  | No       | String          | <p>Target security group ID bound to the NAT gateway.</p><p>Currently, a NAT gateway can be associated with only one security group.</p><p>Specifying this field will unbind the original security group from the NAT gateway.</p> |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Modify the attributes of the NAT gateway by attaching to specified subnets.**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ModifyNatGatewayAttribute
<Common Request Params>

Request：
{
    "natGatewayId": "natGatewayId",
    "subnetIds": ["subnetId1", "subnetId2"]
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode).

| HTTP Status Code | Error Code                                    | Description                                                                                  |
| ---------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------- |
| 404              | INVALID\_NAT\_NOT\_FOUND                      | NAT gateway does not exist.                                                                  |
| 404              | INVALID\_NAT\_SUBNET\_IS\_MISSING             | The subnet range of the NAT gateway is smaller than the subnet range of its associated SNAT. |
| 404              | INVALID\_SUBNET\_NOT\_FOUND                   | Subnet does not exist.                                                                       |
| 400              | OPERATION\_DENIED\_NAT\_STATUS                | NAT gateway state is not RUNNING.                                                            |
| 400              | OPERATION\_DENIED\_SUBNET\_STATUS             | Subnet state is not supported.                                                               |
| 400              | OPERATION\_DENIED\_SUBNET\_TYPE\_NOT\_SUPPORT | Operations on subnets with such IP stack type is not supported.                              |
| 404              | INVALID\_SECURITY\_GROUP\_NOT\_FOUND          | The specified security group does not exist.                                                 |
