提交 e06bd88a 编写于 作者: 徐晓伟's avatar 徐晓伟

议题 API: 删除议题

上级 6db44aca
......@@ -293,8 +293,9 @@ COPYRIGHT:
gitlab-go issue command [command options] [arguments...]
COMMANDS:
list 列出议题
help, h Shows a list of commands or help for one command
list 列出议题
delete, rm 删除议题
help, h Shows a list of commands or help for one command
OPTIONS:
--base-url value 实例地址,例如:https://gitlab.xuxiaowei.com.cn/api/v4 (default: "https://gitlab.com/api/v4") [%CI_API_V4_URL%]
......@@ -323,6 +324,7 @@ COPYRIGHT:
--with-labels-details 若为 true 则返回更详尽的标签信息::name、:color、:description、:description_html、:text_color。默认值是 false。description_html 属性引入于 12.7 版本。 (default: false)
--created-after value 对于给定的时间戳,返回不早于该时间创建的议题。时间戳应符合 ISO 8601 格式(2019-03-15T08:00:00Z)
--created-before value 对于给定的时间戳,返回不晚于该时间创建的议题。时间戳应符合 ISO 8601 格式(2019-03-15T08:00:00Z)。
--issue-id value 项目议题的内部 ID
--help, -h show help
```
......
......@@ -18,4 +18,5 @@ const (
PrintTime = "print-time"
PrintTimeDefault = false
Scope = "scope"
IssueId = "issue-id"
)
......@@ -131,3 +131,11 @@ func Scope(value string, usage string) cli.Flag {
Usage: usage,
}
}
func IssueId(required bool) cli.Flag {
return &cli.StringFlag{
Name: constant.IssueId,
Usage: "项目议题的内部 ID",
Required: required,
}
}
package issues
import (
"github.com/urfave/cli/v2"
"github.com/xanzy/go-gitlab"
"github.com/xuxiaowei-com-cn/gitlab-go/constant"
"github.com/xuxiaowei-com-cn/gitlab-go/flag"
"log"
)
// Delete 删除议题 https://docs.gitlab.cn/jh/api/issues.html#%E5%88%A0%E9%99%A4%E8%AE%AE%E9%A2%98
func Delete() *cli.Command {
return &cli.Command{
Name: "delete",
Aliases: []string{"rm"},
Usage: "删除议题",
Flags: append(flag.CommonTokenRequired(), flag.Id(true), flag.IssueId(true)),
Action: func(context *cli.Context) error {
var baseUrl = context.String(constant.BaseUrl)
var token = context.String(constant.Token)
var id = context.String(constant.Id)
var issueId = context.Int(constant.IssueId)
gitClient, err := gitlab.NewClient(token, gitlab.WithBaseURL(baseUrl))
if err != nil {
return err
}
response, err := gitClient.Issues.DeleteIssue(id, issueId)
if err != nil {
return err
}
log.Printf("Response StatusCode: %d\n", response.Response.StatusCode)
return nil
},
}
}
......@@ -22,9 +22,11 @@ func Issues() *cli.Command {
flag.DueDate(), flag.Iids(), flag.In(), flag.IssueType(), flag.IterationId(), flag.Milestone(),
flag.MilestoneId(), flag.MyReactionEmoji(), flag.OrderBy(OrderByUsage), flag.Scope(ScopeValue, ScopeUsage), flag.Search(),
flag.Sort(), flag.State(), flag.WithLabelsDetails(),
flag.CreatedAfter(), flag.CreatedBefore()),
flag.CreatedAfter(), flag.CreatedBefore(),
flag.IssueId(false)),
Subcommands: []*cli.Command{
List(),
Delete(),
},
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册