|
|
@@ -13,12 +13,12 @@ const (
|
|
|
lintWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/lint"
|
|
|
submitWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/submit"
|
|
|
resubmitWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/resubmit"
|
|
|
- resumeWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/resume"
|
|
|
retryWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/retry"
|
|
|
setWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/set"
|
|
|
stopWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/stop"
|
|
|
- suspendWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/suspend"
|
|
|
terminateWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/terminate"
|
|
|
+ suspendWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/suspend"
|
|
|
+ resumeWorkflowRelativeUrl = "/api/v1/workflows/{namespace}/{name}/resume"
|
|
|
getEventsStreamRelativeUrl = "/api/v1/stream/events/{namespace}"
|
|
|
getWorkflowEventsStreamRelativeUrl = "/api/v1/workflow-events/{namespace}"
|
|
|
)
|
|
|
@@ -314,54 +314,143 @@ func (c *Client) SubmitWorkflowFromWorkflowTemplate(params SubmitWorkflowFromWor
|
|
|
type ResubmitWorkflowParams struct {
|
|
|
Namespace string
|
|
|
Name string
|
|
|
+ Memoized bool
|
|
|
ResubmitParameters []string
|
|
|
}
|
|
|
|
|
|
-func (c *Client) ResubmitWorkflow(params ResubmitWorkflowParams) error {
|
|
|
- return nil
|
|
|
-}
|
|
|
+func (c *Client) ResubmitWorkflow(params ResubmitWorkflowParams) (string, error) {
|
|
|
+ responseMap := make(map[string]any)
|
|
|
|
|
|
-type ResumeWorkflowParams struct {
|
|
|
- Namespace string
|
|
|
- Name string
|
|
|
-}
|
|
|
+ resp, err := c.restyClient.R().
|
|
|
+ SetHeader("Content-Type", "application/json").
|
|
|
+ SetAuthToken(c.token).
|
|
|
+ SetPathParams(map[string]string{
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
+ }).
|
|
|
+ SetBody(map[string]any{
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
+ "memoized": params.Memoized,
|
|
|
+ "parameters": params.ResubmitParameters,
|
|
|
+ }).
|
|
|
+ SetResult(&responseMap).
|
|
|
+ SetError(&responseMap).
|
|
|
+ Put(resubmitWorkflowRelativeUrl)
|
|
|
+ if err != nil {
|
|
|
+ return "", errors.New(err.Error())
|
|
|
+ }
|
|
|
|
|
|
-func (c *Client) ResumeWorkflow(params ResumeWorkflowParams) error {
|
|
|
- return nil
|
|
|
+ switch resp.StatusCode() {
|
|
|
+ case http.StatusOK:
|
|
|
+ metadata, ok := responseMap["metadata"]
|
|
|
+ if !ok {
|
|
|
+ return "", errors.New("metadata为空")
|
|
|
+ }
|
|
|
+
|
|
|
+ metadataMap, ok := metadata.(map[string]any)
|
|
|
+ if !ok {
|
|
|
+ return "", errors.New("metadata不是map")
|
|
|
+ }
|
|
|
+
|
|
|
+ workflowName, ok := metadataMap["name"]
|
|
|
+ if !ok {
|
|
|
+ return "", errors.New("metadata中没有工作流名称")
|
|
|
+ }
|
|
|
+
|
|
|
+ workflowNameStr, ok := workflowName.(string)
|
|
|
+ if !ok {
|
|
|
+ return "", errors.New("工作流名称不是字符串")
|
|
|
+ }
|
|
|
+
|
|
|
+ return workflowNameStr, nil
|
|
|
+ case http.StatusConflict:
|
|
|
+ return "", errors.New("工作流已存在")
|
|
|
+ default:
|
|
|
+ message, ok := responseMap["message"]
|
|
|
+ if !ok {
|
|
|
+ return "", errors.Errorf("%v", resp.Status())
|
|
|
+ }
|
|
|
+
|
|
|
+ return "", errors.Errorf("%v, %v", resp.Status(), message)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
type RetryWorkflowParams struct {
|
|
|
- Namespace string
|
|
|
- Name string
|
|
|
- RetryParameters []string
|
|
|
- RetryOnSuccessWorkflowNodeFieldSelector string
|
|
|
+ Namespace string
|
|
|
+ Name string
|
|
|
+ RetryParameters []string
|
|
|
+ RetryOnSuccessfulWorkflow bool
|
|
|
+ SuccessfulWorkflowNodeFieldSelector string
|
|
|
}
|
|
|
|
|
|
func (c *Client) RetryWorkflow(params RetryWorkflowParams) error {
|
|
|
- return nil
|
|
|
+ responseMap := make(map[string]any)
|
|
|
+
|
|
|
+ resp, err := c.restyClient.R().
|
|
|
+ SetHeader("Content-Type", "application/json").
|
|
|
+ SetAuthToken(c.token).
|
|
|
+ SetPathParams(map[string]string{
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
+ }).
|
|
|
+ SetBody(map[string]any{
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
+ "parameters": params.RetryParameters,
|
|
|
+ "restartSuccessful": params.RetryOnSuccessfulWorkflow,
|
|
|
+ "nodeFieldSelector": params.SuccessfulWorkflowNodeFieldSelector,
|
|
|
+ }).
|
|
|
+ SetResult(&responseMap).
|
|
|
+ SetError(&responseMap).
|
|
|
+ Put(retryWorkflowRelativeUrl)
|
|
|
+ if err != nil {
|
|
|
+ return errors.New(err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ switch resp.StatusCode() {
|
|
|
+ case http.StatusConflict:
|
|
|
+ return errors.New("工作流已存在")
|
|
|
+ default:
|
|
|
+ message, ok := responseMap["message"]
|
|
|
+ if !ok {
|
|
|
+ return errors.Errorf("%v", resp.Status())
|
|
|
+ }
|
|
|
+
|
|
|
+ return errors.Errorf("%v, %v", resp.Status(), message)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-type SetWorkflowParams struct {
|
|
|
+type StopWorkflowParams struct {
|
|
|
Namespace string
|
|
|
Name string
|
|
|
NodeFieldSelector string
|
|
|
Message string
|
|
|
- Phase string
|
|
|
- OutputParameters []string
|
|
|
}
|
|
|
|
|
|
-func (c *Client) SetWorkflow(params SetWorkflowParams) error {
|
|
|
+func (c *Client) StopWorkflow(params StopWorkflowParams) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-type StopWorkflowParams struct {
|
|
|
+type TerminalWorkflowParams struct {
|
|
|
+ Namespace string
|
|
|
+ Name string
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) TerminalWorkflow(params TerminalWorkflowParams) error {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type SetWorkflowParams struct {
|
|
|
Namespace string
|
|
|
Name string
|
|
|
NodeFieldSelector string
|
|
|
Message string
|
|
|
+ Phase string
|
|
|
+ OutputParameters []string
|
|
|
}
|
|
|
|
|
|
-func (c *Client) StopWorkflow(params StopWorkflowParams) error {
|
|
|
+func (c *Client) SetWorkflow(params SetWorkflowParams) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -374,12 +463,12 @@ func (c *Client) SuspendWorkflow(params SuspendWorkflowParams) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-type TerminalWorkflowParams struct {
|
|
|
+type ResumeWorkflowParams struct {
|
|
|
Namespace string
|
|
|
Name string
|
|
|
}
|
|
|
|
|
|
-func (c *Client) TerminalWorkflow(params TerminalWorkflowParams) error {
|
|
|
+func (c *Client) ResumeWorkflow(params ResumeWorkflowParams) error {
|
|
|
return nil
|
|
|
}
|
|
|
|