路由管理
添加路由条目
函数声明
func (c *Client) CreateRouteRule(csnRtId string, body *CreateRouteRuleRequest,
clientToken string) error
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/Nl14d16n5
使用示例
args := &csn.CreateRouteRuleRequest{
AttachId: "tgwAttach-rvu8tkaubphb78eg",
DestAddress: "0.0.0.0/0",
RouteType: "custom",
}
err := client.CreateRouteRule(csnRtId, args, clientToken) // 创建路由规则
返回值
操作成功:
{}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_create_route_rule.go
查询路由条目
函数声明
func (c *Client) ListRouteRule(csnRtId string, listRouteRuleArgs *ListRouteRuleArgs)
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/sl14d3at6
使用示例
csnRtId := "xxxxx" //云智能网路由表的ID
args := &csn.ListRouteRuleArgs{}
response, err := client.ListRouteRule(csnRtId, args)
返回值
操作成功:
{
"nextMarker": "csnrr-IyWRn123",
"marker": "csnrr-IyWRnII7",
"maxKeys": 1,
"isTruncated": true,
"csnRtRules": [
{
"ruleId": "cnrr-1db26d78-1781",
"routeType": "propagated",
"csnId": "csn-m3dwj6tfysnmxmcy",
"csnRtId": "csnRt-w3x16fk8nr5kpxkx",
"description": null,
"fromAttachId": "tgwAttach-wg3z1z5baq3ry1a6",
"status": "conflicted",
"sourceAddress": null,
"destAddress": "192.168.0.0/20",
"nextHopId": "vpc-fh43ygs8yp0d",
"nextHopName": "默认私有网络",
"nextHopRegion": "su",
"nextHopType": "vpc",
"asPath": "",
"community": "",
"blackHole": false
}
]
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_list_route_rule.go
删除路由条目
函数声明
func (c *Client) DeleteRouteRule(csnRtId string, csnRtRuleId string, clientToken string) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/Ll14d5a1d
返回值
操作成功:
{}
操作失败: 返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_delete_routerule.go
创建学习关系
函数声明
func (c *Client) CreatePropagation(csnRtId string, body *CreatePropagationRequest,
clientToken string) error
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/Dl14cf0h1
使用示例
clientToken := util.NewUUID() //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性
desc := "desc"
args := &csn.CreatePropagationRequest{
AttachId: "tgwAttach-uff0gvjkis95f6xg",
Description: &desc,
}
err := client.CreatePropagation(csnRtId, args, clientToken) // 创建学习关系
返回值
操作成功:
{
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_create_propagation.go
删除学习关系
函数声明
func (c *Client) DeletePropagation(csnRtId string, attachId string, clientToken string) error
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/gl14cfnmj
使用示例
csnRtId := "xxxx" //云智能网路由表的ID
attachId := "tgwAttach-xxxx" //网络实例在云智能网中的身份ID
clientToken := util.NewUUID() //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性
err := client.DeletePropagation(csnRtId, attachId, clientToken) // 删除学习关系
返回值
操作成功:
{
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_delete_propagation.go
查询学习关系
函数声明
func (c *Client) ListPropagation(csnRtId string) (*ListPropagationResponse, error)
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/8l14cgbsf
使用示例
csnRtId := "xxxxx" //云智能网路由表的ID
response, err := client.ListPropagation(csnRtId)
返回值
操作成功:
{
"propagations":[
{
"attachId":"tgwAttach-kfdccn8a6pip0qd1",
"description":"default",
"instanceName":"test-03",
"instanceRegion":"bj",
"instanceId":"vpc-v3ku2mhsyxvn",
"instanceType":"vpc",
"status":"enable"
}
]
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_list_propagation.go
创建关联关系
函数声明
func CreateAssociation(cli bce.Client, csnRtId string, body *CreateAssociationRequest, clientToken string) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/il13gbcn8
返回值
操作成功:
{}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_create_association.go
删除关联关系
函数声明
func DeleteAssociation(cli bce.Client, csnRtId string, attachId string, clientToken string) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/kl13gcb4h
返回值
操作成功:
{}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_delete_association.go
查询关联关系
函数声明
func ListAssociation(cli bce.Client, csnRtId string) (*ListAssociationResponse, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/zl13gcrny
返回值
操作成功:
{
"associations":[
{
"attachId":"tgwAttach-kfdccn8a6pip0qd1",
"description":"desc",
"instanceId":"vpc-v3ku2mhsyxvn",
"instanceName":"test-03",
"instanceRegion":"bj",
"instanceType":"vpc",
"status":"active"
}
]
}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_list_association.go
查询路由表列表
函数声明
func ListRouteTable(cli bce.Client, csnId string, listRouteTableArgs *ListRouteTableArgs) (
*ListRouteTableResponse, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/hl13gm7x2
返回值
操作成功:
{
"marker": null,
"isTruncated": true,
"nextMarker": "csnBp-iuc756n5kkda",
"maxKeys": 1,
"csnRts": [
{
"csnRtId": "csn-rt-uezhhw306g5be3gb",
"name": "csnRtName",
"description": "desc",
"type": "default"
}
]
}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_list_route_table.go