Skip to content

Commit

Permalink
revert deleted function
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <[email protected]>
  • Loading branch information
kartikaysaxena committed Feb 15, 2024
1 parent e16443e commit d07b960
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/apis/infrastructure/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,42 @@ func DisconnectInfra(projectID string, infraID string, cred types.Credentials) (
return DisconnectInfraData{}, err
}
}

func GetServerVersion(endpoint string) (ServerVersionResponse, error) {
var gqlReq ServerVersionRequest
var err error

gqlReq.Query = ServerVersionQuery
query, err := json.Marshal(gqlReq)
if err != nil {
return ServerVersionResponse{}, err
}
resp, err := apis.SendRequest(
apis.SendRequestParams{
Endpoint: endpoint + utils.GQLAPIPath,
},
query,
string(types.Post),
)
if err != nil {
return ServerVersionResponse{}, err
}
bodyBytes, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
return ServerVersionResponse{}, err
}
if resp.StatusCode == http.StatusOK {
var version ServerVersionResponse
err = json.Unmarshal(bodyBytes, &version)
if err != nil {
return ServerVersionResponse{}, err
}
if len(version.Errors) > 0 {
return ServerVersionResponse{}, errors.New(version.Errors[0].Message)
}
return version, nil
} else {
return ServerVersionResponse{}, errors.New(resp.Status)
}
}

0 comments on commit d07b960

Please sign in to comment.