-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,496 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
examples/cce/cluster/example_upate_cluster_forbiddelete.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cluster | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
ccev2 "github.com/baidubce/bce-sdk-go/services/cce/v2" | ||
) | ||
|
||
func UpdateClusterForbidDelete() { | ||
// 用户的Access Key ID和Secret Access Key | ||
AK, SK := "", "" | ||
|
||
// 用户指定的endpoint | ||
ENDPOINT := "" | ||
|
||
// 初始化一个CCEClient | ||
ccev2Client, err := ccev2.NewClient(AK, SK, ENDPOINT) | ||
if err != nil { | ||
panic(err) | ||
} | ||
clusterID := "" | ||
args := &ccev2.UpdateClusterForbidDeleteArgs{ | ||
ClusterID: clusterID, | ||
UpdateClusterForbidDeleteRequest: ccev2.UpdateClusterForbidDeleteRequest{ | ||
ForbidDelete: true, | ||
}, | ||
} | ||
|
||
resp, err := ccev2Client.UpdateClusterForbidDelete(args) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
|
||
s, _ := json.MarshalIndent(resp, "", "\t") | ||
fmt.Println("Response:" + string(s)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package etexamples | ||
|
||
import ( | ||
"fmt" | ||
"github.com/baidubce/bce-sdk-go/services/et" | ||
"github.com/baidubce/bce-sdk-go/util" | ||
) | ||
|
||
func getClientToken() string { | ||
return util.NewUUID() | ||
} | ||
|
||
// AssociateEtChannel | ||
func AssociateEtChannel() { | ||
client, err := et.NewClient("Your AK", "Your SK", "bcc.bj.baidubce.com") | ||
if err != nil { | ||
fmt.Printf("Failed to new et client, err: %v.\n", err) | ||
return | ||
} | ||
|
||
args := &et.AssociateEtChannelArgs{ | ||
ClientToken: getClientToken(), // client token | ||
EtId: "Your EtId", // et id | ||
EtChannelId: "Your EtChannelId", // et channel id | ||
ExtraChannelId: "Your ExtraChannelId", // extra channel id | ||
} | ||
|
||
if err := client.AssociateEtChannel(args); err != nil { | ||
fmt.Printf("Failed to associate et channel, err: %v.\n", err) | ||
return | ||
} | ||
fmt.Println("Successfully associate et channel.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package etexamples | ||
|
||
import ( | ||
"fmt" | ||
"github.com/baidubce/bce-sdk-go/services/et" | ||
"github.com/baidubce/bce-sdk-go/util" | ||
) | ||
|
||
func getClientToken() string { | ||
return util.NewUUID() | ||
} | ||
|
||
// DisAssociateEtChannel | ||
func DisAssociateEtChannel() { | ||
client, err := et.NewClient("Your AK", "Your SK", "bcc.bj.baidubce.com") | ||
if err != nil { | ||
fmt.Printf("Failed to new et client, err: %v.\n", err) | ||
return | ||
} | ||
|
||
args := &et.DisAssociateEtChannelArgs{ | ||
ClientToken: getClientToken(), // client token | ||
EtId: "Your EtId", // et id | ||
EtChannelId: "Your EtChannelId", // et channel id | ||
ExtraChannelId: "Your ExtraChannelId", // extra channel id | ||
} | ||
|
||
if err := client.DisAssociateEtChannel(args); err != nil { | ||
fmt.Printf("Failed to disassociate et channel, err: %v.\n", err) | ||
return | ||
} | ||
fmt.Println("Successfully disassociate et channel.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func AddIpAddressToIpSet() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
addIpAddress2IpSetArgs := &vpc.AddIpAddress2IpSetArgs{ | ||
ClientToken: clientToken, | ||
IpAddressInfo: []vpc.TemplateIpAddressInfo{ // 添加的IP地址信息,其ipVersion需与指定的IP地址组保持一致,单次最多指定10个 | ||
{IpAddress: "192.168.11.0/24", Description: "test1"}, | ||
{IpAddress: "192.168.12.0/24", Description: "test2"}, | ||
}, | ||
} | ||
ipSetID := "ips-2etsti1g24hv" | ||
err := client.AddIpAddress2IpSet(ipSetID, addIpAddress2IpSetArgs) // IP地址组添加IP地址 | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func AddIpSetToIpGroup() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
addIpSetToIpGroupArgs := &vpc.AddIpSet2IpGroupArgs{ | ||
ClientToken: clientToken, | ||
IpSetIds: []string{ // 关联的IP地址组ID,其ipVersion需与指定的IP地址族一致,单次最多指定5个 | ||
"ips-5eekehr75vbv", | ||
"ips-vn4nfjau2t2u", | ||
}, | ||
} | ||
ipGroupID := "ipg-9vd6xtyjz0in" | ||
err := client.AddIpSet2IpGroup(ipGroupID, addIpSetToIpGroupArgs) // IP地址族添加IP地址组 | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func CreateIpGroup() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
createIpGroupArgs := &vpc.CreateIpGroupArgs{ | ||
ClientToken: clientToken, | ||
Name: "test_create_ip_set", // IP地址族的名称 | ||
IpVersion: "IPv4", // ipVersion,取值IPv4或IPv6 | ||
IpSetIds: []string{ // 关联的IP地址组ID,其ipVersion需与本次创建的IP地址族一致,单次最多指定5个 | ||
"ips-z2a8uk9qnkc1", | ||
"ips-hms1n8fu184f", | ||
}, | ||
Description: "this is a test", //IP地址族描述 | ||
} | ||
|
||
response, err := client.CreateIpGroup(createIpGroupArgs) | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func CreateIpSet() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
createIpSetArgs := &vpc.CreateIpSetArgs{ | ||
ClientToken: clientToken, | ||
Name: "test_create_ip_set", // IP地址组的名称 | ||
IpVersion: "IPv4", // ipVersion,取值IPv4或IPv6 | ||
IpAddressInfo: []vpc.TemplateIpAddressInfo{ // 参数模板IP地址信息,单次最多指定10个 | ||
{IpAddress: "192.168.11.0/24", Description: "test1"}, | ||
{IpAddress: "192.168.12.0/24", Description: "test2"}, | ||
}, | ||
Description: "this is a test", // IP地址组描述 | ||
} | ||
|
||
response, err := client.CreateIpSet(createIpSetArgs) // 创建IP地址组 | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func DelIpAddress() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
delIpAddressArgs := &vpc.DelIpAddressArgs{ | ||
ClientToken: clientToken, | ||
IpAddressInfo: []string{ | ||
"192.168.11.0/24", | ||
"192.168.12.0/24", | ||
}, | ||
} | ||
IpSetID := "ips-2etsti1g24hv" | ||
err := client.DelIpAddress(IpSetID, delIpAddressArgs) // 创建vpc | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func DelIpSet() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
delIpSetArgs := &vpc.DelIpSetArgs{ | ||
ClientToken: clientToken, | ||
} | ||
IpSetID := "ips-2etsti1g24hv" | ||
err := client.DelIpSet(IpSetID, delIpSetArgs) // 创建vpc | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package vpcexamples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/baidubce/bce-sdk-go/services/vpc" | ||
) | ||
|
||
func DeleteIpAddress() { | ||
ak, sk, endpoint := "Your Ak", "Your Sk", "Your endpoint" // 初始化ak, sk和endpoint | ||
client, _ := vpc.NewClient(ak, sk, endpoint) // 初始化client | ||
clientToken := "c587aab8-cc6d-4e36-a7a6-b78339b1469f" //幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性支持。 | ||
deleteIpAddressArgs := &vpc.DeleteIpAddressArgs{ | ||
ClientToken: clientToken, | ||
IpAddressInfo: []string{ // 删除的IP地址信息,单次最多指定10个 | ||
"192.168.11.0/24", | ||
"192.168.12.0/24", | ||
}, | ||
} | ||
ipSetID := "ips-2etsti1g24hv" | ||
err := client.DeleteIpAddress(ipSetID, deleteIpAddressArgs) // IP地址组删除IP地址 | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |
Oops, something went wrong.