EipBp实例
创建带宽包
- 带宽包仅支持绑定预付费资源,目前支持绑定弹性公网Eip和共享带宽
- name字段为可选参数,表示带宽包名称,不填写则自动生成。若填写要求以字母开头,只能包括数字、字母、及- _ . /中的特殊字符,长度不超过65个字符
- eip 和 eipGroup 字段分别表示待绑定资源的 Eip 的IP地址或共享带宽的 id,只能有一个字段生效,若都填写则仅有"eip"字段生效
- eip 只能是单独弹性公网实例的IP地址,不能是属于某个共享带宽资源的IP地址
- bandwidthInMbps字段表示带宽包的公网带宽,要求为大于0的整数,且该值与所绑定资源的带宽总和不大于200Mbps。若带宽包类型为跨境加速包,带宽包带宽值与所绑定的实例的默认跨境带宽之和要小于等于绑定实例的带宽值
- autoReleaseTime为可选参数,表示带宽包自动释放时间。如果设置要求时间格式符合UTC格式(格式形如:”2019-08-03T20:38:43Z”),该时间要介于当前时间和所绑定的预付费实例的到期时间之间,若不填写则随所绑定资源的到期一并释放
- type为可选参数,表示带宽包的类型,包括BandwidthPackage(带宽包)和AccelerationPackage(跨境加速包),其中跨境加速包仅支持中国香港区域,默认为包括BandwidthPackage
函数声明
1type CreateEipBpArgs struct {
2 Name string `json:"name"`
3 Eip string `json:"eip"`
4 EipGroupId string `json:"eipGroupId"`
5 BandwidthInMbps int `json:"bandwidthInMbps"`
6 Type string `json:"type"`
7 AutoReleaseTime string `json:"autoReleaseTime"`
8 ClientToken string `json:"-"`
9}
10
11type CreateEipBpResult struct {
12 Id string `json:"id"`
13}
14
15func (c *Client) CreateEipBp(args *CreateEipBpArgs) (*CreateEipBpResult, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/mk0m4ecrk
返回值
操作成功:
1{
2 "id":"bw-xxxxxxxx"
3}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_create_eipbp.go
调整带宽包带宽
- 调整带宽包的带宽大小
- bandwidthInMbps字段表示带宽包的公网带宽,要求为大于0的整数,且该值与所绑定资源的带宽总和不大于200Mbps
- 若带宽包类型为跨境加速包,带宽包带宽值与所绑定的实例的默认跨境带宽之和要小于等于绑定实例的带宽值
函数声明
1type ResizeEipBpArgs struct {
2 BandwidthInMbps int `json:"bandwidthInMbps"`
3 ClientToken string `json:"-"`
4}
5
6func (c *Client) ResizeEipBp(id string, args *ResizeEipBpArgs) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Yk0m4k7im
返回值
操作成功:
无特殊返回参数
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_resize_eipbp.go
查询带宽包详情
- 根据带宽包id查询指定带宽包资源的详细信息
函数声明
1type EipBpDetail struct {
2 Name string `json:"name"`
3 Id string `json:"id"`
4 BindType string `json:"bindType"`
5 BandwidthInMbps int `json:"bandwidthInMbps"`
6 InstanceId string `json:"instanceId"`
7 Eips []string `json:"eips"`
8 InstanceBandwidthInMbps int `json:"instanceBandwidthInMbps"`
9 CreateTime string `json:"createTime"`
10 AutoReleaseTime string `json:"autoReleaseTime"`
11 Type string `json:"type"`
12 Region string `json:"region"`
13}
14
15func (c *Client) GetEipBp(id, clientToken string) (*EipBpDetail, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/hk0m4uwtc
返回值
操作成功:
1{
2 "name": "xxxxx",
3 "id": "bw-xxxxxxxx",
4 "bindType": "eip",
5 "bandwidthInMbps": 199,
6 "instanceId": "ip-xxxxxxxx",
7 "eips": [
8 "x.x.x.x"
9 ],
10 "instanceBandwidthInMbps": 1,
11 "createTime": "2023-11-29T11:29:54Z",
12 "autoReleaseTime": "2023-12-29T08:09:54Z",
13 "type": "BandwidthPackage",
14 "region": "bj"
15}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_get_eipbp.go
查询用户带宽包列表信息
- 查询用户账户下所有带宽包的信息
- 支持按带宽包的id、name、bindType进行查询
- 返回结果是多重查询条件的交集
- 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定
函数声明
1type ListEipBpArgs struct {
2 Id string `json:"id"`
3 Name string `json:"name"`
4 Marker string `json:"marker"`
5 MaxKeys int `json:"maxKeys"`
6 BindType string `json:"bindType"`
7 Type string `json:"type"`
8}
9
10type ListEipBpResult struct {
11 Marker string `json:"marker"`
12 MaxKeys int `json:"maxKeys"`
13 NextMarker string `json:"nextMarker"`
14 IsTruncated bool `json:"isTruncated"`
15 EipGroup []EipBpList `json:"bpList"`
16}
17
18type EipBpList struct {
19 Name string `json:"name"`
20 Id string `json:"id"`
21 BindType string `json:"bindType"`
22 BandwidthInMbps int `json:"bandwidthInMbps"`
23 InstanceId string `json:"instanceId"`
24 Eips []string `json:"eips"`
25 CreateTime string `json:"createTime"`
26 AutoReleaseTime string `json:"autoReleaseTime"`
27 Type string `json:"type"`
28 Region string `json:"region"`
29}
30
31func (c *Client) ListEipBp(args *ListEipBpArgs) (*ListEipBpResult, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Lk0m4n7yr
返回值
操作成功:
1{
2 "marker": "bw-xxxxxxxx",
3 "maxKeys": 1000,
4 "nextMarker": "",
5 "isTruncated": false,
6 "bpList": [
7 {
8 "name": "test_eip_bp",
9 "id": "bw-xxxxxxxx",
10 "bindType": "eip",
11 "bandwidthInMbps": 10,
12 "instanceId": "ip-xxxxxxxx",
13 "eips": [
14 "x.x.x.x",
15 ...
16 ],
17 "createTime": "2023-11-24T09:46:26Z",
18 "autoReleaseTime": "2023-12-30T16:45:00Z",
19 "type": "BandwidthPackage",
20 "region": "bj"
21 },
22 ...
23 ]
24}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_list_eipbp.go
更新带宽包自动释放时间
- 更新带宽包的自动释放时间
- autoReleaseTime 表示自动释放时间,要求时间格式符合UTC格式(格式形如:”2019-08-03T20:38:43Z”),该时间要介于当前时间和所绑定的预付费实例的到期时间之间
函数声明
1type UpdateEipBpAutoReleaseTimeArgs struct {
2 AutoReleaseTime string `json:"autoReleaseTime"`
3 ClientToken string `json:"-"`
4}
5
6func (c *Client) UpdateEipBpAutoReleaseTime(id string, args *UpdateEipBpAutoReleaseTimeArgs) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Fk0m4mb1h
返回值
操作成功:
无特殊返回参数
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_update_eipbp_autoreleasetime.go
更新带宽包名称
- 更新带宽包的名称
- name字段要求以字母开头,只能包括数字、字母、及- _ . /中的特殊字符,长度不超过65个字符
函数声明
1type UpdateEipBpNameArgs struct {
2 Name string `json:"name"`
3 ClientToken string `json:"-"`
4}
5
6func (c *Client) UpdateEipBpName(id string, args *UpdateEipBpNameArgs) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/lk0m4lk6d
返回值
操作成功:
无特殊返回参数
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_update_eipbp_name.go
释放带宽包
- 根据带宽包id释放指定的带宽包资源
函数声明
1func (c *Client) DeleteEipBp(id, clientToken string) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/4k0m4hayt
返回值
操作成功:
无特殊返回参数
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_eipbp_delete_eipbp.go