Route management

CSN

  • API Reference
    • API function release records
    • Appendix
    • Bandwidth Package Related
      • Bandwidth package price inquiry
      • Bandwidth upgrade-downgrade for the bandwidth package
      • Bind a bandwidth package to a Cloud Smart Network
      • Create bandwidth package
      • Delete bandwidth package
      • Query bandwidth package list
      • Query the specified bandwidth package details
      • Unbind a bandwidth package from a Cloud Smart Network
      • Update bandwidth package
    • Cloud Smart Network Related
      • Create a Cloud Smart Network
      • Delete a Cloud Smart Network
      • Network instances loaded by the Cloud Smart Network
      • Network instances unloaded by the Cloud Smart Network
      • Query Cloud Smart Network details
      • Query Cloud Smart Network instance list
      • Query the list of Cloud Smart Network
      • Update a Cloud Smart Network
    • Common Headers and Error Responses
    • General Description
    • Ingress Management Related Interfaces
      • Add a routing entry
      • Create affiliation
      • Create learning relationship
      • Delete a learning relationship
      • Delete a routing entry
      • Delete an association relationship
      • Query association relationships
      • Query learning relationships
      • Query route table list
      • Query routing entries
    • Interface Overview
    • Region Bandwidth Related Interfaces
      • Create cross-region bandwidth
      • Delete cross-region bandwidth
      • Query cross-region bandwidth
      • Query the cross-region bandwidth of the specified Cloud Smart Network
      • Update cross-region bandwidth
    • Service domain
    • TGW Related Interfaces
      • Query routing entries of a TGW
      • Query TGW list
      • Update TGW information
  • FAQs
    • Consultation
  • Function Release Records
  • Operation guide
    • Cross-Account Authorization Management
      • Cancel Authorized Network Instance
      • Create Authorized Network Instance
      • Delete Authorized Network Instance
      • View Authorized Network Instance
    • Cross-Region Bandwidth Package Management
    • CSN Instance
      • Create CSN Instance
      • Delete CSN Instance
      • Modify CSN Instance
    • Identity and access management
    • Monitor and Operations
      • CSN Instance Diagnosis
    • Network instance
      • Add Cross-Account Network Instance
      • Add Local Account Network Instance
      • Adjust Network Instance Bandwidth
      • Uninstall Network Instance
    • Region Bandwidth Management
      • Adjust Region Bandwidth
      • Create cross-region bandwidth
      • Delete cross-region bandwidth
    • Route management
      • Association Relationship
        • Create affiliation
        • Delete affiliation
      • Custom route tables
        • Create custom route table
        • Delete custom route table
        • View Custom Route Table
      • Learning Relationship
        • Add Custom Route Entry
        • Create learning relationship
        • Delete Custom Route Entry
        • Delete learning relationship
        • Publish and Revoke Network Instance Route
        • View Route Entry
    • Tag Management
  • Product Description
    • Application scenarios
    • Introduction
    • Usage restrictions
  • Product pricing
  • SDK
    • GO-SDK
      • Bandwidth package
      • CSN Instance
      • Exception handling
      • Initialization
      • Install
      • Overview
      • Region Bandwidth
      • Route management
      • TGW
    • Java-SDK
      • CSN
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Python-SDK
      • Bandwidth package
      • CSN Instance
      • Initialization
      • Region Bandwidth
      • Route management
      • TGW
  • Service Level Agreement (SLA)
    • Cloud Smart Network Service Level Agreement SLA
  • Typical Practices
    • CSN supports VPC custom route tables for secure traffic access
    • Multi-IDC Disaster Recovery via Cloud Smart Network
    • Multi-IDC Interconnection via Cloud Smart Network
    • Private Network VPC Interconnection with Edge Network
All documents
menu
No results found, please re-enter

