mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
feat: add GetResumeUrls to go client (#3810)
* feat: add GetResumeUrls to go client * add type ResumeUrls
This commit is contained in:
@@ -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,
|
||||
¶ms,
|
||||
)
|
||||
if err != nil {
|
||||
return urls, err
|
||||
}
|
||||
if res.StatusCode()/100 != 2 {
|
||||
return urls, errors.New(string(res.Body))
|
||||
}
|
||||
urls = *res.JSON200
|
||||
return urls, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user