Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Direct Connect/ API Reference/ API/ Virtual Interfaces/ Updating a Virtual Interface

Updating a Virtual Interface

Function

This API is used to update a virtual interface.

Debugging

For details, see Calling APIs.

URI

PUT /v3/{project_id}/dcaas/virtual-interfaces/{virtual_interface_id}

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

virtual_interface_id

Yes

String

Specifies the virtual interface ID.

Minimum: 36

Maximum: 36

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

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

Minimum: 0

Maximum: 10240

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

virtual_interface

Yes

UpdateVirtualInterface object

Specifies the virtual interface to be updated.

Table 4 UpdateVirtualInterface

Parameter

Mandatory

Type

Description

name

No

String

Specifies the virtual interface name.

Minimum: 0

Maximum: 64

description

No

String

Provides supplementary information about the virtual interface.

Minimum: 0

Maximum: 128

bandwidth

No

Integer

Specifies the virtual interface bandwidth configuration.

Minimum: 2

Maximum: 2147483647

remote_ep_group

No

Array of strings

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

service_ep_group

No

Array of strings

Specifies the local endpoint group that is connected to the public network over a connection.

enable_bfd

No

Boolean

Specifies whether to enable BFD. The value can be true or false.

enable_nqa

No

Boolean

Specifies whether to enable NQA. The value can be true or false.

status

No

String

Confirms the virtual interfaces created by other users. The value can be ACCEPTED or REJECTED.

Enumeration values:

  • ACCEPTED
  • REJECTED

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID.

virtual_interface

VirtualInterface object

Specifies the virtual interface.

Table 6 VirtualInterface

Parameter

Type

Description

id

String

Specifies the virtual interface ID.

Maximum: 36

name

String

Specifies the virtual interface name.

Maximum: 64

admin_state_up

Boolean

Specifies the administrative status. The value can be true or false.

bandwidth

Integer

Specifies the virtual interface bandwidth.

Minimum: 2

Maximum: 2147483647

create_time

String

Specifies when the virtual interface was created. The UTC time format is yyyy-MM-ddTHH:mm:ss.SSSZ.

Maximum: 255

update_time

String

Specifies when the virtual interface was updated. The UTC time format is yyyy-MM-ddTHH:mm:ss.SSSZ.

Maximum: 255

description

String

Provides supplementary information about the virtual interface.

Maximum: 128

direct_connect_id

String

Specifies the connection ID.

Maximum: 36

service_type

String

Specifies the gateway type. The value can be VGW, GDGW, or LGW. You do not need to configure this parameter if a virtual gateway is used.

Enumeration values:

  • VGW
  • GDGW
  • LGW

status

String

Specifies the operating status. The value can be ACTIVE, DOWN, BUILD, ERROR, PENDING_CREATE, PENDING_UPDATE, PENDING_DELETE, DELETED, AUTHORIZATION, or REJECTED.

tenant_id

String

Specifies the project ID.

Minimum: 32

Maximum: 32

type

String

Specifies the type of the virtual interface. The value is private.

Default: private

Maximum: 255

Enumeration value: private

vgw_id

String

Specifies the virtual gateway ID.

Minimum: 36

Maximum: 36

vlan

Integer

Specifies the VLAN for connecting to the customer gateway. The value ranges from 0 to 3999.

Minimum: 0

Maximum: 3999

route_limit

Integer

Specifies the remote subnet route configurations of the virtual interface.

Minimum: 1

Maximum: 200

Default: 50

enable_nqa

Boolean

Specifies whether NQA is enabled. The value can be true or false.

enable_bfd

Boolean

Specifies whether BFD is enabled. The value can be true or false.

lag_id

String

Specifies the ID of the LAG associated with the virtual interface.

Minimum: 36

Maximum: 36

device_id

String

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

enterprise_project_id

String

Specifies the ID of the enterprise project that the virtual interface belongs to.

Minimum: 36

Maximum: 36

tags

Array of Tag objects

Specifies the tags.

Array length: 0–10

