package scm_sdk import ( "encoding/json" "errors" "github.com/go-resty/resty/v2" "net/url" "time" ) const ( timeoutSec = 30 ) const ( getCurrentConfigurationUrl = "/scm/api/inner/configuration/current/query" ) func GetCurrentConfiguration(baseUrl string, namespace string, name string) (*ConfigurationInfo, error) { fullUrl, err := url.JoinPath(baseUrl, getCurrentConfigurationUrl) if err != nil { return nil, err } resp, err := resty.New().SetTimeout(timeoutSec*time.Second).R(). SetHeader("Content-Type", "application/json"). SetQueryParams(map[string]string{ "namespace": namespace, "name": name, }). Get(fullUrl) if err != nil { return nil, err } if resp.IsError() { return nil, errors.New(resp.Status()) } response := new(GetCurrentConfigurationResponse) err = json.Unmarshal(resp.Body(), response) if err != nil { return nil, err } if !response.Success { return nil, errors.New(response.Msg) } return response.Info, nil }