Help Center/ Direct Connect/ API Reference/ API/ Virtual Interfaces/ Updating a Virtual Interface Peer
Updated on 2026-11-11 GMT+08:00

Updating a Virtual Interface Peer

Function

This API is used to update a virtual interface peer, such as its remote subnet, name, and description. This API is available only in regions that support IPv6. To use this API, contact customer service.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    dcaas:vifPeer:update

    Write

    vifPeer *

    -

    -

    -

URI

PUT /v3/{project_id}/dcaas/vif-peers/{vif_peer_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Specifies the project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

vif_peer_id

Yes

String

Definition

Specifies the virtual interface peer ID.

Constraints

N/A

Range

The value can contain up to 36 characters in UUID format and is connected by hyphens (-).

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

Specifies the user token. To obtain the token, see section "Obtaining the User Token" in the Identity and Access Management API Reference. After the request is processed, the value of X-Subject-Token in the header is the token value.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

vif_peer

No

UpdateVifPeer object

Definition

Specifies the parameters for updating a virtual interface peer.

Constraints

N/A

Table 4 UpdateVifPeer

Parameter

Mandatory

Type

Description

name

No

String

Definition

Specifies the virtual interface peer name.

Constraints

N/A

Range

The value can contain a maximum of 64 characters.

Default Value

N/A

description

No

String

Definition

Provides supplementary information about the virtual interface peer.

Constraints

N/A

Range

The value can contain a maximum of 2,048 characters.

Default Value

N/A

remote_ep_group

No

Array of strings

Definition

Specifies the remote subnet list, which records the CIDR blocks used in the on-premises data center.

Constraints

N/A

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

vif_peer

VifPeer object

Definition

Specifies the virtual interface peer object.

Table 6 VifPeer

Parameter

Type

Description

id

String

Definition

Specifies the resource ID.

Range

The value can contain a maximum of 36 characters.

tenant_id

String

Definition

Specifies the ID of the project to which the virtual interface peer belongs.

Range

N/A

name

String

Definition

Specifies the virtual interface peer name.

Range

The value can contain a maximum of 64 characters.

description

String

Definition

Provides supplementary information about the virtual interface peer.

Range

The value can contain a maximum of 128 characters.

address_family

String

Definition

Specifies the address family of the virtual interface, which can be IPv4 or IPv6.

Range

N/A

local_gateway_ip

String

Definition

Specifies the IP address of the virtual interface peer used on the cloud.

Range

N/A

remote_gateway_ip

String

Definition

Specifies the IP address of the virtual interface peer used in the on-premises data center.

Range

N/A

route_mode

String

Definition

Specifies the routing mode, which can be static or bgp.

Range

  • bgp

  • static

bgp_asn

Integer

Definition

Specifies the ASN of the BGP peer.

Range

1 to 4294967295

bgp_md5

String

Definition

Specifies the MD5 password of the BGP peer.

Range

N/A

remote_ep_group

Array of strings

Definition

Specifies the remote subnet list, which records the CIDR blocks used in the on-premises data center.

service_ep_group

Array of strings

Definition

Specifies the list of public network addresses that can be accessed by the on-premises data center. This field is required in the APIs of public network connections.

device_id

String

Definition

Specifies the ID of the device to which the virtual interface belongs.

Range

N/A

bgp_route_limit

Integer

Definition

Specifies the BGP route configuration.

Range

N/A

bgp_status

String

Definition

Specifies the BGP protocol status of the virtual interface peer. If the virtual interface peer uses static routing, the status is null.

Range

N/A

status

String

Definition

Specifies the virtual interface peer status.

Range

  • ACTIVE: normal

  • ERROR: abnormal

vif_id

String

Definition

Specifies the ID of the virtual interface corresponding to the virtual interface peer.

Range

The value can contain a maximum of 36 characters.

receive_route_num

Integer

Definition

Specifies the number of received BGP routes if BGP routing is used. If static routing is used, this parameter does not take effect and the value is -1.

If this parameter cannot be obtained, contact customer service to migrate your ports.

Range

N/A

enable_nqa

Boolean

Definition

Specifies whether to enable the NQA function.

Range

  • true: Enables NQA.

  • false: Disables NQA.

enable_bfd

Boolean

Definition

Specifies whether to enable the BFD function.

Range

  • true: Enables BFD.

  • false: Disables BFD.

Example Requests

Updating the name, description, and remote subnet of a virtual interface peer

PUT https://{endpoint}/v3/cfa563efb77d4b6d9960781d82530fd8/dcaas/vif-peers/68250543-0a13-4ac7-aa36-d018856ac640

{
  "vif_peer" : {
    "name" : "vif-0819",
    "description" : "mytest",
    "remote_ep_group" : [ "20.1.1.0/24" ]
  }
}

Example Responses

Status code: 200

{
  "vif_peer" : {
    "name" : "vif-0819",
    "description" : "mytest",
    "id" : "4c95de3e-9f75-4357-9c79-b22498dd71c7",
    "tenant_id" : "ed28c294165741faaeccab26913122a1",
    "address_family" : "ipv4",
    "local_gateway_ip" : "12.3.4.1/30",
    "remote_gateway_ip" : "12.3.4.2/30",
    "route_mode" : "static",
    "bgp_asn" : null,
    "bgp_md5" : null,
    "bgp_route_limit" : 100,
    "bgp_status" : null,
    "status" : "ACTIVE",
    "vif_id" : "5d6c17bc-0ebe-420b-8734-21f519e9d7ad",
    "receive_route_num" : -1,
    "remote_ep_group" : [ "20.1.1.0/24" ],
    "service_ep_group" : null,
    "device_id" : "172.16.40.2",
    "enable_nqa" : false,
    "enable_bfd" : false
  }
}

SDK Sample Code

The SDK sample code is as follows.

Updating the name, description, and remote subnet of a virtual interface peer

 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
53
54
55
56
57
58
59
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.dc.v3.region.DcRegion;
import com.huaweicloud.sdk.dc.v3.*;
import com.huaweicloud.sdk.dc.v3.model.*;

import java.util.List;
import java.util.ArrayList;

public class UpdateVifPeerSolution {

    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);

        DcClient client = DcClient.newBuilder()
                .withCredential(auth)
                .withRegion(DcRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateVifPeerRequest request = new UpdateVifPeerRequest();
        request.withVifPeerId("{vif_peer_id}");
        UpdateVifPeerRequestBody body = new UpdateVifPeerRequestBody();
        List<String> listVifPeerRemoteEpGroup = new ArrayList<>();
        listVifPeerRemoteEpGroup.add("20.1.1.0/24");
        UpdateVifPeer vifPeerbody = new UpdateVifPeer();
        vifPeerbody.withName("vif-0819")
            .withDescription("mytest")
            .withRemoteEpGroup(listVifPeerRemoteEpGroup);
        body.withVifPeer(vifPeerbody);
        request.withBody(body);
        try {
            UpdateVifPeerResponse response = client.updateVifPeer(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());
        }
    }
}