local_gateway_v4_ip

String

Specifies the IPv4 interface address of the gateway used on the cloud. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

remote_gateway_v4_ip

String

Specifies the IPv4 interface address of the gateway used on premises. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

ies_id

String

Specifies the edge site ID.

reason

String

Displays error information if the status of a line is Error.

rate_limit

Boolean

Specifies whether rate limiting is enabled on a virtual interface.

address_family

String

Specifies the address family of the virtual interface. The value can be IPv4 or IPv6. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

local_gateway_v6_ip

String

Specifies the IPv6 interface address of the gateway used on the cloud. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

remote_gateway_v6_ip

String

Specifies the IPv6 interface address of the gateway used on premises. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

lgw_id

String

Specifies the ID of the local gateway, which is used in IES scenarios.

gateway_id

String

Specifies the ID of the gateway associated with the virtual interface.

remote_ep_group

Array of strings

Specifies the remote subnet list, which records the CIDR blocks used in the on-premises data center. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

service_ep_group

Array of strings

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. This parameter has been migrated to the vifpeer parameter list and will be discarded later.

bgp_route_limit

Integer

Specifies the BGP route configuration.

priority

String

Specifies the priority of a virtual interface. The value can be normal or low. If the priorities are the same, the virtual interfaces work in load balancing mode. If the priorities are different, the virtual interfaces work in active/standby pairs. Outbound traffic is preferentially forwarded to the normal virtual interface with a higher priority. This option is only supported by virtual interfaces that use BGP routing.

Default: normal

Enumeration values:

  • normal
  • low

vif_peers

Array of VifPeer objects

Provides information about virtual interface peers.

extend_attribute

VifExtendAttribute object

Provides extended parameter information.

Table 7 Tag

Parameter

Type

Description

key

String

Specifies the tag key. The key can contain a maximum of 36 Unicode characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

Minimum: 0

Maximum: 36

value

String

Specifies the tag value. The value can contain a maximum of 43 Unicode characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.

Minimum: 0

Maximum: 43

Table 8 VifPeer

Parameter

Type

Description

id

String

Specifies the resource ID.

Minimum: 36

Maximum: 36

tenant_id

String

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

Minimum: 36

Maximum: 36

name

String

Specifies the name of the virtual interface peer.

Minimum: 0

Maximum: 64

description

String

Provides supplementary information about the virtual interface peer.

Minimum: 0

Maximum: 128

address_family

String

Specifies the address family of the virtual interface. The value can be IPv4 or IPv6.

local_gateway_ip

String

Specifies the gateway of the virtual interface peer used on the cloud.

remote_gateway_ip

String

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

route_mode

String

Specifies the routing mode. The value can be static or bgp.

Maximum: 255

Enumeration values:

  • bgp
  • static

bgp_asn

Integer

Specifies the ASN of the BGP peer.

Minimum: 1

Maximum: 4294967295

bgp_md5

String

Specifies the MD5 password of the BGP peer.

remote_ep_group

Array of strings

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

service_ep_group

Array of strings

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

Specifies the ID of the device that the virtual interface peer belongs to.

bgp_route_limit

Integer

Specifies the BGP route configuration.

bgp_status

String

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

Maximum: 10

status

String

Specifies the status of the virtual interface peer.

vif_id

String

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

Minimum: 36

Maximum: 36

receive_route_num

Integer

Specifies the number of received BGP routes if BGP routing is used. If static routing is used, this parameter is meaningless and the value is -1. If this parameter cannot be obtained, contact customer service to migrate your ports.

enable_nqa

Boolean

Specifies whether NQA is enabled. The value can be true or false.

enable_bfd

Boolean

Specifies whether BFD is enabled. The value can be true or false.

Table 9 VifExtendAttribute

Parameter

Type

Description

ha_type

String

Specifies the availability detection type of the virtual interface.

Enumeration values:

  • nqa
  • bfd

ha_mode

String

Specifies the availability detection mode.

