Dedicated gateway
Retrieve Endpoint
Before setting up the endpoint for SDK usage, consult the developer guide section on VPC service domain names to understand endpoint-related concepts. Baidu AI Cloud supports multiple regions. Refer to the Region Selection Guide's VPC section. The dedicated gateway service falls under the VPC service and uses the VPC service domain name.
Retrieve AK/SK
To use Baidu AI Cloud products, you need a Baidu AI Cloud account along with valid AK (Access Key ID) and SK (Secret Access Key) credentials for signature authorization. You can obtain and understand your AK/SK information through the following steps:
Create EtGateway client
The EtGatewayClient acts as the client for dedicated gateway services, offering developers various methods to interact with these services. To initialize an EtGatewayClient, first set up a configuration instance of BceClientConfiguration using Endpoint, AK, and SK, and then use this configuration to initialize the EtGatewayClient. The detailed configuration method is outlined below:
1 ak = "Your AK"
2 sk = "Your SK"
3 endpoint = "bcc.bj.baidubce.com"
4 config = BceClientConfiguration(credentials=BceCredentials(access_key_id=ak, secret_access_key=sk),
5 endpoint=endpoint)
6 et_gateway_client = et_gateway_client.EtGatewayClient(config)
Create dedicated gateway
Function declaration
1 def create_et_gateway(self, name, vpc_id, speed, et_id=None, channel_id=None,
2 local_cidrs=None, client_token=None, description=None, config=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Hk2ygtxlw
Response value
Operation succeeded:
1{
2 "etGatewayId": "dcgw-4ds9x3kmds88"
3}
Operation failed: Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_create_et_gateway.py
Update dedicated gateway
Function declaration
1 def update_et_gateway(self, et_gateway_id, name=None, description=None,
2 speed=None, local_cidrs=None, client_token=None, config=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/hk2yh2c7u
Response value
Operation succeeded:
1There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_update_et_gateway.py
Release dedicated gateway
Function declaration
1 def delete_et_gateway(self, et_gateway_id, client_token=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/vk2yh4sdb
Response value
Operation succeeded:
1There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_delete_et_gateway.py
Bind physical dedicated line
Function declaration
1def bind_et(self, et_id, et_gateway_id, channel_id, local_cidrs=None, client_token=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/nk2yh37ae
Response value
Operation succeeded:
1There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_bind_et.py
Unbind physical dedicated line
Function declaration
1 def unbind_et(self, et_gateway_id, client_token=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/yk2yh3yuy
Response value
Operation succeeded:
1There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_unbind_et.py
Query dedicated gateway list
Function declaration
1 def list_et_gateway(self, vpc_id, et_gateway_id=None, name=None,
2 status=None, marker=None, max_keys=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/3k2ygzmr6
Response value
Operation succeeded:
1Server: BWS
2{
3 "etGateways":[
4 {
5 "etGatewayId": "dcgw-4ds9x3kmds88",
6 "name": "dcGateway",
7 "status": "running",
8 "speed": 100,
9 "createTime": "2016-03-08T08:13:09Z",
10 "description": "",
11 "vpcId": "vpc-IyrqYIQ7",
12 "etId": "dcphy-478px3km77dh",
13 "channelId": "dedicatedconn-i7c1skfd0djs",
14 "localCidrs": ["192.168.0.0/20"],
15 "enableIpv6": 1,
16 "ipv6LocalCidrs": ["2400:da00:e003:0:15f::/87"]
17 }
18 ],
19 "marker":"dcgw-4ds9x3kmds88",
20 "isTruncated": true,
21 "nextMarker": "dcgw-bi72s924x5xu",
22 "maxKeys": 1
23}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_list_et_gateway.py
Query dedicated gateway details
Function declaration
1 def get_et_gateway(self, et_gateway_id, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/ak2yh15im
Response value
Operation succeeded:
1{
2 "etGatewayId":"dcgw-4ds9x3kmds88",
3 "name":"dcGateway",
4 "status":"running",
5 "speed":100,
6 "createTime":"2016-03-08T08:13:09Z",
7 "description":"",
8 "vpcId":"vpc-IyrqYIQ7",
9 "etId":"dcphy-478px3km77dh",
10 "channelId":"dedicatedconn-i7c1skfd0djs",
11 "localCidrs":["192.168.0.0/20"],
12 "enableIpv6": 1,
13 "ipv6LocalCidrs": ["2400:da00:e003:0:15f::/87"],
14 "healthCheckSourceIp":"192.168.5.2",
15 "healthCheckDestIp":"172.16.2.3",
16 "healthCheckType":"ICMP",
17 "healthCheckInterval":2,
18 "healthThreshold":2,
19 "unhealthThreshold":2
20}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_get_et_gateway.py
Create health check for dedicated gateway
Function declaration
1 def create_health_check(self, et_gateway_id, health_check_interval, health_check_threshold, unhealth_threshold,
2 health_check_source_ip=None, health_check_type=None, health_check_port=None,
3 auto_generate_route_rule=None, client_token=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Ak2yh5nm6
Response value
Operation succeeded:
1There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/VPC/s/sjwvyuhe7
Code example
For specific code examples, refer to example_create_health_check.py