CSN

  • API Reference
    • API function release records
    • Appendix
    • Bandwidth Package Related
      • Bandwidth package price inquiry
      • Bandwidth upgrade-downgrade for the bandwidth package
      • Bind a bandwidth package to a Cloud Smart Network
      • Create bandwidth package
      • Delete bandwidth package
      • Query bandwidth package list
      • Query the specified bandwidth package details
      • Unbind a bandwidth package from a Cloud Smart Network
      • Update bandwidth package
    • Cloud Smart Network Related
      • Create a Cloud Smart Network
      • Delete a Cloud Smart Network
      • Network instances loaded by the Cloud Smart Network
      • Network instances unloaded by the Cloud Smart Network
      • Query Cloud Smart Network details
      • Query Cloud Smart Network instance list
      • Query the list of Cloud Smart Network
      • Update a Cloud Smart Network
    • Common Headers and Error Responses
    • General Description
    • Ingress Management Related Interfaces
      • Add a routing entry
      • Create affiliation
      • Create learning relationship
      • Delete a learning relationship
      • Delete a routing entry
      • Delete an association relationship
      • Query association relationships
      • Query learning relationships
      • Query route table list
      • Query routing entries
    • Interface Overview
    • Region Bandwidth Related Interfaces
      • Create cross-region bandwidth
      • Delete cross-region bandwidth
      • Query cross-region bandwidth
      • Query the cross-region bandwidth of the specified Cloud Smart Network
      • Update cross-region bandwidth
    • Service domain
    • TGW Related Interfaces
      • Query routing entries of a TGW
      • Query TGW list
      • Update TGW information
  • FAQs
    • Consultation
  • Function Release Records
  • Operation guide
    • Cross-Account Authorization Management
      • Cancel Authorized Network Instance
      • Create Authorized Network Instance
      • Delete Authorized Network Instance
      • View Authorized Network Instance
    • Cross-Region Bandwidth Package Management
    • CSN Instance
      • Create CSN Instance
      • Delete CSN Instance
      • Modify CSN Instance
    • Identity and access management
    • Monitor and Operations
      • CSN Instance Diagnosis
    • Network instance
      • Add Cross-Account Network Instance
      • Add Local Account Network Instance
      • Adjust Network Instance Bandwidth
      • Uninstall Network Instance
    • Region Bandwidth Management
      • Adjust Region Bandwidth
      • Create cross-region bandwidth
      • Delete cross-region bandwidth
    • Route management
      • Association Relationship
        • Create affiliation
        • Delete affiliation
      • Custom route tables
        • Create custom route table
        • Delete custom route table
        • View Custom Route Table
      • Learning Relationship
        • Add Custom Route Entry
        • Create learning relationship
        • Delete Custom Route Entry
        • Delete learning relationship
        • Publish and Revoke Network Instance Route
        • View Route Entry
    • Tag Management
  • Product Description
    • Application scenarios
    • Introduction
    • Usage restrictions
  • Product pricing
  • SDK
    • GO-SDK
      • Bandwidth package
      • CSN Instance
      • Exception handling
      • Initialization
      • Install
      • Overview
      • Region Bandwidth
      • Route management
      • TGW
    • Java-SDK
      • CSN
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Python-SDK
      • Bandwidth package
      • CSN Instance
      • Initialization
      • Region Bandwidth
      • Route management
      • TGW
  • Service Level Agreement (SLA)
    • Cloud Smart Network Service Level Agreement SLA
  • Typical Practices
    • CSN supports VPC custom route tables for secure traffic access
    • Multi-IDC Disaster Recovery via Cloud Smart Network
    • Multi-IDC Interconnection via Cloud Smart Network
    • Private Network VPC Interconnection with Edge Network
  • Document center
  • arrow
  • CSN
  • arrow
  • SDK
  • arrow
  • Python-SDK
  • arrow
  • Route management
Table of contents on this page
  • Create affiliation
  • Delete an association relationship
  • Query association relationships
  • Query route table list
  • Add a routing entry
  • Function declaration
  • Parameter meaning
  • Response value
  • Code example

Route management

Updated at:2025-11-11

Create affiliation

Function declaration

Plain Text
1def create_association(self, csn_rt_id, attach_id, description=None, client_token=None)

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/il13gbcn8

Response value
Operation succeeded:

Plain Text
1{}

Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym

Code example
For specific code examples, please refer to: example_resize_csn_bp.py

Delete an association relationship

Function declaration

Plain Text
1def delete_association(self, csn_rt_id=None, attach_id=None, client_token=None)

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/kl13gcb4h

Response value
Operation succeeded:

Plain Text
1{}

Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym

Code example
For specific code examples, please refer to: example_delete_association.py

Query association relationships

Function declaration

Plain Text
1list_association(self, csn_rt_id=None)

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/zl13gcrny

Response value
Operation succeeded:

Plain Text
1{
2    "associations":[
3        {
4            "attachId":"tgwAttach-kfdccn8a6pip0qd1",
5            "description":"desc",
6            "instanceId":"vpc-v3ku2mhsyxvn",
7            "instanceName":"test-03",
8            "instanceRegion":"bj",
9            "instanceType":"vpc",
10            "status":"active"
11        }
12    ]  
13}

Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym

Code example
For specific code examples, please refer to: example_list_association.py

Query route table list

Function declaration

Plain Text
1def list_route_table(self, csn_id, marker=None, max_keys=None)

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/hl13gm7x2

Response value
Operation succeeded:

Plain Text
1{
2    "marker": null,
3    "isTruncated": true,
4    "nextMarker": "csnBp-iuc756n5kkda",
5    "maxKeys": 1,
6    "csnRts": [
7         {
8            "csnRtId": "csn-rt-uezhhw306g5be3gb",
9            "name": "csnRtName",
10            "description": "desc",
11            "type": "default"
12        }
13    ]  
14}

Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym

Code example
For specific code examples, please refer to: example_list_routetable.py

Add a routing entry

Function declaration

