diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bf76ab..1f0aa51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # vNext + +# Release 2.0.0 +- 新增app授权和撤销授权功能 - Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN - 日志搜索结果添加CollectedAtNano字段 +- 添加 GetWebProxy 方法 # Release 1.2.0 - 添加禁用/启用AP端口的API,并在查看/搜索AP的API返回的端口信息中返回端口的启用状态(启用/禁用)。 diff --git a/kirksdk/account_client.go b/kirksdk/account_client.go index 73b8b7a..02d6d72 100644 --- a/kirksdk/account_client.go +++ b/kirksdk/account_client.go @@ -138,13 +138,13 @@ func (p *accountClientImp) UpdateAlertMethod(ctx context.Context, appURI string, } func (p *accountClientImp) CreateAppGrant(ctx context.Context, appURI, username string) (err error) { - url := fmt.Sprintf("%s%s/apps/%s/grant/%s", p.host, appVersionPrefix, appURI, username) + url := fmt.Sprintf("%s%s/apps/%s/grants/%s", p.host, appVersionPrefix, appURI, username) err = p.client.Call(ctx, nil, "PUT", url) return } func (p *accountClientImp) DeleteAppGrant(ctx context.Context, appURI, username string) (err error) { - url := fmt.Sprintf("%s%s/apps/%s/grant/%s", p.host, appVersionPrefix, appURI, username) + url := fmt.Sprintf("%s%s/apps/%s/grants/%s", p.host, appVersionPrefix, appURI, username) err = p.client.Call(ctx, nil, "DELETE", url) return } diff --git a/kirksdk/kirksdk.go b/kirksdk/kirksdk.go index aaa479b..a4cf6fd 100644 --- a/kirksdk/kirksdk.go +++ b/kirksdk/kirksdk.go @@ -1,3 +1,3 @@ package kirksdk -const Version = "1.2.0" +const Version = "2.0.0" diff --git a/kirksdk/qcos_api.go b/kirksdk/qcos_api.go index 1360f91..1abcbf3 100644 --- a/kirksdk/qcos_api.go +++ b/kirksdk/qcos_api.go @@ -333,6 +333,9 @@ type QcosClient interface { // DELETE /v3/configservices/<namespace> DeleteConfigServiceSpec(ctx context.Context, namespace string) (err error) + + // POST /v3/webproxy + GetWebProxy(ctx context.Context, args GetWebProxyArgs) (ret WebProxyInfo, err error) } const ( @@ -931,3 +934,12 @@ type UpdateConfigServiceSpecArgs struct { Vars map[string]interface{} `json:"vars"` Listvars []map[string]interface{} `json:"listvars"` } + +type GetWebProxyArgs struct { + Backend string `json:"backend"` +} + +type WebProxyInfo struct { + Backend string `json:"backend"` + OneTimeURL string `json:"oneTimeUrl"` +} diff --git a/kirksdk/qcos_client.go b/kirksdk/qcos_client.go index 8514548..cb0e498 100644 --- a/kirksdk/qcos_client.go +++ b/kirksdk/qcos_client.go @@ -1319,6 +1319,13 @@ func (p *qcosClientImp) DeleteConfigServiceSpec(ctx context.Context, namespace s return } +// POST /v3/webproxy +func (p *qcosClientImp) GetWebProxy(ctx context.Context, args GetWebProxyArgs) (ret WebProxyInfo, err error) { + url := fmt.Sprintf("%s/v3/webproxy", p.host) + err = p.client.CallWithJson(ctx, &ret, "POST", url, args) + return +} + func (p *qcosClientImp) wait4StackRunning(stackName string, timeout time.Duration) (err error) { if stackName == "" { stackName = DefaultStack diff --git a/kirksdk/qcos_client_test.go b/kirksdk/qcos_client_test.go index f733264..6781389 100644 --- a/kirksdk/qcos_client_test.go +++ b/kirksdk/qcos_client_test.go @@ -645,3 +645,36 @@ func TestUpdateJob(t *testing.T) { err := client.UpdateJob(context.TODO(), "default", args) assert.NoError(t, err) } + +func TestGetWebproxy(t *testing.T) { + expectedUrl := "/v3/webproxy" + expectedMethod := "POST" + expectedBody := `{"backend":"10.128.0.1:8080"}` + returnBody := `{ + "backend": "10.128.0.1:8080", + "oneTimeUrl": "http://dummy.com" +}` + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, expectedUrl, r.URL.Path) + assert.Equal(t, expectedMethod, r.Method) + body, err := ioutil.ReadAll(r.Body) + assert.NoError(t, err) + assert.Equal(t, expectedBody, string(body)) + fmt.Fprintln(w, returnBody) + })) + defer ts.Close() + + client := NewQcosClient(QcosConfig{ + Host: ts.URL, + }) + + args := GetWebProxyArgs{ + Backend: "10.128.0.1:8080", + } + + webproxy, err := client.GetWebProxy(context.TODO(), args) + assert.NoError(t, err) + assert.Equal(t, "10.128.0.1:8080", webproxy.Backend) + assert.Equal(t, "http://dummy.com", webproxy.OneTimeURL) +}