Files
BlueArchiveToolkit/internal/api/responses.go
T

184 lines
7.1 KiB
Go

package api
import "net/http"
type ErrorResponse struct {
Error ErrorBody `json:"error"`
}
type ErrorBody struct {
Code string `json:"code"`
Message string `json:"message"`
Status int `json:"status"`
}
type RefreshDiagnostics struct {
InProgress bool `json:"in_progress"`
LastAttemptUnixSeconds *int64 `json:"last_attempt_unix_seconds"`
LastFinishedUnixSeconds *int64 `json:"last_finished_unix_seconds"`
LastSuccessUnixSeconds *int64 `json:"last_success_unix_seconds"`
LastDurationMilliseconds int64 `json:"last_duration_milliseconds"`
LastError string `json:"last_error"`
LastWarningCount int `json:"last_warning_count"`
LastWarnings []string `json:"last_warnings"`
RefreshIntervalSeconds int64 `json:"refresh_interval_seconds"`
ResourceRootOverrideActive bool `json:"resource_root_override_active"`
}
type BootstrapResponse struct {
Service string `json:"service"`
Ready bool `json:"ready"`
Bat BootstrapBat `json:"bat"`
BatAPI BootstrapAPI `json:"bat_api"`
Resource BootstrapResource `json:"resource"`
Policy BootstrapPolicy `json:"policy"`
Endpoints []string `json:"endpoints"`
Warnings []string `json:"warnings"`
}
type BootstrapBat struct {
Role string `json:"role"`
Socket string `json:"socket"`
RPCAvailable bool `json:"rpc_available"`
DoctorHealthy *bool `json:"doctor_healthy,omitempty"`
}
type BootstrapAPI struct {
Role string `json:"role"`
PublicBase string `json:"public_base"`
RefreshIntervalSeconds int64 `json:"refresh_interval_seconds"`
Refresh RefreshDiagnostics `json:"refresh"`
}
type BootstrapResource struct {
Release *SnapshotSummary `json:"release,omitempty"`
ResourceRoot string `json:"resource_root"`
Source string `json:"source"`
ManifestVersion int `json:"manifest_version,omitempty"`
EntryCount int `json:"entry_count"`
PresentCount int `json:"present_count"`
MissingCount int `json:"missing_count"`
ServerInfoURL string `json:"server_info_url"`
ClientPatchBaseURL string `json:"client_patch_base_url"`
AddressablesCatalogURLRoot string `json:"addressables_catalog_url_root,omitempty"`
}
type BootstrapPolicy struct {
PullOwner string `json:"pull_owner"`
ResourceRootDiscovery string `json:"resource_root_discovery"`
Deployment string `json:"deployment"`
ResourceRootOverride bool `json:"resource_root_override"`
ServesOnlyPublishedRelease bool `json:"serves_only_published_release"`
WritesReleaseState bool `json:"writes_release_state"`
FullGameBusinessAPI bool `json:"full_game_business_api"`
}
type RootResponse struct {
Service string `json:"service"`
Role string `json:"role"`
Note string `json:"note"`
Endpoints []string `json:"endpoints"`
}
type ResourceListResponse struct {
Total int `json:"total"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Items []ResourceEntry `json:"items"`
}
type LauncherBootstrapResponse struct {
Service string `json:"service"`
Ready bool `json:"ready"`
LauncherAPI LauncherAPIInfo `json:"launcher_api"`
Policy LauncherPolicy `json:"policy"`
Resource LauncherResource `json:"resource"`
Endpoints LauncherEndpointSet `json:"endpoints"`
GameMainConfig *GameMainConfigSummary `json:"game_main_config,omitempty"`
LauncherMetadata *LauncherMetadataSummary `json:"launcher_metadata,omitempty"`
AddressablesCatalogURLRoot string `json:"addressables_catalog_url_root,omitempty"`
}
type LauncherAPIInfo struct {
Host string `json:"host"`
ObservedResourceRelevantEndpoints []string `json:"observed_resource_relevant_endpoints"`
CompatibilityScope string `json:"compatibility_scope"`
}
type LauncherPolicy struct {
Source string `json:"source"`
DownloadsLauncherPackage bool `json:"downloads_launcher_package"`
EmulatesLoginOrGateway bool `json:"emulates_login_or_gateway"`
PackageUpdateManifest bool `json:"package_update_manifest"`
}
type LauncherResource struct {
Release *SnapshotSummary `json:"release,omitempty"`
ServerInfoURL string `json:"server_info_url"`
ClientPatchBaseURL string `json:"client_patch_base_url"`
}
type LauncherEndpointSet struct {
Bootstrap string `json:"bootstrap"`
LauncherBootstrap string `json:"launcher_bootstrap"`
ServerInfo string `json:"server_info"`
ClientPatchBase string `json:"client_patch_base"`
LauncherGameConfig string `json:"launcher_game_config"`
LauncherGameConfigJSON string `json:"launcher_game_config_json"`
LauncherCdnConfig string `json:"launcher_cdn_config"`
}
type LauncherGameConfigData struct {
GameLatestVersion string `json:"game_latest_version"`
GameLatestFilePath string `json:"game_latest_file_path"`
GameLowestVersion string `json:"game_lowest_version,omitempty"`
GameStartExeName string `json:"game_start_exe_name"`
GameStartParams []string `json:"game_start_params"`
ResourceBootstrapURL string `json:"resource_bootstrap_url"`
ServerInfoURL string `json:"server_info_url"`
ClientPatchBaseURL string `json:"client_patch_base_url"`
Scope string `json:"scope"`
}
type LauncherGameConfigJSONData struct {
URL string `json:"url"`
ResourceBootstrapURL string `json:"resource_bootstrap_url"`
PackageUpdateManifest bool `json:"package_update_manifest"`
Scope string `json:"scope"`
}
type LauncherCdnConfigData struct {
PrimaryCDN string `json:"primary_cdn"`
BackupCDN string `json:"back_up_cdn"`
ResourceBootstrapURL string `json:"resource_bootstrap_url"`
PackageUpdateManifest bool `json:"package_update_manifest"`
Scope string `json:"scope"`
}
type LauncherEnvelope[T any] struct {
Code int `json:"code"`
Message string `json:"message"`
Data T `json:"data"`
}
type AdminIndexResponse struct {
Service string `json:"service"`
Panel string `json:"panel"`
Status string `json:"status"`
Links []string `json:"links"`
Controls []string `json:"controls"`
}
type AdminControlResponse struct {
Service string `json:"service"`
Action string `json:"action"`
RPCMethod string `json:"rpc_method"`
Status string `json:"status"`
Result any `json:"result"`
}
func writeNoStoreJSON(w http.ResponseWriter, status int, body any) {
w.Header().Set("Cache-Control", "no-store")
writeJSON(w, status, body)
}