Documentation
¶
Index ¶
- func MD5(s string) string
- type Client
- func (this *Client) AddDomain(id int64, webname string, domain string) (RespMSG, error)
- func (this *Client) AddSite(params *ReqAddSite) (RespAddSite, error)
- func (this *Client) CloseHasPwd(id int64) (RespMSG, error)
- func (this *Client) CloseLimitNet(id int64) (RespMSG, error)
- func (this *Client) DelDomain(id int64, webname string, domain string, port int64) (RespMSG, error)
- func (this *Client) DeleteSite(params *ReqDeleteSite) (RespMSG, error)
- func (this *Client) DeleteSiteBackup(id int64) (RespMSG, error)
- func (this *Client) GetDirUserINI(id int64, path string) (RespUserINI, error)
- func (this *Client) GetDiskInfo() (DiskInfo, error)
- func (this *Client) GetFile(path string) (RespGetFile, error)
- func (this *Client) GetIndex(id int64) (string, error)
- func (this *Client) GetLimitNet(id int64) (RespLimitNet, error)
- func (this *Client) GetNetWork() (NetWork, error)
- func (this *Client) GetPHPVersion() (PHPVersions, error)
- func (this *Client) GetRewriteList(siteName string) (RewriteList, error)
- func (this *Client) GetSiteBackups(params *ReqSiteBackups) (RespSiteBackups, error)
- func (this *Client) GetSiteDomains(search int64) (SiteDomains, error)
- func (this *Client) GetSites(params *ReqSites) (RespSites, error)
- func (this *Client) GetSystemTotal() (SystemTotal, error)
- func (this *Client) GetTaskCount() int
- func (this *Client) GetUpdateStatus(check bool, force bool) (UpdateStatus, error)
- func (this *Client) Raw(data map[string][]string, endpoint string) ([]byte, error)deprecated
- func (this *Client) SetDirUserINI(path string) (RespMSG, error)
- func (this *Client) SetFile(path string, body string) (RespMSG, error)
- func (this *Client) SetHasPwd(id int64, user string, pwd string) (RespMSG, error)
- func (this *Client) SetIndex(id int64, Index string) (RespMSG, error)
- func (this *Client) SetLimitNet(id int64, perServer int64, perIP int64, limitRate int64) (RespMSG, error)
- func (this *Client) SetLogsOpen(id int64) (RespMSG, error)
- func (this *Client) SetPath(id int64, path string) (RespMSG, error)
- func (this *Client) SetRunPath(id int64, path string) (RespMSG, error)
- func (this *Client) SetSiteEdate(id int64, edate string) (RespMSG, error)
- func (this *Client) SetSitePS(id int64, ps string) (RespMSG, error)
- func (this *Client) SiteBackup(id int64) (RespMSG, error)
- func (this *Client) StartSite(id int64, name string) (RespMSG, error)
- func (this *Client) StopSite(id int64, name string) (RespMSG, error)
- type DiskInfo
- type NetWork
- type PHPVersions
- type ReqAddSite
- type ReqDeleteSite
- type ReqSiteBackups
- type ReqSites
- type RespAddSite
- type RespGetFile
- type RespLimitNet
- type RespMSG
- type RespSiteBackups
- type RespSites
- type RespUserINI
- type RewriteList
- type SiteDomains
- type SiteTypes
- type SystemTotal
- type UpdateStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
BTAddress string // 目标宝塔面板地址 eg.http://10.0.0.14:8888 结尾不要有斜杠
BTKey string // API Key 还需要添加 IP 白名单
Timeout time.Duration
// contains filtered or unexported fields
}
Client 每个 Client 对象对应一个宝塔面板 先实例化再调用接口
func (*Client) AddSite ¶
func (this *Client) AddSite(params *ReqAddSite) (RespAddSite, error)
AddSite 创建网站
func (*Client) CloseHasPwd ¶
CloseHasPwd 关闭网站密码访问
func (*Client) CloseLimitNet ¶
CloseLimitNet 关闭流量限制
func (*Client) DeleteSite ¶
func (this *Client) DeleteSite(params *ReqDeleteSite) (RespMSG, error)
DeleteSite 删除网站
func (*Client) DeleteSiteBackup ¶
DeleteSiteBackup 删除网站备份
func (*Client) GetDirUserINI ¶
func (this *Client) GetDirUserINI(id int64, path string) (RespUserINI, error)
GetDirUserINI 取回防跨站配置/运行目录/日志开关状态/可设置的运行目录列表/密码访问状态
func (*Client) GetDiskInfo ¶
GetDiskInfo 获取磁盘分区信息
func (*Client) GetLimitNet ¶
func (this *Client) GetLimitNet(id int64) (RespLimitNet, error)
GetLimitNet 获取流量限制相关配置(仅支持 nginx)
func (*Client) GetNetWork ¶
GetNetWork 获取实时状态信息(CPU、内存、网络、负载)
func (*Client) GetPHPVersion ¶
func (this *Client) GetPHPVersion() (PHPVersions, error)
GetPHPVersion 获取已安装的 PHP 版本列表
func (*Client) GetRewriteList ¶
func (this *Client) GetRewriteList(siteName string) (RewriteList, error)
GetRewriteList 获取网站可选伪静态列表
func (*Client) GetSiteBackups ¶
func (this *Client) GetSiteBackups(params *ReqSiteBackups) (RespSiteBackups, error)
GetSiteBackups 获取网站备份列表
func (*Client) GetSiteDomains ¶
func (this *Client) GetSiteDomains(search int64) (SiteDomains, error)
GetSiteDomains 获取网站域名列表
func (*Client) GetSystemTotal ¶
func (this *Client) GetSystemTotal() (SystemTotal, error)
GetSystemTotal 获取系统基础统计
func (*Client) GetUpdateStatus ¶
func (this *Client) GetUpdateStatus(check bool, force bool) (UpdateStatus, error)
GetUpdateStatus 检查面板更新
func (*Client) SetDirUserINI ¶
SetDirUserINI 设置防跨站状态(自动取反)
func (*Client) SetIndex ¶
SetIndex 设置默认文档 ep. Index : "index.php,index.html,index.htm,default.php,default.htm,default.html"
func (*Client) SetLimitNet ¶
func (this *Client) SetLimitNet(id int64, perServer int64, perIP int64, limitRate int64) (RespMSG, error)
SetLimitNet 开启或保存流量限制配置(仅支持 nginx)
func (*Client) SetLogsOpen ¶
SetLogsOpen 设置是否写访问日志
func (*Client) SetRunPath ¶
SetRunPath 修改网站运行目录 path 填相对目录 比如 "/public"
func (*Client) SetSiteEdate ¶
SetSiteEdate 设置网站过期时间 格式 “0000-00-00”(全 0 为永久)
func (*Client) SiteBackup ¶
SiteBackup 创建网站备份
type DiskInfo ¶
type DiskInfo []struct {
Path string `json:"path"`
Inodes []string `json:"inodes"`
Size []string `json:"size"`
}
DiskInfo 获取磁盘分区信息 URI 地址:/system?action=GetDiskInfo
type NetWork ¶
type NetWork struct {
Load struct {
Max int `json:"max"` // 最高值
Safe float64 `json:"safe"` // 安全值
One float64 `json:"one"` // 1 分钟
Five float64 `json:"five"` // 5 分钟
Limit int `json:"limit"` // 限制
Fifteen float64 `json:"fifteen"` // 10 分钟
} `json:"load"` // 负载实时信息
Down float64 `json:"down"` // 下行流量 (KB)
DownTotal int64 `json:"downTotal"` // 总接收 (Byte)
Version string `json:"version"` // 面板版本
Mem struct {
MemFree int `json:"memFree"` // 可用内存(MB)
MemTotal int `json:"memTotal"` // 总共内存(MB)
MemCached int `json:"memCached"` // 缓存化内存(MB)
MemBuffers int `json:"memBuffers"` // 系统缓冲(MB)
MemRealUsed int `json:"memRealUsed"` // 实际使用内存(MB)
} `json:"mem"` // 内存实时信息
Up float64 `json:"up"` // 上行流量(KB)
UpTotal int64 `json:"upTotal"` // 总发送 (Byte)
UpPackets int `json:"upPackets"` // 总发包 (个)
Disk []struct {
Path string `json:"path"` // 挂载点
Inodes []string `json:"inodes"` // Inode使用信息 数组同下
Size []string `json:"size"` // 0-总共(GB) 1-已用(GB) 2-可用(GB) 3-使用率(百分比 带%)
} `json:"disk"` // 磁盘
DownPackets int `json:"downPackets"` // 总收包(个)
CPU []interface{} `json:"cpu"` // 0-总体使用率 1-核心数 2-[0-CPU0 1-CPU1]使用率 3-CPU型号
}
NetWork 获取实时状态信息(CPU、内存、网络、负载) URI 地址:/system?action=GetNetWork
type PHPVersions ¶
PHPVersions 获取已安装的 PHP 版本列表 URI 地址:/site?action=GetPHPVersion
type ReqAddSite ¶
type ReqAddSite struct {
WebName struct {
Domain string `json:"domain"` // 必填
DomainList []string `json:"domainlist"` // 必填
Count int `json:"count"` // 必填
}
Path string // 必填
TypeID int64 // 必填
Type string // 必填
Version int64 // 必填
Port int64 // 必填
PS string // 必填
FTP bool // 必填
FTPUserName string // FTP 为 true 时 必填
FTPPassword string // FTP 为 true 时 必填
SQL bool // 必填
Codeing string // SQL 为 true 时 必填
DataUser string // SQL 为 true 时 必填
DataPassword string // SQL 为 true 时 必填
}
ReqAddSite 创建网站 URI 地址:/site?action=AddSite
type ReqDeleteSite ¶
ReqDeleteSite 删除网站 URI 地址:/site?action=DeleteSite
type ReqSiteBackups ¶
type ReqSiteBackups struct {
P int64
Limit int64 // 必填
Type int64 // 必不填或填0
ToJS string
Search int64 // 必填
}
ReqSiteBackups 获取网站备份列表 URI 地址:/data?action=getData&table=backup
type ReqSites ¶
type ReqSites struct {
P int64
Limit int64 // 必填
Type int64
Order string
ToJS string
Search string
}
ReqSites 获取网站列表 URI 地址:/data?action=getData&table=sites
type RespAddSite ¶
type RespAddSite struct {
FtpStatus bool `json:"ftpStatus"`
DatabaseUser string `json:"databaseUser"`
DatabaseStatus bool `json:"databaseStatus"`
FtpUser string `json:"ftpUser"`
DatabasePass string `json:"databasePass"`
SiteStatus bool `json:"siteStatus"`
FtpPass string `json:"ftpPass"`
}
RespAddSite 创建网站 URI 地址:/site?action=AddSite
type RespGetFile ¶
type RespGetFile struct {
Status bool `json:"status"`
Data string `json:"data"`
Encoding string `json:"encoding"`
}
RespGetFile 获取指定文件
type RespLimitNet ¶
type RespLimitNet struct {
LimitRate int `json:"limit_rate"`
Perserver int `json:"perserver"`
Perip int `json:"perip"`
}
RespLimitNet 获取网络限制
type RespSiteBackups ¶
type RespSiteBackups struct {
Data []struct {
Name string `json:"name"`
Addtime string `json:"addtime"`
Pid int `json:"pid"`
Filename string `json:"filename"`
ID int `json:"id"`
Size int `json:"size"`
} `json:"data"`
Where string `json:"where"`
Page string `json:"page"`
}
RespSiteBackups 获取网站备份列表 URI 地址:/data?action=getData&table=backup
type RespSites ¶
type RespSites struct {
Data []struct {
Status string `json:"status"`
Ps string `json:"ps"`
Domain int `json:"domain"`
Name string `json:"name"`
Addtime string `json:"addtime"`
Path string `json:"path"`
BackupCount int `json:"backup_count"`
Edate string `json:"edate"`
ID int `json:"id"`
} `json:"data"`
Where string `json:"where"`
Page string `json:"page"`
}
RespSites 获取网站列表 URI 地址:/data?action=getData&table=sites
type RespUserINI ¶
type RewriteList ¶
type RewriteList struct {
Rewrites []string `json:"rewrite"`
}
RewriteList 伪静态可用列表
type SiteDomains ¶
type SiteDomains []struct {
Port int `json:"port"`
Addtime string `json:"addtime"`
Pid int `json:"pid"`
ID int `json:"id"`
Name string `json:"name"`
}
SiteDomains 获取网站的域名列表 URI 地址:/data?action=getData&table=domain
type SystemTotal ¶
type SystemTotal struct {
CPURealUsed float64 `json:"cpuRealUsed"` // cpu使用率(百分比)
MemTotal int `json:"memTotal"` // 物理内存容量(MB)
System string `json:"system"` // 操作系统信息
MemRealUsed int `json:"memRealUsed"` // 物已使用的物理内存 (MB)
CPUNum int `json:"cpuNum"` // CPU 核心数
MemFree int `json:"memFree"` // 可用物理内存
Version string `json:"version"` // 面板版本
Time string `json:"time"` // 上次开机到现在的运行时间
MemCached int `json:"memCached"` // 缓存化的内存
MemBuffers int `json:"memBuffers"` // 系统缓冲 (MB)
Isuser int `json:"isuser"` // ?
}
SystemTotal 获取系统基础统计 URI 地址:/system?action=GetSystemTotal
type UpdateStatus ¶
type UpdateStatus struct {
Status bool `json:"status"`
Version string `json:"version"`
UpdateMsg string `json:"updateMsg"`
}
UpdateStatus 检查面板更新 URI 地址:/ajax?action=UpdatePanel