feat: add GetResumeUrls to go client (#3810)

* feat: add GetResumeUrls to go client

* add type ResumeUrls
This commit is contained in:
William Butez
2024-05-24 12:47:50 +02:00
committed by GitHub
parent a85eacdea3
commit e5824f0bab
+37
View File
@@ -4,9 +4,12 @@ import (
"context"
"errors"
"fmt"
"math"
"math/rand"
"net/http"
"os"
"github.com/google/uuid"
api "github.com/windmill-labs/windmill-go-client/api"
)
@@ -154,3 +157,37 @@ func SetState(state interface{}) error {
}
return nil
}
type ResumeUrls struct {
ApprovalPage string `json:"approvalPage"`
Cancel string `json:"cancel"`
Resume string `json:"resume"`
}
func GetResumeUrls(approver string) (ResumeUrls, error) {
var urls ResumeUrls
client, err := GetClient()
if err != nil {
return urls, err
}
jobId, err := uuid.Parse(os.Getenv("WM_JOB_ID"))
if err != nil {
return urls, err
}
params := api.GetResumeUrlsParams{Approver: &approver}
nonce := rand.Intn(int(math.MaxUint32))
res, err := client.Client.GetResumeUrlsWithResponse(context.Background(),
client.Workspace,
jobId,
nonce,
&params,
)
if err != nil {
return urls, err
}
if res.StatusCode()/100 != 2 {
return urls, errors.New(string(res.Body))
}
urls = *res.JSON200
return urls, nil
}