From 86fba6637036d0f0cdf61d616e4c7e57d082a562 Mon Sep 17 00:00:00 2001 From: Fendy Date: Mon, 3 Aug 2026 12:25:51 +0800 Subject: [PATCH] finish some public api rename public service --- apis/public/client.go | 6 +++--- apis/public/get_app_config.go | 2 +- apis/public/get_news.go | 28 ++++++++++++++++++++++++++++ apis/public/get_status.go | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 apis/public/get_news.go diff --git a/apis/public/client.go b/apis/public/client.go index ab57401..0bfe07d 100644 --- a/apis/public/client.go +++ b/apis/public/client.go @@ -2,10 +2,10 @@ package public import "github.com/XingfenD/rainyun_api_go_sdk/apis" -type Service struct { +type PublicService struct { client *apis.Client } -func NewService(c *apis.Client) *Service { - return &Service{client: c} +func NewPublicService(c *apis.Client) *PublicService { + return &PublicService{client: c} } diff --git a/apis/public/get_app_config.go b/apis/public/get_app_config.go index 185b3d2..4e4627b 100644 --- a/apis/public/get_app_config.go +++ b/apis/public/get_app_config.go @@ -24,7 +24,7 @@ type AppConfigValue struct { OriginalIndex int `json:"originalIndex"` } -func (s *Service) GetAppConfig() (*GetAppConfigResponse, error) { +func (s *PublicService) GetAppConfig() (*GetAppConfigResponse, error) { path := "/app_config" var resp GetAppConfigResponse err := s.client.Do(constant.HTTPMethod_GET, path, nil, &resp) diff --git a/apis/public/get_news.go b/apis/public/get_news.go new file mode 100644 index 0000000..8e75c43 --- /dev/null +++ b/apis/public/get_news.go @@ -0,0 +1,28 @@ +package public + +import ( + "time" + + "github.com/XingfenD/rainyun_api_go_sdk/constant" +) + +type GetNewsResponse struct { + Code int `json:"code"` + Data []RainyunNewsItem `json:"data"` +} + +type RainyunNewsItem struct { + Type string `json:"Type"` + Title string `json:"Title"` + TimeStamp time.Time `json:"TimeStamp"` + URL string `json:"URL"` +} + +func (s *PublicService) GetNews() (*GetNewsResponse, error) { + path := "/news" + + var resp GetNewsResponse + err := s.client.Do(constant.HTTPMethod_GET, path, nil, &resp) + + return &resp, err +} diff --git a/apis/public/get_status.go b/apis/public/get_status.go index 9fd24e5..ccf6ecf 100644 --- a/apis/public/get_status.go +++ b/apis/public/get_status.go @@ -1 +1,34 @@ package public + +import "github.com/XingfenD/rainyun_api_go_sdk/constant" + +type GetStatusResponse struct { + Code int `json:"code"` + Data NodeStatus `json:"data"` +} + +type NodeStatus struct { + TotalRecords int `json:"TotalRecords"` + OngoingServiceEvents []interface{} `json:"OngoingServiceEvents"` + Records []NodeStatusRecordItem `json:"Records"` +} + +type NodeStatusRecordItem struct { + UUID string `json:"UUID"` + ChineseName string `json:"ChineseName"` + Product string `json:"Product"` + CPU float64 `json:"CPU"` + Memory float64 `json:"Memory"` + NetOut int `json:"NetOut"` + UpdateTime string `json:"UpdateTime"` + Status string `json:"Status"` + Data string `json:"Data"` +} + +func (s *PublicService) GetStatus() (*GetStatusResponse, error) { + path := "/status" + + var resp GetStatusResponse + err := s.client.Do(constant.HTTPMethod_GET, path, nil, &resp) + return &resp, err +}