From 8e31a4d0eeccabc8f84245231f2e0dbaef77fbb5 Mon Sep 17 00:00:00 2001 From: duanliguo Date: Wed, 9 Aug 2023 10:32:49 +0800 Subject: [PATCH] Add features in bcc --- bce/config.go | 2 +- doc/BCC.md | 3 +++ services/bbc/model.go | 2 +- services/bcc/api/keypair.go | 4 +++- services/bcc/api/model.go | 1 + services/bcc/client_test.go | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bce/config.go b/bce/config.go index 8d0d34da..bd2d3771 100644 --- a/bce/config.go +++ b/bce/config.go @@ -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" diff --git a/doc/BCC.md b/doc/BCC.md index 4ca96fb8..76396a54 100644 --- a/doc/BCC.md +++ b/doc/BCC.md @@ -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) diff --git a/services/bbc/model.go b/services/bbc/model.go index d4c9effe..f5ae1f89 100644 --- a/services/bbc/model.go +++ b/services/bbc/model.go @@ -977,4 +977,4 @@ type BbcStock struct { type ListInstanceByInstanceIdArgs struct { InstanceIds []string `json:"instanceIdList"` -} \ No newline at end of file +} diff --git a/services/bcc/api/keypair.go b/services/bcc/api/keypair.go index 78d1741f..1d908c13 100644 --- a/services/bcc/api/keypair.go +++ b/services/bcc/api/keypair.go @@ -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") } diff --git a/services/bcc/api/model.go b/services/bcc/api/model.go index 23c47612..a6ab29bf 100644 --- a/services/bcc/api/model.go +++ b/services/bcc/api/model.go @@ -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 { diff --git a/services/bcc/client_test.go b/services/bcc/client_test.go index cf7f0443..a7a84de1 100644 --- a/services/bcc/client_test.go +++ b/services/bcc/client_test.go @@ -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)