Network probe
Initialize
Confirm Endpoint
Before configuring the endpoint for SDK usage, please refer to the developer guide section on VPC Service Domain Name to understand endpoint-related concepts. Baidu AI Cloud currently supports multiple regions. Please refer to the VPC section in the Region Selection Guide. The probe service is part of the VPC service and adopts the VPC service domain name.
Retrieve access key
To use Baidu AI Cloud products, you need a Baidu AI Cloud account, as well as a valid AK (Access Key ID) and SK (Secret Access Key) for signature authentication.
Your AK/SK information can be obtained and understood through the following steps:
After obtaining the key, it must be provided as a parameter during Client configuration. The SDK integrates an authentication mechanism, so you don’t need to understand the underlying authentication process. Simply fill in the AK/SK in the designated fields as required, and the SDK will automatically handle the authentication for you.
Create ProbeClient
ProbeClient encapsulates the probe service's APIs, thereby simplifying developer interaction with the probe service. Users can call ProbeClient methods to configure probes, with return parameters consistent with API methods.
When creating a new ProbeClient, first configure a BceClientConfiguration-type config instance using Endpoint, AK and SK, and then use the config instance to configure the ProbeClient. The specific configuration method is as follows:
1ak = b''
2sk = b''
3endpoint = b'bcc.bj.baidubce.com' # Replace with your havip endpoint
4config = BceClientConfiguration(credentials=BceCredentials(access_key_id=ak, secret_access_key=sk),endpoint=endpoint)
5probe_client = probe_client.ProbeClient(config)
Create Network Probe
The create_probe function can be used to create probes in the subnet of the specified VPC:
1@required(name=(bytes, str),
2 vpc_id=(bytes, str),
3 subnet_id=(bytes, str),
4 protocol=(bytes, str),
5 frequency=int,
6 source_ips=list,
7 source_ip_num=int)
8def create_probe(self, name, vpc_id, subnet_id, protocol,
9 frequency, dst_ip, dst_port=None,
10 source_ips=[], source_ip_num=None,
11 description=None,
12 payload=None, client_token=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Xl6a5e196
Response Value
- Operation succeeded:
1{
2 "probeId": "probe-s2kyrsdnvk287ziu"
3}
- Operation failed:
Throw an exception. For the exception list, refer to Exception List
Code example
For specific code examples, refer to example_create_probe.py
Query network probe list.
The list_probes function can be used to query probe list information:
1def list_probes(self, marker=None, max_keys=None, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/Ul6lld6c5
Response value
- Operation succeeded:
1{
2 "nextMarker": "probe-68sfxk5ihf85hjs",
3 "marker": "probe-6gfqbgfypumvmyh0",
4 "maxKeys": 1,
5 "isTruncated": true,
6 "probes": [
7 {
8 "description":"dsdsds",
9 "destIp":"1.2.3.4",
10 "destPort":11,
11 "frequency":20,
12 "name":"probe1",
13 "payload":"qqqqqqwwwww",
14 "probeId":"probe-6gfqbgfypumvmyh0",
15 "protocol":"UDP",
16 "sourceIps":[
17 "192.168.0.4"
18 ],
19 "status":"active",
20 "subnetId":"sbn-qz55vemw0n40",
21 "vpcId":"vpc-2pa2x0bjt26i"
22 }
23 ]
24 }
- Operation failed:
Throw an exception. For the exception list, refer to Exception List
Code example
For specific code examples, refer to example_list_probes.py
Query network probe details
The get_probe function can be used to query detailed information of specified probes:
1@required(probe_id=(bytes, str))
2def get_probe(self, probe_id, config=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/5l6lt3w4d
Response Value
- Operation succeeded:
1{
2 "probeId":"probe-6gfqbgfypumvmyh0",
3 "description":"dsdsds",
4 "destIp":"1.2.3.4",
5 "destPort":11,
6 "frequency":20,
7 "name":"probe1",
8 "payload":"qqqqqqwwwww",
9 "protocol":"UDP",
10 "sourceIps":[
11 "192.168.0.4"
12 ],
13 "status":"active",
14 "subnetId":"sbn-qz55vemw0n40",
15 "vpcId":"vpc-2pa2x0bjt26i"
16}
- Operation failed:
Throw an exception. For the exception list, refer to: Exception List
Code example
For specific code examples, refer to example_get_probe.py
Update probe
The update_probe function can be used to update specified network probe information:
1@required(probe_id=(bytes, str))
2def update_probe(self, probe_id, name=None, description=None,
3 dst_ip=None, dst_port=None, frequency=None,
4 payload=None, client_token=None, config=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/dl6lu4bl8
Response Value
- Operation succeeded:
There are no special response parameters
- Operation failed:
Throw an exception. For the exception list, refer to Exception List
Code example
For specific code examples, refer to example_update_probe.py
Delete network probe
The delete_probe function can be used to delete specified network probes:
1@required(probe_id=(bytes, str))
2 def delete_probe(self, probe_id, client_token=None, config=None):
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/VPC/s/cl6ll9ur9
Response Value
- Operation succeeded:
There are no special response parameters
- Operation failed:
Throw an exception. For the exception list, refer to Exception List
Code example
For specific code examples, refer to example_delete_probe.py
