mirror of
https://github.com/KaySar12/NextZen-UserService.git
synced 2025-03-15 15:15:35 +07:00
feature: add 1panel related api(wip)
This commit is contained in:
parent
f42b57a15c
commit
946e3dba59
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -6,7 +6,7 @@
|
||||
"type": "go",
|
||||
"debugAdapter": "dlv-dap",
|
||||
"request": "launch",
|
||||
"port": 34933,
|
||||
"port": 33107,
|
||||
"host": "127.0.0.1",
|
||||
"mode": "exec",
|
||||
"program": "${workspaceFolder}/dist/casaos-user-service-amd64_linux_amd64_v1/build/sysroot/usr/bin/casaos-user-service"
|
||||
|
@ -14,6 +14,11 @@ type OnePanelService interface {
|
||||
Login(m model2.OnePanelCredentials, baseURL string) (model2.LoginResponse, []*http.Cookie, error)
|
||||
Logout(m model2.OnePanelCredentials, baseURL string) (model2.LogoutResponse, error)
|
||||
HealthCheck(baseURL string) (string, error)
|
||||
SearchInstalledApp(p model2.InstalledAppRequest, baseURL string) (model2.InstalledAppResponse, error)
|
||||
// InstallApp()
|
||||
// SearchWebsite()
|
||||
// CreateWebsite()
|
||||
// DeleteWebsite()
|
||||
}
|
||||
|
||||
var (
|
||||
@ -23,6 +28,33 @@ var (
|
||||
type onePanelService struct {
|
||||
}
|
||||
|
||||
func (o *onePanelService) SearchInstalledApp(m model2.InstalledAppRequest, baseUrl string) (model2.InstalledAppResponse, error) {
|
||||
path := baseUrl + "/api/v1/websites/search"
|
||||
reqBody, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return model2.InstalledAppResponse{}, fmt.Errorf("error marshaling request body: %v", err)
|
||||
}
|
||||
req, err := http.NewRequest("POST", path, bytes.NewReader(reqBody))
|
||||
// req.AddCookie()
|
||||
if err != nil {
|
||||
return model2.InstalledAppResponse{}, fmt.Errorf("error creating request: %v", err)
|
||||
}
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return model2.InstalledAppResponse{}, fmt.Errorf("error making request: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
return model2.InstalledAppResponse{}, fmt.Errorf("HTTP error: %s", resp.Status)
|
||||
}
|
||||
var result model2.InstalledAppResponse
|
||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
||||
return model2.InstalledAppResponse{}, fmt.Errorf("error decoding response: %v", err)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
func (o *onePanelService) Login(m model2.OnePanelCredentials, baseURL string) (model2.LoginResponse, []*http.Cookie, error) {
|
||||
path := baseURL + prefixV1 + "/auth/login"
|
||||
|
||||
|
47
service/model/dto_onepanel_app.go
Normal file
47
service/model/dto_onepanel_app.go
Normal file
@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type InstalledAppRequest struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"pageSize"`
|
||||
Name string `json:"name"`
|
||||
Tags []interface{} `json:"tags"`
|
||||
Update bool `json:"update"`
|
||||
Sync bool `json:"sync"`
|
||||
}
|
||||
|
||||
type InstalledAppResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data struct {
|
||||
Total int `json:"total"`
|
||||
Items []struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
AppID int `json:"appID"`
|
||||
AppDetailID int `json:"appDetailID"`
|
||||
Version string `json:"version"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
HTTPPort int `json:"httpPort"`
|
||||
HTTPSPort int `json:"httpsPort"`
|
||||
Path string `json:"path"`
|
||||
CanUpdate bool `json:"canUpdate"`
|
||||
Icon string `json:"icon"`
|
||||
AppName string `json:"appName"`
|
||||
Ready int `json:"ready"`
|
||||
Total int `json:"total"`
|
||||
AppKey string `json:"appKey"`
|
||||
AppType string `json:"appType"`
|
||||
AppStatus string `json:"appStatus"`
|
||||
DockerCompose string `json:"dockerCompose"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
App struct {
|
||||
Website string `json:"website"`
|
||||
Document string `json:"document"`
|
||||
Github string `json:"github"`
|
||||
} `json:"app"`
|
||||
} `json:"items"`
|
||||
} `json:"data"`
|
||||
}
|
47
service/model/dto_onepanel_ssl.go
Normal file
47
service/model/dto_onepanel_ssl.go
Normal file
@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
type CreateSSLRequest struct {
|
||||
ID int `json:"id"`
|
||||
PrimaryDomain string `json:"primaryDomain"`
|
||||
OtherDomains string `json:"otherDomains"`
|
||||
Provider string `json:"provider"`
|
||||
WebsiteID int `json:"websiteId"`
|
||||
AcmeAccountID int `json:"acmeAccountId"`
|
||||
AutoRenew bool `json:"autoRenew"`
|
||||
KeyType string `json:"keyType"`
|
||||
PushDir bool `json:"pushDir"`
|
||||
Dir string `json:"dir"`
|
||||
Description string `json:"description"`
|
||||
DisableCNAME bool `json:"disableCNAME"`
|
||||
SkipDNS bool `json:"skipDNS"`
|
||||
Nameserver1 string `json:"nameserver1"`
|
||||
Nameserver2 string `json:"nameserver2"`
|
||||
ExecShell bool `json:"execShell"`
|
||||
Shell string `json:"shell"`
|
||||
}
|
||||
|
||||
type CreateSSLResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data struct {
|
||||
PrimaryDomain string `json:"primaryDomain"`
|
||||
OtherDomains string `json:"otherDomains"`
|
||||
Provider string `json:"provider"`
|
||||
AcmeAccountID int `json:"acmeAccountId"`
|
||||
DNSAccountID int `json:"dnsAccountId"`
|
||||
AutoRenew bool `json:"autoRenew"`
|
||||
KeyType string `json:"keyType"`
|
||||
Apply bool `json:"apply"`
|
||||
PushDir bool `json:"pushDir"`
|
||||
Dir string `json:"dir"`
|
||||
ID int `json:"id"`
|
||||
Description string `json:"description"`
|
||||
DisableCNAME bool `json:"disableCNAME"`
|
||||
SkipDNS bool `json:"skipDNS"`
|
||||
Nameserver1 string `json:"nameserver1"`
|
||||
Nameserver2 string `json:"nameserver2"`
|
||||
ExecShell bool `json:"execShell"`
|
||||
Shell string `json:"shell"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
87
service/model/dtop_onepanel_website.go
Normal file
87
service/model/dtop_onepanel_website.go
Normal file
@ -0,0 +1,87 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type SearchWebsiteRequest struct {
|
||||
Name string `json:"name"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"pageSize"`
|
||||
OrderBy string `json:"orderBy"`
|
||||
Order string `json:"order"`
|
||||
WebsiteGroupID int `json:"websiteGroupId"`
|
||||
}
|
||||
|
||||
type SearchWebsiteResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data struct {
|
||||
Total int `json:"total"`
|
||||
Items []struct {
|
||||
ID int `json:"id"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Protocol string `json:"protocol"`
|
||||
PrimaryDomain string `json:"primaryDomain"`
|
||||
Type string `json:"type"`
|
||||
Alias string `json:"alias"`
|
||||
Remark string `json:"remark"`
|
||||
Status string `json:"status"`
|
||||
ExpireDate time.Time `json:"expireDate"`
|
||||
SitePath string `json:"sitePath"`
|
||||
AppName string `json:"appName"`
|
||||
RuntimeName string `json:"runtimeName"`
|
||||
SslExpireDate time.Time `json:"sslExpireDate"`
|
||||
SslStatus string `json:"sslStatus"`
|
||||
AppInstallID int `json:"appInstallId"`
|
||||
RuntimeType string `json:"runtimeType"`
|
||||
} `json:"items"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type CreateWebsiteRequest struct {
|
||||
PrimaryDomain string `json:"primaryDomain"`
|
||||
Type string `json:"type"`
|
||||
Alias string `json:"alias"`
|
||||
Remark string `json:"remark"`
|
||||
AppType string `json:"appType"`
|
||||
WebSiteGroupID int `json:"webSiteGroupId"`
|
||||
OtherDomains string `json:"otherDomains"`
|
||||
Proxy string `json:"proxy"`
|
||||
Appinstall struct {
|
||||
AppID int `json:"appId"`
|
||||
Name string `json:"name"`
|
||||
AppDetailID int `json:"appDetailId"`
|
||||
Params struct {
|
||||
} `json:"params"`
|
||||
Version string `json:"version"`
|
||||
Appkey string `json:"appkey"`
|
||||
Advanced bool `json:"advanced"`
|
||||
CPUQuota int `json:"cpuQuota"`
|
||||
MemoryLimit int `json:"memoryLimit"`
|
||||
MemoryUnit string `json:"memoryUnit"`
|
||||
ContainerName string `json:"containerName"`
|
||||
AllowPort bool `json:"allowPort"`
|
||||
} `json:"appinstall"`
|
||||
IPV6 bool `json:"IPV6"`
|
||||
EnableFtp bool `json:"enableFtp"`
|
||||
FtpUser string `json:"ftpUser"`
|
||||
FtpPassword string `json:"ftpPassword"`
|
||||
ProxyType string `json:"proxyType"`
|
||||
Port int `json:"port"`
|
||||
ProxyProtocol string `json:"proxyProtocol"`
|
||||
ProxyAddress string `json:"proxyAddress"`
|
||||
RuntimeType string `json:"runtimeType"`
|
||||
}
|
||||
|
||||
type DeleteWebsiteRequest struct {
|
||||
ID int `json:"id"`
|
||||
DeleteApp bool `json:"deleteApp"`
|
||||
DeleteBackup bool `json:"deleteBackup"`
|
||||
ForceDelete bool `json:"forceDelete"`
|
||||
}
|
||||
|
||||
type GenericResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data struct {
|
||||
} `json:"data"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user