Plain Text
1def create_route_rule(self, csn_rt_id, attach_id, destAddress, routeType="custom", client_token=None):

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Nl14d16n5

Usage example

Plain Text
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2 attach_id = "tgwAttach-n7yctm9zm605raig” # Identity ID of the network instance in Cloud Smart Network
3 destAddress = "0.0.0.0/0" # Destination address
4try:
5    resp = csn_client.create_route_rule(csn_rt_id=csn_rt_id, attach_id=attach_id,
6                                        destAddress=destAddress, client_token=str(uuid.uuid4()))
7    print("Create csn route rule response: %s" % resp)
8except BceHttpClientError as e:
9    print("Exception when calling api: %s" % e)

Response value
Operation succeeded:

Plain Text
1{
2}

Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_create_route_rule.py

Query routing entries

Function declaration

Plain Text
1def list_route_rule(self, csn_rt_id):

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/sl14d3at6

Usage example

Plain Text
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2try:
3    resp = csn_client.list_route_rule(csn_rt_id=csn_rt_id)
4    route_rules = resp.csnRtRules
5    print("List csn route rule response: %s" % resp)
6except BceHttpClientError as e:
7    print("Exception when calling api: %s" % e)

Response value
Operation succeeded:

Plain Text
1{
2    "nextMarker": "csnrr-IyWRn123",
3    "marker": "csnrr-IyWRnII7",
4    "maxKeys": 1,
5    "isTruncated": true,
6    "csnRtRules": [
7          {
8                "ruleId": "cnrr-1db26d78-1781",
9                "routeType": "propagated",
10                "csnId": "csn-m3dwj6tfysnmxmcy",
11                "csnRtId": "csnRt-w3x16fk8nr5kpxkx",
12                "description": null,
13                "fromAttachId": "tgwAttach-wg3z1z5baq3ry1a6",
14                "status": "conflicted",
15                "sourceAddress": null,
16                "destAddress": "192.168.0.0/20",
17                "nextHopId": "vpc-fh43ygs8yp0d",
18 "nextHopName": "Default Virtual Private Cloud",
19                "nextHopRegion": "su",
20                "nextHopType": "vpc",
21                "asPath": "",
22                "community": "",
23                "blackHole": false
24           }
25    ]
26}

Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_list_route_rule.py

Delete a routing entry

Function declaration

Plain Text
1func (c *Client) DeleteRouteRule(csnRtId string, csnRtRuleId string, clientToken string) error

Parameter meaning

Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Ll14d5a1d

Response value

Operation succeeded:

Plain Text
1{}

Operation failed: Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym

Code example

For specific code examples, please refer to: example_delete_route_rule.py

Create learning relationship

Function declaration

Plain Text
1def create_propagation(self, csn_rt_id, attach_id, description=None, client_token=None):

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Dl14cf0h1

Usage example

Plain Text
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2 attach_id = "tgwAttach-n7yctm9zm605raig” # Identity ID of the network instance in Cloud Smart Network
3try:
4    resp = csn_client.create_propagation(csn_rt_id=csn_rt_id, attach_id=attach_id, client_token=str(uuid.uuid4()))
5    print("Create csn propagation response: %s" % resp)
6except BceHttpClientError as e:
7    print("Exception when calling api: %s" % e)

Response value
Operation succeeded:

Plain Text
1{
2}

Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_create_propagation.py

Delete a learning relationship

Function declaration

Plain Text
1def delete_propagation(self, csn_rt_id, attach_id, client_token=None):

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/gl14cfnmj

Usage example

Plain Text
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2 attach_id = "tgwAttach-n7yctm9zm605raig” # Identity ID of the network instance in Cloud Smart Network
3try:
4    resp = csn_client.delete_propagation(csn_rt_id=csn_rt_id, attach_id=attach_id, client_token=str(uuid.uuid4()))
5    print("Delete csn propagation response: %s" % resp)
6except BceHttpClientError as e:
7    print("Exception when calling api: %s\n" % e)

Response value
Operation succeeded:

Plain Text
1{
2}

Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_delete_propagation.py

Query learning relationships

Function declaration

Plain Text
1def list_propagation(self, csn_rt_id):

Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/8l14cgbsf

Usage example

Plain Text
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2try:
3    resp = csn_client.list_propagation(csn_rt_id=csn_rt_id)
4    propagations = resp.propagations
5    print("List propagation response: %s" % propagations)
6except BceHttpClientError as e:
7    print("Exception when calling api: %s" % e)

Response value
Operation succeeded:

Plain Text
1{
2    "propagations":[
3        {
4            "attachId":"tgwAttach-kfdccn8a6pip0qd1",
5            "description":"default",
6            "instanceName":"test-03",
7            "instanceRegion":"bj",
8            "instanceId":"vpc-v3ku2mhsyxvn",
9            "instanceType":"vpc",
10            "status":"enable"
11        }
12    ]
13}

Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_list_propagation.py

Previous
Region Bandwidth
Next
TGW