Skip to content

Commit

Permalink
Add features in bcc
Browse files Browse the repository at this point in the history
  • Loading branch information
duanliguo committed Aug 9, 2023
1 parent 1358734 commit 8e31a4d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bce/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

// Constants and default values for the package bce
const (
SDK_VERSION = "0.9.154"
SDK_VERSION = "0.9.155"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"
Expand Down
3 changes: 3 additions & 0 deletions doc/BCC.md
Original file line number Diff line number Diff line change
Expand Up @@ -3266,10 +3266,13 @@ if res, err := bccClient.GetKeypairDetail(keypairId); err != nil {
marker := "your-marker"
// 每页包含的最大数量,最大数量通常不超过1000。缺省值为1000,可选参数
maxKeys := your-maxKeys
// 根据name过滤keypair列表,返回精确匹配结果
name := "your-keyPairName"

args := &api.ListKeypairArgs{
Marker marker,
MaxKeys maxKeys,
Name name,
}
if res, err := bccClient.ListKeypair(args); err != nil {
fmt.Println("get keypair list failed: ", err)
Expand Down
2 changes: 1 addition & 1 deletion services/bbc/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,4 +977,4 @@ type BbcStock struct {

type ListInstanceByInstanceIdArgs struct {
InstanceIds []string `json:"instanceIdList"`
}
}
4 changes: 3 additions & 1 deletion services/bcc/api/keypair.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ func ListKeypairs(cli bce.Client, queryArgs *ListKeypairArgs) (*ListKeypairResul
if queryArgs.MaxKeys != 0 {
req.SetParam("maxKeys", strconv.Itoa(queryArgs.MaxKeys))
}
if len(queryArgs.Name) != 0 {
req.SetParam("name", queryArgs.Name)
}
}

if queryArgs == nil || queryArgs.MaxKeys == 0 {
req.SetParam("maxKeys", "1000")
}
Expand Down
1 change: 1 addition & 0 deletions services/bcc/api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,7 @@ type DeleteKeypairArgs struct {
type ListKeypairArgs struct {
Marker string `json:"marker"`
MaxKeys int `json:"maxKeys"`
Name string `json:"name,omitempty"`
}

type ListKeypairResult struct {
Expand Down
1 change: 1 addition & 0 deletions services/bcc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ func TestListKeypairs(t *testing.T) {
args := &api.ListKeypairArgs{
Marker: "",
MaxKeys: 0,
Name: "ac",
}
if res, err := BCC_CLIENT.ListKeypairs(args); err != nil {
fmt.Println("Get specific instance eni failed: ", err)
Expand Down

0 comments on commit 8e31a4d

Please sign in to comment.