2020-12-04 12:10:32 +00:00
|
|
|
package hub
|
2020-10-03 11:50:30 +00:00
|
|
|
|
2020-10-08 06:52:03 +00:00
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"runtime"
|
|
|
|
)
|
2020-10-03 11:50:30 +00:00
|
|
|
|
2023-05-18 02:43:50 +00:00
|
|
|
var ServiceURL = "https://my.photoprism.app/v1/hello"
|
2020-10-03 11:50:30 +00:00
|
|
|
|
2021-11-20 11:29:21 +00:00
|
|
|
// Request represents basic environment specs for debugging.
|
2020-10-03 11:50:30 +00:00
|
|
|
type Request struct {
|
|
|
|
ClientVersion string `json:"ClientVersion"`
|
2020-12-05 05:21:16 +00:00
|
|
|
ClientSerial string `json:"ClientSerial"`
|
2020-10-03 11:50:30 +00:00
|
|
|
ClientOS string `json:"ClientOS"`
|
|
|
|
ClientArch string `json:"ClientArch"`
|
|
|
|
ClientCPU int `json:"ClientCPU"`
|
2022-03-02 13:16:49 +00:00
|
|
|
ClientEnv string `json:"ClientEnv"`
|
|
|
|
PartnerID string `json:"PartnerID"`
|
2022-07-19 14:58:43 +00:00
|
|
|
ApiToken string `json:"ApiToken"`
|
2020-10-03 11:50:30 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 11:29:21 +00:00
|
|
|
// NewRequest creates a new backend key request instance.
|
2022-07-19 14:58:43 +00:00
|
|
|
func NewRequest(version, serial, env, partnerId, token string) *Request {
|
2020-10-03 11:50:30 +00:00
|
|
|
return &Request{
|
|
|
|
ClientVersion: version,
|
2020-12-05 05:21:16 +00:00
|
|
|
ClientSerial: serial,
|
2020-10-03 11:50:30 +00:00
|
|
|
ClientOS: runtime.GOOS,
|
|
|
|
ClientArch: runtime.GOARCH,
|
|
|
|
ClientCPU: runtime.NumCPU(),
|
2022-03-02 13:16:49 +00:00
|
|
|
ClientEnv: env,
|
|
|
|
PartnerID: partnerId,
|
2022-07-19 14:58:43 +00:00
|
|
|
ApiToken: token,
|
2020-10-03 11:50:30 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-08 06:52:03 +00:00
|
|
|
|
2021-11-20 11:29:21 +00:00
|
|
|
// ApiHost returns the backend host name.
|
2020-10-08 06:52:03 +00:00
|
|
|
func ApiHost() string {
|
2020-12-04 12:10:32 +00:00
|
|
|
u, err := url.Parse(ServiceURL)
|
2020-10-08 06:52:03 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Warn(err)
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return u.Host
|
|
|
|
}
|