-
Notifications
You must be signed in to change notification settings - Fork 71
/
example_create_eni.go
53 lines (47 loc) · 1.35 KB
/
example_create_eni.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package eniexamples
import (
"fmt"
"github.com/baidubce/bce-sdk-go/model"
"github.com/baidubce/bce-sdk-go/services/eni"
"github.com/baidubce/bce-sdk-go/util"
)
func getClientToken() string {
return util.NewUUID()
}
func CreateEni() {
// 初始化AK/SK/Endpoint
ak, sk, endpoint := "Your AK", "Your SK", "Your Endpoint"
ENI_CLIENT, _ := eni.NewClient(ak, sk, endpoint) // 初始化client
createEniArgs := &eni.CreateEniArgs{
ClientToken: getClientToken(),
Name: "GO_SDK_TEST_CREATE", // 弹性网卡名称
SubnetId: "sbn-d63m7t0bbwt5", // 子网ID
SecurityGroupIds: []string{ // 安全组ID列表
"g-92600fd1grhr", // 安全组ID
},
PrivateIpSet: []eni.PrivateIp{ // 弹性网卡内网IP列表
{
Primary: true, // 弹性网卡内网IP是否为主IP
PrivateIpAddress: "10.0.1.108", // 弹性网卡内网IP
},
},
Ipv6PrivateIpSet: []eni.PrivateIp{ // 弹性网卡内网IPv6列表
{
Primary: false, // 弹性网卡内网IPv6是否为主IP
PrivateIpAddress: "", // 弹性网卡内网IPv6
},
},
Tags: []model.TagModel{
{
TagKey: "tagKey",
TagValue: "tagValue",
},
},
Description: "go sdk test: create eni", // 弹性网卡描述
}
response, err := ENI_CLIENT.CreateEni(createEniArgs) // 创建eni
if err != nil {
panic(err)
}
fmt.Println(response)
}