Updating the name, description, and remote subnet of a virtual interface peer

 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdc.v3.region.dc_region import DcRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdc.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 = DcClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DcRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateVifPeerRequest()
        request.vif_peer_id = "{vif_peer_id}"
        listRemoteEpGroupVifPeer = [
            "20.1.1.0/24"
        ]
        vifPeerbody = UpdateVifPeer(
            name="vif-0819",
            description="mytest",
            remote_ep_group=listRemoteEpGroupVifPeer
        )
        request.body = UpdateVifPeerRequestBody(
            vif_peer=vifPeerbody
        )
        response = client.update_vif_peer(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Updating the name, description, and remote subnet of a virtual interface peer

 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
53
54
55
56
57
58
59
60
61
62
63
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dc/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dc/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dc/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 := dc.DcClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := dc.NewDcClient(hcClient)

    request := &model.UpdateVifPeerRequest{}
	request.VifPeerId = "{vif_peer_id}"
	var listRemoteEpGroupVifPeer = []string{
        "20.1.1.0/24",
    }
	nameVifPeer:= "vif-0819"
	descriptionVifPeer:= "mytest"
	vifPeerbody := &model.UpdateVifPeer{
		Name: &nameVifPeer,
		Description: &descriptionVifPeer,
		RemoteEpGroup: &listRemoteEpGroupVifPeer,
	}
	request.Body = &model.UpdateVifPeerRequestBody{
		VifPeer: vifPeerbody,
	}
	response, err := client.UpdateVifPeer(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.