Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge branch 'feat/tenant' into 'master'
Browse files Browse the repository at this point in the history
Feat/tenant

See merge request sdk/authing-golang-sdk!9
  • Loading branch information
罗杰林 committed Dec 17, 2021
2 parents adca890 + 4443d07 commit 11a6799
Show file tree
Hide file tree
Showing 9 changed files with 1,096 additions and 5 deletions.
24 changes: 23 additions & 1 deletion lib/management/application_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package management
import (
"errors"
"fmt"
"net/http"

"github.com/Authing/authing-go-sdk/lib/constant"
"github.com/Authing/authing-go-sdk/lib/model"
jsoniter "github.com/json-iterator/go"
"net/http"
)

// ListApplication
Expand Down Expand Up @@ -278,3 +279,24 @@ func (c *Client) SortApplicationAgreement(appId string, ids []string) (*string,
}
return &resp.Message, nil
}

// ApplicationTenants
// 获取应用关联租户
func (c *Client) ApplicationTenants(appId string) (*model.ApplicationTenantDetails, error) {

url := fmt.Sprintf("%s/api/v2/application/%v/tenants", c.Host, appId)
b, err := c.SendHttpRestRequest(url, http.MethodGet, nil)
if err != nil {
return nil, err
}
resp := &struct {
Message string `json:"message"`
Code int64 `json:"code"`
Data model.ApplicationTenantDetails `json:"data"`
}{}
jsoniter.Unmarshal(b, &resp)
if resp.Code != 200 {
return nil, errors.New(resp.Message)
}
return &resp.Data, nil
}
13 changes: 12 additions & 1 deletion lib/management/application_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package management

import (
"fmt"
"github.com/Authing/authing-go-sdk/lib/model"
"log"
"testing"

"github.com/Authing/authing-go-sdk/lib/model"
)

func TestClient_ListApplication(t *testing.T) {
Expand Down Expand Up @@ -123,3 +124,13 @@ func TestClient_SortApplicationAgreement(t *testing.T) {
}
log.Printf("%+v\n", resp)
}

func TestClient_ApplicationTenants(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========获取应用关联租户==========")
resp, err := client.ApplicationTenants("61b8366efa768b57d65b6394")
if err != nil {
fmt.Println(err)
}
log.Printf("%+v\n", resp)
}
Loading

0 comments on commit 11a6799

Please sign in to comment.