@@ -87,11 +87,7 @@ func (c Client) GetSkillLatestVersion() (string, error) {
8787 defer resp .Body .Close ()
8888
8989 if resp .StatusCode != 200 {
90- msg := extractErrorMessage (resp .Body )
91- if msg == "" {
92- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
93- }
94- return "" , errors .New (msg )
90+ return "" , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
9591 }
9692
9793 var result struct {
@@ -141,11 +137,7 @@ func (c Client) GetDebugConnectionInfo(debugKey string) (DebugConnectionInfo, er
141137 }
142138 return connectionInfo , errors .ErrGone
143139 default :
144- msg := extractErrorMessage (resp .Body )
145- if msg == "" {
146- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
147- }
148- return connectionInfo , errors .New (msg )
140+ return connectionInfo , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
149141 }
150142
151143 if err := json .NewDecoder (resp .Body ).Decode (& connectionInfo ); err != nil {
@@ -202,11 +194,7 @@ func (c Client) GetSandboxConnectionInfo(runID, scopedToken string) (SandboxConn
202194 }
203195 return connectionInfo , errors .ErrGone
204196 default :
205- msg := extractErrorMessage (resp .Body )
206- if msg == "" {
207- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
208- }
209- return connectionInfo , errors .New (msg )
197+ return connectionInfo , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
210198 }
211199
212200 if err := json .NewDecoder (resp .Body ).Decode (& connectionInfo ); err != nil {
@@ -352,11 +340,15 @@ func (c Client) InitiateDispatch(cfg InitiateDispatchConfig) (*InitiateDispatchR
352340 defer resp .Body .Close ()
353341
354342 if resp .StatusCode != 201 {
355- msg := extractErrorMessage (resp .Body )
356- if msg == "" {
357- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
343+ errorStruct := struct {
344+ Error string `json:"error,omitempty"`
345+ }{}
346+
347+ if err := json .NewDecoder (resp .Body ).Decode (& errorStruct ); err != nil {
348+ return nil , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
358349 }
359- return nil , errors .New (msg )
350+
351+ return nil , errors .New (errorStruct .Error )
360352 }
361353
362354 respBody := struct {
@@ -389,11 +381,7 @@ func (c Client) GetDispatch(cfg GetDispatchConfig) (*GetDispatchResult, error) {
389381 defer resp .Body .Close ()
390382
391383 if resp .StatusCode != 200 {
392- msg := extractErrorMessage (resp .Body )
393- if msg == "" {
394- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
395- }
396- return nil , errors .New (msg )
384+ return nil , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
397385 }
398386
399387 respBody := struct {
@@ -440,11 +428,7 @@ func (c Client) ObtainAuthCode(cfg ObtainAuthCodeConfig) (*ObtainAuthCodeResult,
440428 defer resp .Body .Close ()
441429
442430 if resp .StatusCode != 201 {
443- msg := extractErrorMessage (resp .Body )
444- if msg == "" {
445- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
446- }
447- return nil , errors .New (msg )
431+ return nil , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
448432 }
449433
450434 respBody := ObtainAuthCodeResult {}
@@ -470,11 +454,7 @@ func (c Client) AcquireToken(tokenUrl string) (*AcquireTokenResult, error) {
470454 defer resp .Body .Close ()
471455
472456 if resp .StatusCode != 200 {
473- msg := extractErrorMessage (resp .Body )
474- if msg == "" {
475- msg = fmt .Sprintf ("Unable to query the token URL - %s" , resp .Status )
476- }
477- return nil , errors .New (msg )
457+ return nil , errors .New (fmt .Sprintf ("Unable to query the token URL - %s" , resp .Status ))
478458 }
479459
480460 respBody := AcquireTokenResult {}
@@ -503,11 +483,7 @@ func (c Client) Whoami() (*WhoamiResult, error) {
503483 defer resp .Body .Close ()
504484
505485 if resp .StatusCode != 200 {
506- msg := extractErrorMessage (resp .Body )
507- if msg == "" {
508- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
509- }
510- return nil , errors .New (msg )
486+ return nil , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
511487 }
512488
513489 respBody := WhoamiResult {}
@@ -535,11 +511,7 @@ func (c Client) CreateDocsToken() (*DocsTokenResult, error) {
535511 defer resp .Body .Close ()
536512
537513 if resp .StatusCode != 201 && resp .StatusCode != 200 {
538- msg := extractErrorMessage (resp .Body )
539- if msg == "" {
540- msg = fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status )
541- }
542- return nil , errors .New (msg )
514+ return nil , errors .New (fmt .Sprintf ("Unable to call RWX API - %s" , resp .Status ))
543515 }
544516
545517 respBody := DocsTokenResult {}
@@ -955,10 +927,7 @@ func (c Client) ImagePushStatus(pushID string) (ImagePushStatusResult, error) {
955927}
956928
957929func (c Client ) TaskKeyStatus (cfg TaskKeyStatusConfig ) (TaskStatusResult , error ) {
958- params := url.Values {}
959- params .Set ("run_id" , cfg .RunID )
960- params .Set ("task_key" , cfg .TaskKey )
961- endpoint := "/mint/api/results/task_status?" + params .Encode ()
930+ endpoint := fmt .Sprintf ("/mint/api/runs/%s/task_status?task_key=%s" , url .PathEscape (cfg .RunID ), url .PathEscape (cfg .TaskKey ))
962931 result := TaskStatusResult {}
963932
964933 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
@@ -982,7 +951,7 @@ func (c Client) TaskKeyStatus(cfg TaskKeyStatusConfig) (TaskStatusResult, error)
982951}
983952
984953func (c Client ) TaskIDStatus (cfg TaskIDStatusConfig ) (TaskStatusResult , error ) {
985- endpoint := fmt .Sprintf ("/mint/api/results/status?id=%s " , url .QueryEscape (cfg .TaskID ))
954+ endpoint := fmt .Sprintf ("/mint/api/tasks/%s/status " , url .PathEscape (cfg .TaskID ))
986955 result := TaskStatusResult {}
987956
988957 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
@@ -1009,24 +978,16 @@ func (c Client) RunStatus(cfg RunStatusConfig) (RunStatusResult, error) {
1009978 var endpoint string
1010979 failFast := fmt .Sprintf ("%t" , cfg .FailFast )
1011980 if cfg .RunID != "" {
1012- params := url.Values {}
1013- params .Set ("id" , cfg .RunID )
1014- params .Set ("fail_fast" , failFast )
1015- endpoint = "/mint/api/results/status?" + params .Encode ()
981+ endpoint = fmt .Sprintf ("/mint/api/runs/%s?fail_fast=%s" , url .PathEscape (cfg .RunID ), failFast )
1016982 } else {
1017983 params := url.Values {}
1018984 params .Set ("fail_fast" , failFast )
1019- if cfg .BranchName != "" {
1020- params .Set ("branch_name" , cfg .BranchName )
1021- }
985+ params .Set ("branch_name" , cfg .BranchName )
1022986 params .Set ("repository_name" , cfg .RepositoryName )
1023987 if cfg .DefinitionPath != "" {
1024988 params .Set ("definition_path" , cfg .DefinitionPath )
1025989 }
1026- if cfg .CommitSha != "" {
1027- params .Set ("commit_sha" , cfg .CommitSha )
1028- }
1029- endpoint = "/mint/api/results/latest?" + params .Encode ()
990+ endpoint = "/mint/api/runs/latest?" + params .Encode ()
1030991 }
1031992 result := RunStatusResult {}
1032993
@@ -1051,7 +1012,7 @@ func (c Client) RunStatus(cfg RunStatusConfig) (RunStatusResult, error) {
10511012}
10521013
10531014func (c Client ) GetRunPrompt (runID string ) (string , error ) {
1054- endpoint := fmt .Sprintf ("/mint/api/results/prompt?id=%s " , url .QueryEscape (runID ))
1015+ endpoint := fmt .Sprintf ("/mint/api/runs/%s/prompt " , url .PathEscape (runID ))
10551016
10561017 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
10571018 if err != nil {
0 commit comments