mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-26 16:01:56 +08:00
merge
This commit is contained in:
@@ -6,6 +6,9 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
application_authorization "github.com/APIParkLab/APIPark/module/application-authorization"
|
||||
application_authorization_dto "github.com/APIParkLab/APIPark/module/application-authorization/dto"
|
||||
|
||||
"github.com/APIParkLab/APIPark/model/plugin_model"
|
||||
"github.com/APIParkLab/APIPark/service/api"
|
||||
|
||||
@@ -271,7 +274,8 @@ func (i *imlServiceController) SaveServiceDoc(ctx *gin.Context, id string, input
|
||||
}
|
||||
|
||||
type imlAppController struct {
|
||||
module service.IAppModule `autowired:""`
|
||||
module service.IAppModule `autowired:""`
|
||||
authModule application_authorization.IAuthorizationModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlAppController) Search(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.AppItem, error) {
|
||||
@@ -279,7 +283,25 @@ func (i *imlAppController) Search(ctx *gin.Context, teamId string, keyword strin
|
||||
}
|
||||
|
||||
func (i *imlAppController) CreateApp(ctx *gin.Context, teamID string, input *service_dto.CreateApp) (*service_dto.App, error) {
|
||||
return i.module.CreateApp(ctx, teamID, input)
|
||||
app, err := i.module.CreateApp(ctx, teamID, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = i.authModule.AddAuthorization(ctx, app.Id, &application_authorization_dto.CreateAuthorization{
|
||||
Name: "Default API Key",
|
||||
Driver: "apikey",
|
||||
Position: "Header",
|
||||
TokenName: "Authorization",
|
||||
ExpireTime: 0,
|
||||
Config: map[string]interface{}{
|
||||
"apikey": uuid.New().String(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
i.module.DeleteApp(ctx, app.Id)
|
||||
return nil, err
|
||||
}
|
||||
return app, nil
|
||||
}
|
||||
func (i *imlAppController) UpdateApp(ctx *gin.Context, appId string, input *service_dto.UpdateApp) (*service_dto.App, error) {
|
||||
return i.module.UpdateApp(ctx, appId, input)
|
||||
|
||||
@@ -3,11 +3,40 @@ package system
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
ai_dto "github.com/APIParkLab/APIPark/module/ai/dto"
|
||||
|
||||
"github.com/APIParkLab/APIPark/model/plugin_model"
|
||||
"github.com/APIParkLab/APIPark/service/api"
|
||||
|
||||
ai_api "github.com/APIParkLab/APIPark/module/ai-api"
|
||||
|
||||
model_runtime "github.com/APIParkLab/APIPark/ai-provider/model-runtime"
|
||||
ai_api_dto "github.com/APIParkLab/APIPark/module/ai-api/dto"
|
||||
router_dto "github.com/APIParkLab/APIPark/module/router/dto"
|
||||
|
||||
"github.com/eolinker/go-common/store"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/ai"
|
||||
|
||||
catalogue_dto "github.com/APIParkLab/APIPark/module/catalogue/dto"
|
||||
|
||||
application_authorization_dto "github.com/APIParkLab/APIPark/module/application-authorization/dto"
|
||||
service_dto "github.com/APIParkLab/APIPark/module/service/dto"
|
||||
team_dto "github.com/APIParkLab/APIPark/module/team/dto"
|
||||
"github.com/eolinker/go-common/register"
|
||||
"github.com/eolinker/go-common/server"
|
||||
"github.com/eolinker/go-common/utils"
|
||||
"github.com/google/uuid"
|
||||
|
||||
system_dto "github.com/APIParkLab/APIPark/module/system/dto"
|
||||
|
||||
application_authorization "github.com/APIParkLab/APIPark/module/application-authorization"
|
||||
@@ -185,3 +214,238 @@ func (i *imlSettingController) Get(ctx *gin.Context) (*system_dto.Setting, error
|
||||
func (i *imlSettingController) Set(ctx *gin.Context, input *system_dto.InputSetting) error {
|
||||
return i.settingModule.Set(ctx, input)
|
||||
}
|
||||
|
||||
type imlInitController struct {
|
||||
teamModule team.ITeamModule `autowired:""`
|
||||
appModule service.IAppModule `autowired:""`
|
||||
serviceModule service.IServiceModule `autowired:""`
|
||||
applicationAuthorizationModule application_authorization.IAuthorizationModule `autowired:""`
|
||||
catalogueModule catalogue.ICatalogueModule `autowired:""`
|
||||
providerModule ai.IProviderModule `autowired:""`
|
||||
transaction store.ITransaction `autowired:""`
|
||||
aiAPIModule ai_api.IAPIModule `autowired:""`
|
||||
docModule service.IServiceDocModule `autowired:""`
|
||||
routerModule router.IRouterModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlInitController) OnInit() {
|
||||
register.Handle(func(v server.Server) {
|
||||
ctx := utils.SetUserId(context.Background(), "admin")
|
||||
|
||||
err := i.transaction.Transaction(ctx, func(ctx context.Context) error {
|
||||
teams, err := i.teamModule.Search(ctx, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("get teams error: %v", err)
|
||||
}
|
||||
if len(teams) > 0 {
|
||||
return nil
|
||||
}
|
||||
items, err := i.catalogueModule.Search(ctx, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("get catalogue error: %v", err)
|
||||
}
|
||||
catalogueId := uuid.New().String()
|
||||
if len(items) == 0 {
|
||||
err = i.catalogueModule.Create(ctx, &catalogue_dto.CreateCatalogue{
|
||||
Id: catalogueId,
|
||||
Name: "Default Catalogue",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default catalogue error: %v", err)
|
||||
}
|
||||
} else {
|
||||
catalogueId = items[0].Id
|
||||
}
|
||||
|
||||
info, err := i.teamModule.Create(ctx, &team_dto.CreateTeam{
|
||||
Name: "Default Team",
|
||||
Description: "Auto created By APIPark",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default team error: %v", err)
|
||||
}
|
||||
// 创建Rest服务
|
||||
_, err = i.serviceModule.Create(ctx, info.Id, &service_dto.CreateService{
|
||||
Name: "REST Demo Service",
|
||||
Prefix: "/rest-demo",
|
||||
Description: "Auto created By APIPark",
|
||||
ServiceType: "public",
|
||||
Catalogue: catalogueId,
|
||||
ApprovalType: "auto",
|
||||
Kind: "rest",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default service error: %v", err)
|
||||
}
|
||||
// 创建AI服务
|
||||
err = i.createAIService(ctx, info.Id, &service_dto.CreateService{
|
||||
Name: "AI Demo Service",
|
||||
Prefix: "/ai-demo",
|
||||
Description: "Auto created By APIPark",
|
||||
ServiceType: "public",
|
||||
Catalogue: catalogueId,
|
||||
ApprovalType: "auto",
|
||||
Kind: "ai",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
app, err := i.appModule.CreateApp(ctx, info.Id, &service_dto.CreateApp{
|
||||
Name: "Demo Application",
|
||||
Description: "Auto created By APIPark",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default app error: %v", err)
|
||||
}
|
||||
_, err = i.applicationAuthorizationModule.AddAuthorization(ctx, app.Id, &application_authorization_dto.CreateAuthorization{
|
||||
Name: "Default API Key",
|
||||
Driver: "apikey",
|
||||
Position: "Header",
|
||||
TokenName: "Authorization",
|
||||
ExpireTime: 0,
|
||||
Config: map[string]interface{}{
|
||||
"apikey": uuid.New().String(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create default api key error: %v", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("init iml error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
func (i *imlInitController) createAIService(ctx context.Context, teamID string, input *service_dto.CreateService) error {
|
||||
|
||||
providerId := "openai"
|
||||
err := i.providerModule.UpdateProviderConfig(ctx, "openai", &ai_dto.UpdateConfig{
|
||||
Config: "{\n \"openai_api_base\": \"API Base\",\n \"openai_api_key\": \"API Key\",\n \"openai_organization\": \"Organization\"\n}",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("update openai config error: %v", err)
|
||||
}
|
||||
input.Provider = &providerId
|
||||
if input.Id == "" {
|
||||
input.Id = uuid.New().String()
|
||||
}
|
||||
if input.Prefix == "" {
|
||||
if len(input.Id) < 9 {
|
||||
input.Prefix = input.Id
|
||||
} else {
|
||||
input.Prefix = input.Id[:8]
|
||||
}
|
||||
}
|
||||
pv, err := i.providerModule.Provider(ctx, *input.Provider)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p, has := model_runtime.GetProvider(*input.Provider)
|
||||
if !has {
|
||||
return fmt.Errorf("provider not found")
|
||||
}
|
||||
m, has := p.GetModel(pv.DefaultLLM)
|
||||
if !has {
|
||||
return fmt.Errorf("model %s not found", pv.DefaultLLM)
|
||||
}
|
||||
|
||||
var info *service_dto.Service
|
||||
err = i.transaction.Transaction(ctx, func(txCtx context.Context) error {
|
||||
var err error
|
||||
info, err = i.serviceModule.Create(ctx, teamID, input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := fmt.Sprintf("/%s/demo_translation_api", strings.Trim(input.Prefix, "/"))
|
||||
timeout := 300000
|
||||
retry := 0
|
||||
aiPrompt := &ai_api_dto.AiPrompt{
|
||||
Variables: []*ai_api_dto.AiPromptVariable{
|
||||
{
|
||||
Key: "source_lang",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
{
|
||||
Key: "target_lang",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
{
|
||||
Key: "text",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
},
|
||||
Prompt: "You need to translate {{source_lang}} into {{target_lang}}, and the following is the content that needs to be translated.\n---\n{{text}}",
|
||||
}
|
||||
aiModel := &ai_api_dto.AiModel{
|
||||
Id: m.ID(),
|
||||
Config: m.DefaultConfig(),
|
||||
}
|
||||
name := "Demo Translation API"
|
||||
description := "A demo that shows you how to use a prompt to create a Translation API."
|
||||
apiId := uuid.New().String()
|
||||
err = i.aiAPIModule.Create(
|
||||
ctx,
|
||||
info.Id,
|
||||
&ai_api_dto.CreateAPI{
|
||||
Id: apiId,
|
||||
Name: name,
|
||||
Path: path,
|
||||
Description: description,
|
||||
Disable: false,
|
||||
AiPrompt: aiPrompt,
|
||||
AiModel: aiModel,
|
||||
Timeout: timeout,
|
||||
Retry: retry,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
plugins := make(map[string]api.PluginSetting)
|
||||
plugins["ai_prompt"] = api.PluginSetting{
|
||||
Config: plugin_model.ConfigType{
|
||||
"prompt": aiPrompt.Prompt,
|
||||
"variables": aiPrompt.Variables,
|
||||
},
|
||||
}
|
||||
plugins["ai_formatter"] = api.PluginSetting{
|
||||
Config: plugin_model.ConfigType{
|
||||
"model": aiModel.Id,
|
||||
"provider": fmt.Sprintf("%s@ai-provider", info.Provider.Id),
|
||||
"config": aiModel.Config,
|
||||
},
|
||||
}
|
||||
_, err = i.routerModule.Create(ctx, info.Id, &router_dto.Create{
|
||||
Id: apiId,
|
||||
Name: name,
|
||||
Path: path,
|
||||
Methods: []string{
|
||||
http.MethodPost,
|
||||
},
|
||||
Description: description,
|
||||
Protocols: []string{"http", "https"},
|
||||
MatchRules: nil,
|
||||
Proxy: &router_dto.InputProxy{
|
||||
Path: path,
|
||||
Timeout: timeout,
|
||||
Retry: retry,
|
||||
Plugins: plugins,
|
||||
},
|
||||
Disable: false,
|
||||
Upstream: info.Provider.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return i.docModule.SaveServiceDoc(ctx, info.Id, &service_dto.SaveServiceDoc{
|
||||
Doc: "The Translation API allows developers to translate text from one language to another. It supports multiple languages and enables easy integration of high-quality translation features into applications. With simple API requests, you can quickly translate content into different target languages.",
|
||||
})
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ type ISettingController interface {
|
||||
Set(ctx *gin.Context, input *system_dto.InputSetting) error
|
||||
}
|
||||
|
||||
type IInitController interface {
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IExportConfigController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlExportConfigController))
|
||||
@@ -33,4 +36,8 @@ func init() {
|
||||
autowire.Auto[ISettingController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlSettingController))
|
||||
})
|
||||
|
||||
autowire.Auto[IInitController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlInitController))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,13 +7,12 @@ go 1.21
|
||||
require (
|
||||
github.com/eolinker/ap-account v1.0.12
|
||||
github.com/eolinker/eosc v0.17.3
|
||||
github.com/eolinker/go-common v1.0.4
|
||||
github.com/eolinker/go-common v1.1.0
|
||||
github.com/gabriel-vasile/mimetype v1.4.4
|
||||
github.com/getkin/kin-openapi v0.127.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.14.0
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/urfave/cli/v2 v2.27.2
|
||||
golang.org/x/crypto v0.24.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
@@ -78,5 +77,3 @@ require (
|
||||
)
|
||||
|
||||
//replace github.com/eolinker/ap-account => ../../eolinker/ap-account
|
||||
//
|
||||
//replace github.com/eolinker/go-common => ../../eolinker/go-common
|
||||
|
||||
@@ -27,12 +27,11 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eolinker/ap-account v1.0.12 h1:QZNOgYf+0mVNjd/6cWz0Ape014c0d/x/XASsbf9w5vQ=
|
||||
github.com/eolinker/ap-account v1.0.12/go.mod h1:5lsZwkQfnHO5YJ3Cu6X1PZwZ0gbmJBUcix0hxG8aEsY=
|
||||
github.com/eolinker/ap-account v1.0.11/go.mod h1:5lsZwkQfnHO5YJ3Cu6X1PZwZ0gbmJBUcix0hxG8aEsY=
|
||||
github.com/eolinker/eosc v0.17.3 h1:sr2yT+v/AsqEdciRaaZZj0zL9pTufR5RvDW6+65hraQ=
|
||||
github.com/eolinker/eosc v0.17.3/go.mod h1:xgq816hpanlMXFtZw7Ztdctb1eEk9UPHchY4NfFO6Cw=
|
||||
github.com/eolinker/go-common v1.0.4 h1:F0akjnzJfIFOVmK30fD0SsCLU7DAKPXuY21MeyMmQ7w=
|
||||
github.com/eolinker/go-common v1.0.4/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
|
||||
github.com/eolinker/go-common v1.1.0 h1:n/XXK7yVRen3jhNG/SfZGXJA+KNnaYf0XTDfMeviaBw=
|
||||
github.com/eolinker/go-common v1.1.0/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
|
||||
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
|
||||
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
|
||||
github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY=
|
||||
|
||||
@@ -24,8 +24,9 @@ type AiPromptVariable struct {
|
||||
}
|
||||
|
||||
type AiModel struct {
|
||||
Id string `json:"id"`
|
||||
Config string `json:"config"`
|
||||
Id string `json:"id"`
|
||||
Config string `json:"config"`
|
||||
Provider string `json:"provider"`
|
||||
}
|
||||
|
||||
type EditAPI struct {
|
||||
|
||||
@@ -26,6 +26,7 @@ type APIItem struct {
|
||||
Updater auto.Label `json:"updater" aolabel:"user"`
|
||||
CreateTime auto.TimeLabel `json:"create_time"`
|
||||
UpdateTime auto.TimeLabel `json:"update_time"`
|
||||
Provider ProviderItem `json:"provider"`
|
||||
Model ModelItem `json:"model"`
|
||||
}
|
||||
|
||||
@@ -33,3 +34,9 @@ type ModelItem struct {
|
||||
Id string `json:"id"`
|
||||
Logo string `json:"logo"`
|
||||
}
|
||||
|
||||
type ProviderItem struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Logo string `json:"logo"`
|
||||
}
|
||||
|
||||
+27
-13
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
model_runtime "github.com/APIParkLab/APIPark/ai-provider/model-runtime"
|
||||
|
||||
ai_api_dto "github.com/APIParkLab/APIPark/module/ai-api/dto"
|
||||
ai_api "github.com/APIParkLab/APIPark/service/ai-api"
|
||||
"github.com/APIParkLab/APIPark/service/api"
|
||||
@@ -203,19 +204,8 @@ func (i *imlAPIModule) List(ctx context.Context, keyword string, serviceId strin
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p, has := model_runtime.GetProvider(info.AdditionalConfig["provider"])
|
||||
if !has {
|
||||
return nil, fmt.Errorf("provider not found")
|
||||
}
|
||||
return utils.SliceToSlice(apis, func(t *ai_api.API) *ai_api_dto.APIItem {
|
||||
modelItem := ai_api_dto.ModelItem{
|
||||
Id: t.Model,
|
||||
}
|
||||
model, has := p.DefaultModel(t.Model)
|
||||
if has {
|
||||
modelItem.Logo = model.Logo()
|
||||
}
|
||||
return &ai_api_dto.APIItem{
|
||||
item := &ai_api_dto.APIItem{
|
||||
Id: t.ID,
|
||||
Name: t.Name,
|
||||
RequestPath: t.Path,
|
||||
@@ -225,8 +215,32 @@ func (i *imlAPIModule) List(ctx context.Context, keyword string, serviceId strin
|
||||
Updater: auto.UUID(t.Updater),
|
||||
CreateTime: auto.TimeLabel(t.CreateAt),
|
||||
UpdateTime: auto.TimeLabel(t.UpdateAt),
|
||||
Model: modelItem,
|
||||
}
|
||||
aiModel, err := ConvertStruct[ai_api_dto.AiModel](t.AdditionalConfig["ai_model"])
|
||||
if err != nil {
|
||||
return item
|
||||
}
|
||||
p, has := model_runtime.GetProvider(aiModel.Provider)
|
||||
if has {
|
||||
item.Provider = ai_api_dto.ProviderItem{
|
||||
Id: p.ID(),
|
||||
Name: p.Name(),
|
||||
Logo: p.Logo(),
|
||||
}
|
||||
m, has := p.GetModel(t.Model)
|
||||
if has {
|
||||
item.Model = ai_api_dto.ModelItem{
|
||||
Id: m.ID(),
|
||||
Logo: m.Logo(),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
item.Model = ai_api_dto.ModelItem{
|
||||
Id: aiModel.Id,
|
||||
}
|
||||
}
|
||||
return item
|
||||
}), nil
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -398,7 +398,8 @@ func (i *imlProviderModule) initGateway(ctx context.Context, clusterId string, c
|
||||
func (i *imlProviderModule) syncGateway(ctx context.Context, clusterId string, releases []*gateway.DynamicRelease, online bool) error {
|
||||
client, err := i.clusterService.GatewayClient(ctx, clusterId)
|
||||
if err != nil {
|
||||
return err
|
||||
log.Errorf("get apinto client error: %v", err)
|
||||
return nil
|
||||
}
|
||||
defer func() {
|
||||
err := client.Close(ctx)
|
||||
|
||||
+16
-10
@@ -2,16 +2,18 @@ package cluster
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/setting"
|
||||
|
||||
cluster_dto "github.com/APIParkLab/APIPark/module/cluster/dto"
|
||||
|
||||
|
||||
"github.com/APIParkLab/APIPark/gateway/admin"
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
|
||||
"github.com/eolinker/go-common/store"
|
||||
|
||||
|
||||
"github.com/APIParkLab/APIPark/gateway"
|
||||
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/cluster"
|
||||
"github.com/eolinker/ap-account/service/account"
|
||||
"github.com/eolinker/go-common/utils"
|
||||
@@ -23,6 +25,7 @@ var (
|
||||
|
||||
type imlClusterModule struct {
|
||||
clusterService cluster.IClusterService `autowired:""`
|
||||
settingService setting.ISettingService `autowired:""`
|
||||
userNameService account.IAccountService `autowired:""`
|
||||
transaction store.ITransaction `autowired:""`
|
||||
}
|
||||
@@ -42,12 +45,12 @@ func (m *imlClusterModule) CheckCluster(ctx context.Context, address ...string)
|
||||
}
|
||||
})
|
||||
nodeStatus(ctx, nodesOut)
|
||||
|
||||
|
||||
return nodesOut, nil
|
||||
}
|
||||
|
||||
func (m *imlClusterModule) ResetCluster(ctx context.Context, clusterId string, address string) ([]*cluster_dto.Node, error) {
|
||||
|
||||
|
||||
nodes, err := m.clusterService.UpdateAddress(ctx, clusterId, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -65,7 +68,10 @@ func (m *imlClusterModule) ResetCluster(ctx context.Context, clusterId string, a
|
||||
Gateways: i.Server,
|
||||
}
|
||||
})
|
||||
|
||||
v, has := m.settingService.Get(ctx, setting.KeyInvokeAddress)
|
||||
if (!has || v == "") && len(nodesOut) > 0 && len(nodesOut[0].Gateways) > 0 {
|
||||
m.settingService.Set(ctx, setting.KeyInvokeAddress, nodesOut[0].Gateways[0], utils.UserId(ctx))
|
||||
}
|
||||
nodeStatus(ctx, nodesOut)
|
||||
return nodesOut, nil
|
||||
}
|
||||
@@ -83,7 +89,7 @@ func (m *imlClusterModule) initGateway(ctx context.Context, clusterId string) er
|
||||
return gateway.InitGateway(ctx, clusterId, client)
|
||||
}
|
||||
func (m *imlClusterModule) ClusterNodes(ctx context.Context, clusterId string) ([]*cluster_dto.Node, error) {
|
||||
|
||||
|
||||
nodes, err := m.clusterService.Nodes(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -98,7 +104,7 @@ func (m *imlClusterModule) ClusterNodes(ctx context.Context, clusterId string) (
|
||||
}
|
||||
})
|
||||
nodeStatus(ctx, nodesOut)
|
||||
|
||||
|
||||
return nodesOut, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ type IServiceModule interface {
|
||||
Edit(ctx context.Context, id string, input *service_dto.EditService) (*service_dto.Service, error)
|
||||
// Delete 删除项目
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// Simple 获取简易项目列表
|
||||
//Simple(ctx context.Context, keyword string) ([]*service_dto.SimpleServiceItem, error)
|
||||
|
||||
|
||||
@@ -161,19 +161,3 @@ func (m *imlTeamModule) Delete(ctx context.Context, id string) error {
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *imlTeamModule) OnInit() {
|
||||
ctx := context.Background()
|
||||
list, err := m.service.List(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(list) == 0 {
|
||||
teamId := uuid.New().String()
|
||||
err = m.service.Create(ctx, &team.CreateTeam{
|
||||
Id: teamId,
|
||||
Name: "Default Team",
|
||||
Description: "Auto create default team",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ type plugin struct {
|
||||
importConfigController system.IImportConfigController `autowired:""`
|
||||
aiProviderController ai.IProviderController `autowired:""`
|
||||
settingController system.ISettingController `autowired:""`
|
||||
initController system.IInitController `autowired:""`
|
||||
apis []pm3.Api
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
system:
|
||||
- name: organization
|
||||
cname: '组织管理'
|
||||
# cname: '组织管理'
|
||||
value: 'organization'
|
||||
children:
|
||||
- name: member
|
||||
cname: '成员'
|
||||
# cname: '成员'
|
||||
value: 'member'
|
||||
children:
|
||||
- name: view
|
||||
cname: '查看'
|
||||
# cname: '查看'
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/user/accounts"
|
||||
- "GET:/api/v1/user/departments"
|
||||
- name: manager
|
||||
cname: '管理'
|
||||
# cname: '管理'
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/user/account"
|
||||
@@ -37,14 +37,14 @@ system:
|
||||
value: 'team'
|
||||
children:
|
||||
- name: view
|
||||
cname: '查看'
|
||||
# cname: '查看'
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/manager/teams"
|
||||
- "GET:/api/v1/manager/team"
|
||||
- name: manager
|
||||
cname: '管理'
|
||||
# cname: '管理'
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/manager/team"
|
||||
@@ -53,7 +53,7 @@ system:
|
||||
dependents:
|
||||
- system.organization.team.view
|
||||
- name: role
|
||||
cname: '角色'
|
||||
# cname: '角色'
|
||||
value: 'role'
|
||||
children:
|
||||
- name: view system role
|
||||
@@ -71,21 +71,21 @@ system:
|
||||
- "GET:/api/v1/team/roles"
|
||||
- "GET:/api/v1/team/role"
|
||||
- name: System Settings
|
||||
cname: '系统设置'
|
||||
# cname: '系统设置'
|
||||
value: 'settings'
|
||||
children:
|
||||
- name: service classification
|
||||
cname: '服务分类'
|
||||
# cname: '服务分类'
|
||||
value: 'service_classification'
|
||||
children:
|
||||
- name: view
|
||||
cname: '查看'
|
||||
# cname: '查看'
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
# apis:
|
||||
# - "GET:/api/v1/catalogues"
|
||||
- name: manager
|
||||
cname: '管理'
|
||||
# cname: '管理'
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/catalogue"
|
||||
@@ -95,24 +95,24 @@ system:
|
||||
dependents:
|
||||
- system.settings.service_classification.view
|
||||
- name: General
|
||||
cname: 常规设置
|
||||
# cname: 常规设置
|
||||
value: 'general'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
# - "GET:/api/v1/setting"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
# - "PUT:/api/v1/setting"
|
||||
dependents:
|
||||
- system.settings.general.view
|
||||
- name: Devops
|
||||
cname: 运维
|
||||
# cname: 运维
|
||||
value: 'devops'
|
||||
children:
|
||||
- name: cluster
|
||||
@@ -126,7 +126,7 @@ system:
|
||||
apis:
|
||||
- "GET:/api/v1/cluster/nodes"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "PUT:/api/v1/cluster/reset"
|
||||
@@ -136,14 +136,14 @@ system:
|
||||
value: 'ssl_certificate'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/certificates"
|
||||
- "GET:/api/v1/certificate"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/certificate"
|
||||
@@ -152,27 +152,27 @@ system:
|
||||
dependents:
|
||||
- system.devops.ssl_certificate.view
|
||||
- name: Data Source
|
||||
cname: '数据源'
|
||||
# cname: '数据源'
|
||||
value: 'data_source'
|
||||
children:
|
||||
- name: view
|
||||
cname: '查看'
|
||||
# cname: '查看'
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/monitor/config"
|
||||
- name: manager
|
||||
cname: '管理'
|
||||
# cname: '管理'
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/monitor/config"
|
||||
- "PUT:/api/v1/monitor/config"
|
||||
- name: log configuration
|
||||
cname: 日志
|
||||
# cname: 日志
|
||||
value: 'log_configuration'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -180,7 +180,7 @@ system:
|
||||
- "GET:/api/v1/dynamic/{name}/list"
|
||||
- "GET:/api/v1/dynamic/{name}/render"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/dynamic/{name}"
|
||||
@@ -190,36 +190,19 @@ system:
|
||||
- "PUT:/api/v1/dynamic/{name}/offline"
|
||||
dependents:
|
||||
- system.devops.log_configuration.view
|
||||
- name: monitor
|
||||
cname: 监控
|
||||
value: 'monitor'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/monitor/config"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/monitor/config"
|
||||
dependents:
|
||||
- system.devops.monitor.view
|
||||
- name: ai_provider
|
||||
cname: AI 模型供应商
|
||||
- name: ai provider
|
||||
# cname: AI 模型供应商
|
||||
value: 'ai_provider'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/ai/providers"
|
||||
- "GET:/api/v1/ai/provider/config"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "PUT:/api/v1/ai/provider/config"
|
||||
@@ -228,15 +211,15 @@ system:
|
||||
- system.devops.ai_provider.view
|
||||
|
||||
- name: dashboard
|
||||
cname: 仪表盘
|
||||
# cname: 仪表盘
|
||||
value: 'dashboard'
|
||||
children:
|
||||
- name: run view
|
||||
cname: 运行视图
|
||||
# cname: 运行视图
|
||||
value: 'run_view'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -245,45 +228,45 @@ system:
|
||||
- "GET:/api/v1/monitor/overview/top10"
|
||||
- "GET:/api/v1/monitor/overview/summary"
|
||||
- name: workspace
|
||||
cname: 工作空间
|
||||
# cname: 工作空间
|
||||
value: 'workspace'
|
||||
children:
|
||||
- name: application
|
||||
cname: 应用
|
||||
# cname: 应用
|
||||
value: 'application'
|
||||
children:
|
||||
- name: view all
|
||||
cname: 查看所有应用
|
||||
- name: view all application
|
||||
# cname: 查看所有应用
|
||||
value: 'view_all'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/apps"
|
||||
- name: service
|
||||
cname: 服务
|
||||
# cname: 服务
|
||||
value: 'service'
|
||||
children:
|
||||
- name: view all
|
||||
cname: 查看所有服务
|
||||
- name: view all service
|
||||
# cname: 查看所有服务
|
||||
value: 'view_all'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/services"
|
||||
- name: team
|
||||
cname: 团队
|
||||
# cname: 团队
|
||||
value: 'team'
|
||||
children:
|
||||
- name: view all
|
||||
cname: 查看所有团队
|
||||
- name: view all team
|
||||
# cname: 查看所有团队
|
||||
value: 'view_all'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/manager/teams"
|
||||
- name: api market
|
||||
cname: API市场
|
||||
# cname: API市场
|
||||
value: 'api_market'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -291,15 +274,15 @@ system:
|
||||
- "GET:/api/v1/catalogue/service"
|
||||
team:
|
||||
- name: service
|
||||
cname: 服务
|
||||
# cname: 服务
|
||||
value: 'service'
|
||||
children:
|
||||
- name: router
|
||||
cname: 路由
|
||||
# cname: 路由
|
||||
value: 'router'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -308,24 +291,24 @@ team:
|
||||
- "GET:/api/v1/service/router/detail/simple"
|
||||
- "GET:/api/v1/service/router/define"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/service/router"
|
||||
- "PUT:/api/v1/service/router"
|
||||
- "DELETE:/api/v1/service/router"
|
||||
- name: api_doc
|
||||
- name: api doc
|
||||
cname: API文档
|
||||
value: 'api_doc'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/service/api_doc"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "PUT:/api/v1/service/api_doc"
|
||||
@@ -335,22 +318,22 @@ team:
|
||||
value: 'upstream'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/service/upstream"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "PUT:/api/v1/service/upstream"
|
||||
- name: release
|
||||
cname: 发布
|
||||
# cname: 发布
|
||||
value: 'release'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -361,18 +344,18 @@ team:
|
||||
- "GET:/api/v1/service/release/preview"
|
||||
- "GET:/api/v1/service/publish/status"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/service/publish/release/do"
|
||||
# - "PUT:/api/v1/service/publish/execute"
|
||||
- "DELETE:/api/v1/service/release"
|
||||
- name: subscription management
|
||||
cname: 订阅方管理
|
||||
# cname: 订阅方管理
|
||||
value: 'subscription'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -380,18 +363,18 @@ team:
|
||||
- "GET:/api/v1/service/approval/subscribe"
|
||||
- "GET:/api/v1/service/subscribers"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/service/approval/subscribe"
|
||||
- "POST:/api/v1/service/subscriber"
|
||||
- "DELETE:/api/v1/service/subscriber"
|
||||
- name: service
|
||||
cname: 服务管理
|
||||
# cname: 服务管理
|
||||
value: 'service'
|
||||
children:
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "PUT:/api/v1/service/info"
|
||||
@@ -406,24 +389,24 @@ team:
|
||||
value: 'subscription'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/application/subscriptions"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/catalogue/service/subscribe"
|
||||
- "POST:/api/v1/application/subscription/cancel"
|
||||
- "POST:/api/v1/application/subscription/cancel_apply"
|
||||
- name: authorization
|
||||
cname: 访问授权
|
||||
# cname: 访问授权
|
||||
value: 'authorization'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
@@ -431,58 +414,58 @@ team:
|
||||
- "GET:/api/v1/app/authorizations"
|
||||
- "GET:/api/v1/app/authorization/details"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/app/authorization"
|
||||
- "PUT:/api/v1/app/authorization"
|
||||
- "DELETE:/api/v1/app/authorization"
|
||||
- name: application
|
||||
cname: 应用
|
||||
# cname: 应用
|
||||
value: 'application'
|
||||
children:
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "PUT:/api/v1/app/info"
|
||||
- "POST:/api/v1/team/app"
|
||||
- "DELETE:/api/v1/app"
|
||||
- name: team
|
||||
cname: 团队
|
||||
# cname: 团队
|
||||
value: 'team'
|
||||
children:
|
||||
- name: member
|
||||
cname: 成员
|
||||
# cname: 成员
|
||||
value: 'member'
|
||||
children:
|
||||
- name: view
|
||||
cname: 查看
|
||||
# cname: 查看
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/team/members"
|
||||
- "GET:/api/v1/team/members/toadd"
|
||||
- name: manager
|
||||
cname: 管理
|
||||
# cname: 管理
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/team/member"
|
||||
- "DELETE:/api/v1/team/member"
|
||||
- "PUT:/api/v1/team/member/role"
|
||||
- name: team
|
||||
cname: 团队管理
|
||||
# cname: 团队管理
|
||||
value: 'team'
|
||||
children:
|
||||
- name: view
|
||||
cname: '查看'
|
||||
# cname: '查看'
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- "GET:/api/v1/manager/teams"
|
||||
- "GET:/api/v1/manager/team"
|
||||
- name: manager
|
||||
cname: '管理'
|
||||
# cname: '管理'
|
||||
value: 'manager'
|
||||
apis:
|
||||
- "POST:/api/v1/manager/team"
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package access
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/eolinker/go-common/access"
|
||||
)
|
||||
|
||||
@@ -55,3 +58,55 @@ func printAccesses(group string, builder *strings.Builder) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TestPrintName(t *testing.T) {
|
||||
result := make(map[string]string)
|
||||
data, err := os.ReadFile("access.yaml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tmp := make(map[string]interface{})
|
||||
err = yaml.Unmarshal(data, &tmp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recursionReadKey("name", tmp, result)
|
||||
data, err = os.ReadFile("role.yaml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tmp = make(map[string]interface{})
|
||||
err = yaml.Unmarshal(data, &tmp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recursionReadKey("name", tmp, result)
|
||||
r, err := json.MarshalIndent(result, "", " ")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(r))
|
||||
|
||||
}
|
||||
|
||||
// 递归读取文件中name字段
|
||||
func recursionReadKey(key string, data map[string]interface{}, result map[string]string) {
|
||||
for k, v := range data {
|
||||
switch t := v.(type) {
|
||||
case string:
|
||||
if k == key {
|
||||
result[strings.ToLower(t)] = ""
|
||||
}
|
||||
case map[string]interface{}:
|
||||
recursionReadKey(key, t, result)
|
||||
case []interface{}:
|
||||
for _, n := range t {
|
||||
switch tt := n.(type) {
|
||||
case map[string]interface{}:
|
||||
recursionReadKey(key, tt, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
system:
|
||||
system.api_market.service_classification.manager:
|
||||
- POST:/api/v1/catalogue
|
||||
- PUT:/api/v1/catalogue
|
||||
- DELETE:/api/v1/catalogue
|
||||
- PUT:/api/v1/catalogue/sort
|
||||
system.api_market.service_classification.view:
|
||||
- GET:/api/v1/catalogues
|
||||
system.dashboard.run_view.view:
|
||||
- GET:/api/v1/monitor/overview/invoke
|
||||
- GET:/api/v1/monitor/overview/message
|
||||
- GET:/api/v1/monitor/overview/top10
|
||||
- GET:/api/v1/monitor/overview/summary
|
||||
system.devops.ai_provider.manager:
|
||||
- PUT:/api/v1/ai/provider/config
|
||||
- PUT:/api/v1/ai/provider/default-llm
|
||||
system.devops.ai_provider.view:
|
||||
- GET:/api/v1/ai/providers
|
||||
- GET:/api/v1/ai/provider
|
||||
- POST:/api/v1/ai/provider
|
||||
- PUT:/api/v1/ai/provider
|
||||
system.devops.ai_provider.manager:
|
||||
- DELETE:/api/v1/ai/provider
|
||||
- GET:/api/v1/ai/provider/config
|
||||
system.devops.cluster.manager:
|
||||
- PUT:/api/v1/cluster/reset
|
||||
- POST:/api/v1/cluster/check
|
||||
system.devops.cluster.view:
|
||||
- GET:/api/v1/cluster/nodes
|
||||
system.devops.data_source.manager:
|
||||
- POST:/api/v1/monitor/config
|
||||
- PUT:/api/v1/monitor/config
|
||||
system.devops.data_source.view:
|
||||
- GET:/api/v1/monitor/config
|
||||
system.devops.log_configuration.manager:
|
||||
- POST:/api/v1/dynamic/{name}
|
||||
- PUT:/api/v1/dynamic/{name}/config
|
||||
@@ -64,6 +66,14 @@ system:
|
||||
system.organization.team.view:
|
||||
- GET:/api/v1/manager/teams
|
||||
- GET:/api/v1/manager/team
|
||||
system.settings.general.manager:
|
||||
system.settings.general.view:
|
||||
system.settings.service_classification.manager:
|
||||
- POST:/api/v1/catalogue
|
||||
- PUT:/api/v1/catalogue
|
||||
- DELETE:/api/v1/catalogue
|
||||
- PUT:/api/v1/catalogue/sort
|
||||
system.settings.service_classification.view:
|
||||
system.workspace.api_market.view:
|
||||
- GET:/api/v1/catalogue/services
|
||||
- GET:/api/v1/catalogue/service
|
||||
@@ -72,10 +82,9 @@ system:
|
||||
system.workspace.service.view_all:
|
||||
- GET:/api/v1/services
|
||||
system.workspace.team.view_all:
|
||||
- GET:/api/v1/teams
|
||||
- GET:/api/v1/manager/teams
|
||||
team:
|
||||
team.application.application.manager:
|
||||
- GET:/api/v1/app/info
|
||||
- PUT:/api/v1/app/info
|
||||
- POST:/api/v1/team/app
|
||||
- DELETE:/api/v1/app
|
||||
@@ -93,20 +102,13 @@ team:
|
||||
- POST:/api/v1/application/subscription/cancel_apply
|
||||
team.application.subscription.view:
|
||||
- GET:/api/v1/application/subscriptions
|
||||
team.service.api.manager:
|
||||
- POST:/api/v1/service/api
|
||||
- PUT:/api/v1/service/api
|
||||
- DELETE:/api/v1/service/api
|
||||
- POST:/api/v1/service/api/copy
|
||||
team.service.api.view:
|
||||
- GET:/api/v1/service/apis
|
||||
- GET:/api/v1/service/api/detail
|
||||
- GET:/api/v1/service/api/detail/simple
|
||||
- GET:/api/v1/service/api/define
|
||||
- GET:/api/v1/service/apis/simple
|
||||
team.service.api_doc.manager:
|
||||
- PUT:/api/v1/service/api_doc
|
||||
- POST:/api/v1/service/api_doc/upload
|
||||
team.service.api_doc.view:
|
||||
- GET:/api/v1/service/api_doc
|
||||
team.service.release.manager:
|
||||
- POST:/api/v1/service/publish/release/do
|
||||
- PUT:/api/v1/service/publish/execute
|
||||
- DELETE:/api/v1/service/release
|
||||
team.service.release.view:
|
||||
- GET:/api/v1/service/releases
|
||||
@@ -115,8 +117,16 @@ team:
|
||||
- GET:/api/v1/service/publish/check
|
||||
- GET:/api/v1/service/release/preview
|
||||
- GET:/api/v1/service/publish/status
|
||||
team.service.router.manager:
|
||||
- POST:/api/v1/service/router
|
||||
- PUT:/api/v1/service/router
|
||||
- DELETE:/api/v1/service/router
|
||||
team.service.router.view:
|
||||
- GET:/api/v1/service/routers
|
||||
- GET:/api/v1/service/router/detail
|
||||
- GET:/api/v1/service/router/detail/simple
|
||||
- GET:/api/v1/service/router/define
|
||||
team.service.service.manager:
|
||||
- GET:/api/v1/service/info
|
||||
- PUT:/api/v1/service/info
|
||||
- POST:/api/v1/team/service
|
||||
- DELETE:/api/v1/team/service
|
||||
@@ -138,7 +148,6 @@ team:
|
||||
- PUT:/api/v1/team/member/role
|
||||
team.team.member.view:
|
||||
- GET:/api/v1/team/members
|
||||
- GET:/api/v1/team/members/simple
|
||||
- GET:/api/v1/team/members/toadd
|
||||
team.team.team.manager:
|
||||
- POST:/api/v1/manager/team
|
||||
|
||||
+35
-31
@@ -1,33 +1,35 @@
|
||||
system:
|
||||
- name: supper_admin
|
||||
cname: 超级管理员
|
||||
- name: supper admin
|
||||
value: supper_admin
|
||||
permits:
|
||||
- system.api_market.service_classification.manager
|
||||
- system.api_market.service_classification.view
|
||||
- system.dashboard.run_view.view
|
||||
- system.devops.ai_provider.view
|
||||
- system.devops.ai_provider.manager
|
||||
- system.devops.ai_provider.view
|
||||
- system.devops.cluster.manager
|
||||
- system.devops.cluster.view
|
||||
- system.devops.data_source.manager
|
||||
- system.devops.data_source.view
|
||||
- system.devops.log_configuration.manager
|
||||
- system.devops.log_configuration.view
|
||||
- system.devops.ssl_certificate.manager
|
||||
- system.devops.ssl_certificate.view
|
||||
- system.devops.data_source.manager
|
||||
- system.devops.data_source.view
|
||||
- system.organization.member.manager
|
||||
- system.organization.member.view
|
||||
- system.organization.role.view_system_role
|
||||
- system.organization.role.view_team_role
|
||||
- system.organization.team.manager
|
||||
- system.organization.team.view
|
||||
- system.settings.general.manager
|
||||
- system.settings.general.view
|
||||
- system.settings.service_classification.manager
|
||||
- system.settings.service_classification.view
|
||||
- system.workspace.api_market.view
|
||||
- system.workspace.application.view_all
|
||||
- system.workspace.service.view_all
|
||||
- system.workspace.team.view_all
|
||||
supper: true
|
||||
- name: team_admin
|
||||
cname: 团队管理员
|
||||
- name: team admin
|
||||
value: team_admin
|
||||
permits:
|
||||
- system.organization.role.view_team_role
|
||||
- system.organization.team.manager
|
||||
@@ -36,35 +38,37 @@ system:
|
||||
- system.workspace.application.view_all
|
||||
- system.workspace.service.view_all
|
||||
- system.workspace.team.view_all
|
||||
- name: devops_admin
|
||||
cname: 运维管理员
|
||||
- name: devops admin
|
||||
value: devops_admin
|
||||
permits:
|
||||
- system.api_market.service_classification.manager
|
||||
- system.api_market.service_classification.view
|
||||
- system.dashboard.run_view.view
|
||||
- system.devops.ai_provider.view
|
||||
- system.devops.ai_provider.manager
|
||||
- system.devops.ai_provider.view
|
||||
- system.devops.cluster.manager
|
||||
- system.devops.cluster.view
|
||||
- system.devops.data_source.manager
|
||||
- system.devops.data_source.view
|
||||
- system.devops.log_configuration.manager
|
||||
- system.devops.log_configuration.view
|
||||
- system.devops.ssl_certificate.manager
|
||||
- system.devops.ssl_certificate.view
|
||||
- system.devops.data_source.manager
|
||||
- system.devops.data_source.view
|
||||
- system.workspace.api_market.view
|
||||
- system.workspace.application.view_all
|
||||
- system.workspace.service.view_all
|
||||
- system.workspace.team.view_all
|
||||
- name: member
|
||||
cname: 普通成员
|
||||
- system.settings.general.manager
|
||||
- system.settings.general.view
|
||||
- system.settings.service_classification.manager
|
||||
- system.settings.service_classification.view
|
||||
- name: general member
|
||||
value: member
|
||||
permits:
|
||||
- system.workspace.api_market.view
|
||||
default: true
|
||||
- name: guest
|
||||
cname: 只读成员
|
||||
value: guest
|
||||
permits:
|
||||
- system.api_market.service_classification.view
|
||||
- system.settings.service_classification.view
|
||||
- system.devops.cluster.view
|
||||
- system.devops.log_configuration.view
|
||||
- system.devops.ssl_certificate.view
|
||||
@@ -79,8 +83,8 @@ system:
|
||||
- system.workspace.team.view_all
|
||||
- system.dashboard.run_view.view
|
||||
team:
|
||||
- name: team_admin
|
||||
cname: 团队管理员
|
||||
- name: team admin
|
||||
value: team_admin
|
||||
permits:
|
||||
- team.application.application.manager
|
||||
- team.application.authorization.manager
|
||||
@@ -103,8 +107,8 @@ team:
|
||||
- team.team.team.manager
|
||||
- team.team.team.view
|
||||
supper: true
|
||||
- name: service_admin
|
||||
cname: 服务管理员
|
||||
- name: service admin
|
||||
value: service_admin
|
||||
permits:
|
||||
- team.service.service.manager
|
||||
- team.service.upstream.manager
|
||||
@@ -118,8 +122,8 @@ team:
|
||||
- team.service.release.manager
|
||||
- team.service.release.view
|
||||
- team.team.member.view
|
||||
- name: service_developer
|
||||
cname: 服务开发者
|
||||
- name: service developer
|
||||
value: service_developer
|
||||
permits:
|
||||
- team.service.upstream.manager
|
||||
- team.service.upstream.view
|
||||
@@ -130,8 +134,8 @@ team:
|
||||
- team.service.release.manager
|
||||
- team.service.release.view
|
||||
- team.team.member.view
|
||||
- name: application_admin
|
||||
cname: 应用管理员
|
||||
- name: application admin
|
||||
value: application_admin
|
||||
permits:
|
||||
- team.application.application.manager
|
||||
- team.application.authorization.manager
|
||||
@@ -139,8 +143,8 @@ team:
|
||||
- team.application.subscription.manager
|
||||
- team.application.subscription.view
|
||||
- team.team.member.view
|
||||
- name: application_developer
|
||||
cname: 应用开发者
|
||||
- name: application developer
|
||||
value: application_developer
|
||||
permits:
|
||||
- team.application.authorization.view
|
||||
- team.application.subscription.manager
|
||||
@@ -148,7 +152,7 @@ team:
|
||||
- team.team.member.view
|
||||
default: true
|
||||
- name: guest
|
||||
cname: 只读成员
|
||||
value: guest
|
||||
permits:
|
||||
- team.application.authorization.view
|
||||
- team.application.subscription.view
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"ai provider": "AI Provider",
|
||||
"api market": "API Market",
|
||||
"api doc": "API Documentation",
|
||||
"application": "Application",
|
||||
"application admin": "Application Administrator",
|
||||
"application developer": "Application Developer",
|
||||
"authorization": "Authorization",
|
||||
"cluster": "Cluster",
|
||||
"dashboard": "Dashboard",
|
||||
"data source": "Data Source",
|
||||
"devops": "DevOps",
|
||||
"devops admin": "DevOps Administrator",
|
||||
"general": "General Settings",
|
||||
"general member": "General Member",
|
||||
"guest": "Guest",
|
||||
"log configuration": "Log Configuration",
|
||||
"manager": "Manager",
|
||||
"member": "Member",
|
||||
"organization": "Organization Management",
|
||||
"release": "Release",
|
||||
"role": "Role",
|
||||
"router": "Router",
|
||||
"run view": "Run View",
|
||||
"service": "Service",
|
||||
"service admin": "Service Administrator",
|
||||
"service classification": "Service Directory",
|
||||
"service developer": "Service Developer",
|
||||
"ssl certificate": "SSL Certificate",
|
||||
"subscription management": "Subscription Management",
|
||||
"subscription service": "Subscription Service",
|
||||
"supper admin": "Super Administrator",
|
||||
"system settings": "System Settings",
|
||||
"team": "Team",
|
||||
"team admin": "Team Administrator",
|
||||
"upstream": "Upstream",
|
||||
"view": "View",
|
||||
"view all application": "View All Applications",
|
||||
"view all service": "View All Services",
|
||||
"view all team": "View All Teams",
|
||||
"view system role": "View System Roles",
|
||||
"view team role": "View Team Roles",
|
||||
"workspace": "Workspace"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"ai provider": "AIプロバイダー",
|
||||
"api market": "APIマーケット",
|
||||
"api doc": "APIドキュメント",
|
||||
"application": "アプリケーション",
|
||||
"application admin": "アプリケーション管理者",
|
||||
"application developer": "アプリケーション開発者",
|
||||
"authorization": "認証",
|
||||
"cluster": "クラスター",
|
||||
"dashboard": "ダッシュボード",
|
||||
"data source": "データソース",
|
||||
"devops": "DevOps",
|
||||
"devops admin": "DevOps管理者",
|
||||
"general": "一般設定",
|
||||
"general member": "一般メンバー",
|
||||
"guest": "ゲスト",
|
||||
"log configuration": "ログ設定",
|
||||
"manager": "管理者",
|
||||
"member": "メンバー",
|
||||
"organization": "組織管理",
|
||||
"release": "リリース",
|
||||
"role": "役割",
|
||||
"router": "ルーター",
|
||||
"run view": "実行ビュー",
|
||||
"service": "サービス",
|
||||
"service admin": "サービス管理者",
|
||||
"service classification": "サービスディレクトリ",
|
||||
"service developer": "サービス開発者",
|
||||
"ssl certificate": "SSL証明書",
|
||||
"subscription management": "サブスクリプション管理",
|
||||
"subscription service": "サブスクリプションサービス",
|
||||
"supper admin": "スーパ管理者",
|
||||
"system settings": "システム設定",
|
||||
"team": "チーム",
|
||||
"team admin": "チーム管理者",
|
||||
"upstream": "アップストリーム",
|
||||
"view": "表示",
|
||||
"view all application": "すべてのアプリケーションを表示",
|
||||
"view all service": "すべてのサービスを表示",
|
||||
"view all team": "すべてのチームを表示",
|
||||
"view system role": "システム役割を表示",
|
||||
"view team role": "チーム役割を表示",
|
||||
"workspace": "ワークスペース"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"ai provider": "AI供应商",
|
||||
"api market": "API市场",
|
||||
"api doc": "API文档",
|
||||
"application": "应用",
|
||||
"application admin": "应用管理员",
|
||||
"application developer": "应用开发者",
|
||||
"authorization": "鉴权",
|
||||
"cluster": "集群",
|
||||
"dashboard": "仪表盘",
|
||||
"data source": "数据源",
|
||||
"devops": "运维",
|
||||
"devops admin": "运维管理员",
|
||||
"general": "常规设置",
|
||||
"general member": "普通成员",
|
||||
"guest": "访客",
|
||||
"log configuration": "日志配置",
|
||||
"manager": "管理",
|
||||
"member": "成员",
|
||||
"organization": "组织管理",
|
||||
"release": "发布",
|
||||
"role": "角色",
|
||||
"router": "路由",
|
||||
"run view": "运行视图",
|
||||
"service": "服务",
|
||||
"service admin": "服务管理员",
|
||||
"service classification": "服务目录",
|
||||
"service developer": "服务开发者",
|
||||
"ssl certificate": "SSL证书",
|
||||
"subscription management": "订阅方管理",
|
||||
"subscription service": "订阅服务",
|
||||
"supper admin": "超级管理员",
|
||||
"system settings": "系统设置",
|
||||
"team": "团队",
|
||||
"team admin": "团队管理员",
|
||||
"upstream": "上游",
|
||||
"view": "查看",
|
||||
"view all application": "查看所有应用",
|
||||
"view all service": "查看所有服务",
|
||||
"view all team": "查看所有团队",
|
||||
"view system role": "查看系统角色",
|
||||
"view team role": "查看团队角色",
|
||||
"workspace": "工作空间"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"ai provider": "AI供應商",
|
||||
"api market": "API市場",
|
||||
"api doc": "API文檔",
|
||||
"application": "應用",
|
||||
"application admin": "應用管理員",
|
||||
"application developer": "應用開發者",
|
||||
"authorization": "授權",
|
||||
"cluster": "集群",
|
||||
"dashboard": "儀表盤",
|
||||
"data source": "數據源",
|
||||
"devops": "運維",
|
||||
"devops admin": "運維管理員",
|
||||
"general": "常規設置",
|
||||
"general member": "普通成員",
|
||||
"guest": "訪客",
|
||||
"log configuration": "日誌配置",
|
||||
"manager": "管理",
|
||||
"member": "成員",
|
||||
"organization": "組織管理",
|
||||
"release": "發布",
|
||||
"role": "角色",
|
||||
"router": "路由",
|
||||
"run view": "運行視圖",
|
||||
"service": "服務",
|
||||
"service admin": "服務管理員",
|
||||
"service classification": "服務目錄",
|
||||
"service developer": "服務開發者",
|
||||
"ssl certificate": "SSL證書",
|
||||
"subscription management": "訂閱方管理",
|
||||
"subscription service": "訂閱服務",
|
||||
"supper admin": "超級管理員",
|
||||
"system settings": "系統設置",
|
||||
"team": "團隊",
|
||||
"team admin": "團隊管理員",
|
||||
"upstream": "上游",
|
||||
"view": "查看",
|
||||
"view all application": "查看所有應用",
|
||||
"view all service": "查看所有服務",
|
||||
"view all team": "查看所有團隊",
|
||||
"view system role": "查看系統角色",
|
||||
"view team role": "查看團隊角色",
|
||||
"workspace": "工作空間"
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package locale
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/eolinker/eosc"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed i18n/*
|
||||
i18nDirs embed.FS
|
||||
i18nData eosc.Untyped[string, map[string]string]
|
||||
defaultI18n = "zh-CN"
|
||||
)
|
||||
|
||||
func init() {
|
||||
i18nData = eosc.BuildUntyped[string, map[string]string]()
|
||||
files, err := i18nDirs.ReadDir("i18n")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var data []byte
|
||||
for _, f := range files {
|
||||
data, err = i18nDirs.ReadFile("i18n/" + f.Name())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
tmp := make(map[string]string)
|
||||
err = json.Unmarshal(data, &tmp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
key := strings.TrimSuffix(f.Name(), ".json")
|
||||
i18nData.Set(key, tmp)
|
||||
}
|
||||
}
|
||||
|
||||
func Get(i18n string) map[string]string {
|
||||
result, has := i18nData.Get(i18n)
|
||||
if has {
|
||||
return result
|
||||
}
|
||||
|
||||
result, has = i18nData.Get(defaultI18n)
|
||||
if !has {
|
||||
return make(map[string]string)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -2,8 +2,9 @@ package ai_api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/APIParkLab/APIPark/stores/api"
|
||||
"time"
|
||||
|
||||
"github.com/APIParkLab/APIPark/stores/api"
|
||||
)
|
||||
|
||||
type API struct {
|
||||
|
||||
@@ -25,6 +25,7 @@ func NewCommitWithKey[H any](name, key string) *StoreWidthType[H] {
|
||||
name: name,
|
||||
latestTableName: name + "_latest",
|
||||
commitTableName: name + "_commit",
|
||||
name: name,
|
||||
},
|
||||
key: key,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user