Enumeration values:

  • auto_single
  • auto_multi
  • static_single
  • static_multi
  • enhance_nqa

detect_multiplier

Integer

Specifies the number of detection retries.

Default: 5

min_rx_interval

Integer

Specifies the interval for receiving detection packets.

Default: 1000

min_tx_interval

Integer

Specifies the interval for sending detection packets.

Default: 1000

remote_disclaim

Integer

Specifies the remote identifier of the static BFD session.

local_disclaim

Integer

Specifies the local identifier of the static BFD session.

Example Requests

Updating the name and description of a virtual interface and changing its bandwidth to 2 Mbit/s

PUT https://{dc_endpoint}/v3/0605768a3300d5762f82c01180692873/dcaas/virtual-interfaces/0d0fdf63-f2c4-491c-8866-d504796189be

{
  "virtual_interface" : {
    "name" : "vif-0819",
    "description" : "mytest",
    "bandwidth" : 2
  }
}

Example Responses

Status code: 200

OK

{
  "virtual_interface" : {
    "id" : "0d0fdf63-f2c4-491c-8866-d504796189be",
    "name" : "vif-0819",
    "description" : "mytest",
    "tenant_id" : "0605768a3300d5762f82c01180692873",
    "direct_connect_id" : "4673e339-8412-4ee1-b73e-2ba9cdfa54c1",
    "vgw_id" : "8a47064a-f34c-4f94-b7fe-cac456c9b37b",
    "type" : "private",
    "service_type" : "VGW",
    "vlan" : 332,
    "bandwidth" : 2,
    "status" : "ACTIVE",
    "create_time" : "2022-08-19T11:28:06.000Z",
    "update_time" : "2022-08-19T11:28:06.000Z",
    "admin_state_up" : true,
    "enable_bfd" : false,
    "route_limit" : 50,
    "enable_nqa" : false,
    "local_gateway_v4_ip" : "1.1.1.1/30",
    "remote_gateway_v4_ip" : "1.1.1.2/30",
    "ies_id" : null,
    "reason" : null,
    "rate_limit" : false,
    "address_family" : "ipv4",
    "local_gateway_v6_ip" : null,
    "remote_gateway_v6_ip" : null,
    "lgw_id" : null,
    "lag_id" : null,
    "gateway_id" : null,
    "remote_ep_group" : [ "1.1.2.0/30" ],
    "service_ep_group" : [ ],
    "bgp_route_limit" : 100,
    "priority" : "normal",
    "vif_peers" : [ {
      "id" : "c768eb52-12a8-4859-9b43-81194643040c",
      "tenant_id" : "0605768a3300d5762f82c01180692873",
      "name" : "vif-0819",
      "description" : "",
      "address_family" : "ipv4",
      "local_gateway_ip" : "1.1.1.1/30",
      "remote_gateway_ip" : "1.1.1.2/30",
      "route_mode" : "static",
      "bgp_asn" : null,
      "bgp_md5" : null,
      "device_id" : "18.9.215.131",
      "bgp_route_limit" : 100,
      "bgp_status" : null,
      "status" : "ACTIVE",
      "vif_id" : "0d0fdf63-f2c4-491c-8866-d504796189be",
      "receive_route_num" : -1,
      "remote_ep_group" : [ "1.1.2.0/30" ],
      "service_ep_group" : null,
      "enable_bfd" : false,
      "enable_nqa" : false
    } ],
    "enterprise_project_id" : "0"
  },
  "request_id" : "5633df7af874576d819a481c76673236"
}

SDK Sample Code

The SDK sample code is as follows.

Updating the name and description of a virtual interface and changing its bandwidth to 2 Mbit/s

 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.dc.v3.region.DcRegion;
import com.huaweicloud.sdk.dc.v3.*;
import com.huaweicloud.sdk.dc.v3.model.*;


public class UpdateVirtualInterfaceSolution {

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

