Skip to content

Commit

Permalink
add /health API to CL client (#13164)
Browse files Browse the repository at this point in the history
  • Loading branch information
skudasov authored May 13, 2024
1 parent 811fe60 commit 98221e1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions integration-tests/client/chainlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ func (c *ChainlinkClient) URL() string {
return c.Config.URL
}

// Health returns all statuses health info
func (c *ChainlinkClient) Health() (*HealthResponse, *http.Response, error) {
respBody := &HealthResponse{}
c.l.Info().Str(NodeURL, c.Config.URL).Msg("Requesting health data")
resp, err := c.APIClient.R().
SetResult(&respBody).
Get("/health")
if err != nil {
return nil, nil, err
}
return respBody, resp.RawResponse, err
}

// CreateJobRaw creates a Chainlink job based on the provided spec string
func (c *ChainlinkClient) CreateJobRaw(spec string) (*Job, *http.Response, error) {
job := &Job{}
Expand Down
13 changes: 13 additions & 0 deletions integration-tests/client/chainlink_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ type ResponseSlice struct {
Data []map[string]interface{}
}

// HealthResponse is the generic model for services health statuses
type HealthResponse struct {
Data []struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Name string `json:"name"`
Status string `json:"status"`
Output string `json:"output"`
} `json:"attributes"`
} `json:"data"`
}

// Response is the generic model that can be used for all Chainlink API responses
type Response struct {
Data map[string]interface{}
Expand Down

0 comments on commit 98221e1

Please sign in to comment.