|
|
@@ -14,24 +14,23 @@ const (
|
|
|
lintWorkflowTemplateRelativeUrl = "/api/v1/workflow-templates/{namespace}/lint"
|
|
|
)
|
|
|
|
|
|
-// CreateWorkflowTemplate 创建工作流模板
|
|
|
-// 参数:
|
|
|
-// namespace: 命名空间
|
|
|
-// templateDefinition: map定义
|
|
|
-// 返回值:
|
|
|
-// 错误
|
|
|
-func (c *Client) CreateWorkflowTemplate(namespace string, templateDefinition map[string]any) error {
|
|
|
+type CreateWorkflowTemplateParams struct {
|
|
|
+ Namespace string
|
|
|
+ TemplateDefinition map[string]any
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) CreateWorkflowTemplate(params CreateWorkflowTemplateParams) error {
|
|
|
responseMap := make(map[string]any)
|
|
|
|
|
|
resp, err := c.restyClient.R().
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
SetAuthToken(c.token).
|
|
|
SetPathParams(map[string]string{
|
|
|
- "namespace": namespace,
|
|
|
+ "namespace": params.Namespace,
|
|
|
}).
|
|
|
SetBody(map[string]any{
|
|
|
- "namespace": namespace,
|
|
|
- "template": templateDefinition,
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "template": params.TemplateDefinition,
|
|
|
}).
|
|
|
SetResult(&responseMap).
|
|
|
SetError(&responseMap).
|
|
|
@@ -55,21 +54,20 @@ func (c *Client) CreateWorkflowTemplate(namespace string, templateDefinition map
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// DeleteWorkflowTemplate 删除工作流模板
|
|
|
-// 参数:
|
|
|
-// namespace: 命名空间
|
|
|
-// name: 工作流模板名称
|
|
|
-// 返回值:
|
|
|
-// 错误
|
|
|
-func (c *Client) DeleteWorkflowTemplate(namespace string, name string) error {
|
|
|
+type DeleteWorkflowTemplateParams struct {
|
|
|
+ Namespace string
|
|
|
+ Name string
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) DeleteWorkflowTemplate(params DeleteWorkflowTemplateParams) error {
|
|
|
responseMap := make(map[string]any)
|
|
|
|
|
|
resp, err := c.restyClient.R().
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
SetAuthToken(c.token).
|
|
|
SetPathParams(map[string]string{
|
|
|
- "namespace": namespace,
|
|
|
- "name": name,
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
}).
|
|
|
SetResult(&responseMap).
|
|
|
SetError(&responseMap).
|
|
|
@@ -91,27 +89,26 @@ func (c *Client) DeleteWorkflowTemplate(namespace string, name string) error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// UpdateWorkflowTemplate 更新工作流模板
|
|
|
-// 参数:
|
|
|
-// namespace: 命名空间
|
|
|
-// name: 工作流模板名称
|
|
|
-// templateDefinition: map定义,注意:需要基于查询回来的map定义进行修改
|
|
|
-// 返回值:
|
|
|
-// 错误
|
|
|
-func (c *Client) UpdateWorkflowTemplate(namespace string, name string, templateDefinition map[string]any) error {
|
|
|
+type UpdateWorkflowTemplateParams struct {
|
|
|
+ Namespace string
|
|
|
+ Name string
|
|
|
+ TemplateDefinition map[string]any
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) UpdateWorkflowTemplate(params UpdateWorkflowTemplateParams) error {
|
|
|
responseMap := make(map[string]any)
|
|
|
|
|
|
resp, err := c.restyClient.R().
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
SetAuthToken(c.token).
|
|
|
SetPathParams(map[string]string{
|
|
|
- "namespace": namespace,
|
|
|
- "name": name,
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
}).
|
|
|
SetBody(map[string]any{
|
|
|
- "namespace": namespace,
|
|
|
- "name": name,
|
|
|
- "template": templateDefinition,
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
+ "template": params.TemplateDefinition,
|
|
|
}).
|
|
|
SetResult(&responseMap).
|
|
|
SetError(&responseMap).
|
|
|
@@ -133,20 +130,18 @@ func (c *Client) UpdateWorkflowTemplate(namespace string, name string, templateD
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// GetWorkflowTemplatesInNamespace 查询一个命名空间下的工作流模板
|
|
|
-// 参数:
|
|
|
-// namespace: 命名空间
|
|
|
-// 返回值:
|
|
|
-// 查询到的工作流模板定义
|
|
|
-// 错误
|
|
|
-func (c *Client) GetWorkflowTemplatesInNamespace(namespace string) ([]map[string]any, error) {
|
|
|
+type GetWorkflowTemplatesInNamespaceParams struct {
|
|
|
+ Namespace string
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) GetWorkflowTemplatesInNamespace(params GetWorkflowTemplatesInNamespaceParams) ([]map[string]any, error) {
|
|
|
responseMap := make(map[string]any)
|
|
|
|
|
|
resp, err := c.restyClient.R().
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
SetAuthToken(c.token).
|
|
|
SetPathParams(map[string]string{
|
|
|
- "namespace": namespace,
|
|
|
+ "namespace": params.Namespace,
|
|
|
}).
|
|
|
SetResult(&responseMap).
|
|
|
SetError(&responseMap).
|
|
|
@@ -188,22 +183,20 @@ func (c *Client) GetWorkflowTemplatesInNamespace(namespace string) ([]map[string
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// GetWorkflowTemplate 查询具体的工作流模板
|
|
|
-// 参数:
|
|
|
-// namespace: 命名空间
|
|
|
-// name: 工作流模板名称
|
|
|
-// 返回值:
|
|
|
-// 查询到的工作流模板定义
|
|
|
-// 错误
|
|
|
-func (c *Client) GetWorkflowTemplate(namespace string, name string) (map[string]any, error) {
|
|
|
+type GetWorkflowTemplateParams struct {
|
|
|
+ Namespace string
|
|
|
+ Name string
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) GetWorkflowTemplate(params GetWorkflowTemplateParams) (map[string]any, error) {
|
|
|
responseMap := make(map[string]any)
|
|
|
|
|
|
resp, err := c.restyClient.R().
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
SetAuthToken(c.token).
|
|
|
SetPathParams(map[string]string{
|
|
|
- "namespace": namespace,
|
|
|
- "name": name,
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "name": params.Name,
|
|
|
}).
|
|
|
SetResult(&responseMap).
|
|
|
SetError(&responseMap).
|
|
|
@@ -225,24 +218,23 @@ func (c *Client) GetWorkflowTemplate(namespace string, name string) (map[string]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// LintWorkflowTemplate 对工作流模板定义进行语法检查
|
|
|
-// 参数:
|
|
|
-// namespace: 命名空间
|
|
|
-// templateDefinition: map定义
|
|
|
-// 返回值:
|
|
|
-// 错误
|
|
|
-func (c *Client) LintWorkflowTemplate(namespace string, templateDefinition map[string]any) error {
|
|
|
+type LintWorkflowTemplateParams struct {
|
|
|
+ Namespace string
|
|
|
+ TemplateDefinition map[string]any
|
|
|
+}
|
|
|
+
|
|
|
+func (c *Client) LintWorkflowTemplate(params LintWorkflowTemplateParams) error {
|
|
|
responseMap := make(map[string]any)
|
|
|
|
|
|
resp, err := c.restyClient.R().
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
SetAuthToken(c.token).
|
|
|
SetPathParams(map[string]string{
|
|
|
- "namespace": namespace,
|
|
|
+ "namespace": params.Namespace,
|
|
|
}).
|
|
|
SetBody(map[string]any{
|
|
|
- "namespace": namespace,
|
|
|
- "template": templateDefinition,
|
|
|
+ "namespace": params.Namespace,
|
|
|
+ "template": params.TemplateDefinition,
|
|
|
}).
|
|
|
SetResult(&responseMap).
|
|
|
SetError(&responseMap).
|