        DcClient client = DcClient.newBuilder()
                .withCredential(auth)
                .withRegion(DcRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateVirtualInterfaceRequest request = new UpdateVirtualInterfaceRequest();
        UpdateVirtualInterfaceRequestBody body = new UpdateVirtualInterfaceRequestBody();
        UpdateVirtualInterface virtualInterfacebody = new UpdateVirtualInterface();
        virtualInterfacebody.withName("vif-0819")
            .withDescription("mytest")
            .withBandwidth(2);
        body.withVirtualInterface(virtualInterfacebody);
        request.withBody(body);
        try {
            UpdateVirtualInterfaceResponse response = client.updateVirtualInterface(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 and description of a virtual interface and changing its bandwidth to 2 Mbit/s

 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 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.getenv("CLOUD_SDK_AK")
    sk = os.getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = DcClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DcRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateVirtualInterfaceRequest()
        virtualInterfacebody = UpdateVirtualInterface(
            name="vif-0819",
            description="mytest",
            bandwidth=2
        )
        request.body = UpdateVirtualInterfaceRequestBody(
            virtual_interface=virtualInterfacebody
        )
        response = client.update_virtual_interface(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 and description of a virtual interface and changing its bandwidth to 2 Mbit/s

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

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := dc.NewDcClient(
        dc.DcClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdateVirtualInterfaceRequest{}
	nameVirtualInterface:= "vif-0819"
	descriptionVirtualInterface:= "mytest"
	bandwidthVirtualInterface:= int32(2)
	virtualInterfacebody := &model.UpdateVirtualInterface{
		Name: &nameVirtualInterface,
		Description: &descriptionVirtualInterface,
		Bandwidth: &bandwidthVirtualInterface,
	}
	request.Body = &model.UpdateVirtualInterfaceRequestBody{
		VirtualInterface: virtualInterfacebody,
	}
	response, err := client.UpdateVirtualInterface(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.

Updating the name and description of a virtual interface and changing its bandwidth to 2 Mbit/s

 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.dc.v3.region.DcRegion;
import com.huaweicloud.sdk.dc.v3.*;
import com.huaweicloud.sdk.dc.v3.model.*;


public class UpdateVirtualInterfaceSolution {

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

        DcClient client = DcClient.newBuilder()
                .withCredential(auth)
                .withRegion(DcRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateVirtualInterfaceRequest request = new UpdateVirtualInterfaceRequest();
        UpdateVirtualInterfaceRequestBody body = new UpdateVirtualInterfaceRequestBody();
        UpdateVirtualInterface virtualInterfacebody = new UpdateVirtualInterface();
        virtualInterfacebody.withName("vif-0819")
            .withDescription("mytest")
            .withBandwidth(2);
        body.withVirtualInterface(virtualInterfacebody);
        request.withBody(body);
        try {
            UpdateVirtualInterfaceResponse response = client.updateVirtualInterface(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 and description of a virtual interface and changing its bandwidth to 2 Mbit/s

 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 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.getenv("CLOUD_SDK_AK")
    sk = os.getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = DcClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DcRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateVirtualInterfaceRequest()
        virtualInterfacebody = UpdateVirtualInterface(
            name="vif-0819",
            description="mytest",
            bandwidth=2
        )
        request.body = UpdateVirtualInterfaceRequestBody(
            virtual_interface=virtualInterfacebody
        )
        response = client.update_virtual_interface(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 and description of a virtual interface and changing its bandwidth to 2 Mbit/s

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

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := dc.NewDcClient(
        dc.DcClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdateVirtualInterfaceRequest{}
	nameVirtualInterface:= "vif-0819"
	descriptionVirtualInterface:= "mytest"
	bandwidthVirtualInterface:= int32(2)
	virtualInterfacebody := &model.UpdateVirtualInterface{
		Name: &nameVirtualInterface,
		Description: &descriptionVirtualInterface,
		Bandwidth: &bandwidthVirtualInterface,
	}
	request.Body = &model.UpdateVirtualInterfaceRequestBody{
		VirtualInterface: virtualInterfacebody,
	}
	response, err := client.UpdateVirtualInterface(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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback