Route management
Add a routing entry
Function declaration
1func (c *Client) CreateRouteRule(csnRtId string, body *CreateRouteRuleRequest,
2 clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Nl14d16n5
Usage example
1args := &csn.CreateRouteRuleRequest{
2 AttachId: "tgwAttach-rvu8tkaubphb78eg",
3 DestAddress: "0.0.0.0/0",
4 RouteType: "custom",
5}
6 err := client.CreateRouteRule(csnRtId, args, clientToken) // Create a routing rule
Response value
Operation succeeded:
1{}
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.go
Query routing entries
Function declaration
1func (c *Client) ListRouteRule(csnRtId string, listRouteRuleArgs *ListRouteRuleArgs)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/sl14d3at6
Usage example
1csnRtId := "xxxxx" //ID of the Cloud Smart Network route table
2args := &csn.ListRouteRuleArgs{}
3response, err := client.ListRouteRule(csnRtId, args)
Response value
Operation succeeded:
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.go
Delete a routing entry
Function declaration
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:
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_routerule.go
Create learning relationship
Function declaration
1func (c *Client) CreatePropagation(csnRtId string, body *CreatePropagationRequest,
2 clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Dl14cf0h1
Usage example
1clientToken := util.NewUUID() //Idempotency token: an ASCII string with a length not exceeding 64 characters. For details, see ClientToken Idempotency
2desc := "desc"
3args := &csn.CreatePropagationRequest{
4 AttachId: "tgwAttach-uff0gvjkis95f6xg",
5 Description: &desc,
6}
7 err := client.CreatePropagation(csnRtId, args, clientToken) // Create a learning relationship
Response value
Operation succeeded:
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.go
Delete a learning relationship
Function declaration
1func (c *Client) DeletePropagation(csnRtId string, attachId string, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/gl14cfnmj
Usage example
1csnRtId := "xxxx" //ID of the Cloud Smart Network route table
2 attachId := "tgwAttach-xxxx" //Identity ID of the network instance in Cloud Smart Network
3 clientToken := util.NewUUID() //Idempotency token: an ASCII string with a length not exceeding 64 characters. For details, see ClientToken Idempotency
4 err := client.DeletePropagation(csnRtId, attachId, clientToken) // Delete a learning relationship
Response value
Operation succeeded:
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.go
Query learning relationships
Function declaration
1func (c *Client) ListPropagation(csnRtId string) (*ListPropagationResponse, error)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/8l14cgbsf
Usage example
1csnRtId := "xxxxx" //ID of the Cloud Smart Network route table
2response, err := client.ListPropagation(csnRtId)
Response value
Operation succeeded:
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.go
Create affiliation
Function declaration
1func (c *Client) CreateAssociation(csnRtId string, body *CreateAssociationRequest, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/il13gbcn8
Response value
Operation succeeded:
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, refer to: example_create_association.go
Delete an association relationship
Function declaration
1func (c *Client) DeleteAssociation(csnRtId string, attachId string, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/kl13gcb4h
Response value
Operation succeeded:
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.go
Query association relationships
Function declaration
1func (c *Client) ListAssociation(csnRtId string) (*ListAssociationResponse, error)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/zl13gcrny
Response value
Operation succeeded:
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.go
Query route table list
Function declaration
1func ListRouteTable(cli bce.Client, csnId string, listRouteTableArgs *ListRouteTableArgs) (
2 *ListRouteTableResponse, error)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/hl13gm7x2
Response value
Operation succeeded:
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_route_table.go
