Documentation
¶
Overview ¶
Package zentao implements a client for the ZenTaoPMS API, ported from the official PHP SDK shipped with zentaopms (zentaopms_21.7 sdk/php/zentao.php).
Auth flow (mirrors the PHP SDK constructor):
- GET ?m=api&f=getSessionID -> { sessionName, sessionID, rand }
- POST ?m=user&f=login&t=json (body: account, password)
Access modes:
- GET (default): every request uses ?m=...&f=...&t=json query style.
- PATH_INFO: POST requests go to /module-func.json instead.
List (GET) responses come back as {"status":"success","data":"<json string>"} where data is double-encoded; submit (POST) responses come back as {"result":"success"|"fail","message":...}. Both are unwrapped transparently.
Index ¶
- Constants
- Variables
- type Bug
- type Client
- func (c *Client) BugCreate(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) BugCreateParams(ctx context.Context, productID string, branch string) (json.RawMessage, error)
- func (c *Client) BugDelete(ctx context.Context, bugID string) (json.RawMessage, error)
- func (c *Client) BugList(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) BugResolve(ctx context.Context, bugID string, params Params) (json.RawMessage, error)
- func (c *Client) BugResolveParams(ctx context.Context, bugID string) (json.RawMessage, error)
- func (c *Client) DeptAdd(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) DeptList(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) GetRand() string
- func (c *Client) Login(ctx context.Context) error
- func (c *Client) MyBugs(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) MyDynamics(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) MyProjects(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) MyStories(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) MyTasks(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) MyTodos(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) ProductAdd(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) ProductCreateParams(ctx context.Context, programID string) (json.RawMessage, error)
- func (c *Client) ProductList(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) ProjectAdd(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) ProjectCreateParams(ctx context.Context, programID string) (json.RawMessage, error)
- func (c *Client) ProjectList(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) SetRand(r string)
- func (c *Client) TaskCreate(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) TaskCreateParams(ctx context.Context, projectID string) (json.RawMessage, error)
- func (c *Client) TaskDelete(ctx context.Context, projectID, taskID string) (json.RawMessage, error)
- func (c *Client) TaskFinish(ctx context.Context, taskID string, params Params) (json.RawMessage, error)
- func (c *Client) TaskFinishParams(ctx context.Context, taskID string) (json.RawMessage, error)
- func (c *Client) TaskList(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) TodoClose(ctx context.Context, todoID string) (json.RawMessage, error)
- func (c *Client) TodoCreate(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) TodoDelete(ctx context.Context, todoID string) (json.RawMessage, error)
- func (c *Client) TodoFinish(ctx context.Context, todoID string) (json.RawMessage, error)
- func (c *Client) TodoList(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) TodoStart(ctx context.Context, todoID string) (json.RawMessage, error)
- func (c *Client) UserAdd(ctx context.Context, params Params) (json.RawMessage, error)
- func (c *Client) UserCreateParams(ctx context.Context, deptID string) (json.RawMessage, error)
- func (c *Client) UserList(ctx context.Context, params Params) (json.RawMessage, error)
- type Config
- type Department
- type Params
- type Product
- type Project
- type Task
- type User
Constants ¶
const ( StatusAll = "all" StatusActive = "active" StatusClosed = "closed" StatusWait = "wait" StatusDoing = "doing" StatusDone = "done" OrderIDAsc = "id_asc" OrderIDDesc = "id_desc" OrderAsc = "order_asc" OrderDesc = "order_desc" )
Common status constants.
const ( AccessModeGET = "GET" AccessModePathInfo = "PATH_INFO" )
Access modes supported by the API, mirroring ztAccessMode in the PHP SDK.
Variables ¶
var MethodPositionalOrder = map[string][]string{
"my/todo": {"type", "account", "status", "orderBy", "recTotal", "recPerPage", "pageID"},
"my/task": {"type", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"my/bug": {"type", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"my/story": {"type", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"my/project": {"status", "orderBy", "recTotal", "recPerPage", "pageID"},
"my/execution": {"type", "orderBy", "recTotal", "recPerPage", "pageID"},
"my/dynamic": {"type", "recTotal", "date", "direction"},
"todo/delete": {"todoID", "confirm"},
"task/delete": {"projectID", "taskID", "confirm"},
"bug/delete": {"bugID", "confirm"},
"bug/browse": {"productID", "branch", "browseType", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"project/browse": {"programID", "browseType", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"project/task": {"projectID", "status", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"execution/task": {"executionID", "status", "param", "orderBy", "recTotal", "recPerPage", "pageID"},
"product/all": {"browseType", "orderBy", "param", "recTotal", "recPerPage", "pageID", "programID"},
"product/browse": {"productID", "branch", "browseType", "param", "storyType", "orderBy", "recTotal", "recPerPage", "pageID"},
"company/browse": {"browseType", "param", "type", "orderBy", "recTotal", "recPerPage", "pageID"},
"dept/browse": {"deptID"},
}
MethodPositionalOrder defines the exact parameter order expected by ZenTao controller action arguments. When constructing GET query strings, parameters matching these lists are placed FIRST in exact positional order. NOTE: Checked against ZenTao 21.7 source code in module/*/control.php.
Functions ¶
This section is empty.
Types ¶
type Bug ¶
type Bug struct {
ID string `json:"id"`
Product string `json:"product"`
Branch string `json:"branch"`
Module string `json:"module"`
Project string `json:"project"`
Story string `json:"story"`
StoryVersion string `json:"storyVersion"`
Task string `json:"task"`
ToTask string `json:"toTask"`
ToStory string `json:"toStory"`
Title string `json:"title"`
Keywords string `json:"keywords"`
Severity string `json:"severity"`
Pri string `json:"pri"`
Type string `json:"type"`
OS string `json:"os"`
Browser string `json:"browser"`
Hardware string `json:"hardware"`
Found string `json:"found"`
Steps string `json:"steps"`
Status string `json:"status"`
SubStatus string `json:"subStatus"`
Color string `json:"color"`
Confirmed string `json:"confirmed"`
ActivatedCount string `json:"activatedCount"`
ActivatedDate string `json:"activatedDate"`
Mailto string `json:"mailto"`
OpenedBy string `json:"openedBy"`
OpenedDate string `json:"openedDate"`
OpenedBuild string `json:"openedBuild"`
AssignedTo string `json:"assignedTo"`
AssignedDate string `json:"assignedDate"`
Deadline string `json:"deadline"`
ResolvedBy string `json:"resolvedBy"`
Resolution string `json:"resolution"`
ResolvedBuild string `json:"resolvedBuild"`
ResolvedDate string `json:"resolvedDate"`
ClosedBy string `json:"closedBy"`
ClosedDate string `json:"closedDate"`
DuplicateBug string `json:"duplicateBug"`
LinkBug string `json:"linkBug"`
Case string `json:"case"`
CaseVersion string `json:"caseVersion"`
Result string `json:"result"`
Repo string `json:"repo"`
Entry string `json:"entry"`
Lines string `json:"lines"`
V1 string `json:"v1"`
V2 string `json:"v2"`
RepoType string `json:"repoType"`
Testtask string `json:"testtask"`
LastEditedBy string `json:"lastEditedBy"`
LastEditedDate string `json:"lastEditedDate"`
Deleted string `json:"deleted"`
}
Bug represents a ZenTao bug.
type Client ¶
type Client struct {
HTTP *http.Client
Cookie string // sessionName=sessionID, from getSessionID
// OnSessionRefreshed callback triggered whenever the session is automatically refreshed.
OnSessionRefreshed func(cookie, rand string)
BaseURL string
Account string
Password string
AccessMode string
// contains filtered or unexported fields
}
Client is a ZenTao API client. Create one with New, then call Login before any endpoint method (Login is also invoked once per CLI invocation).
func (*Client) BugCreateParams ¶
func (c *Client) BugCreateParams(ctx context.Context, productID string, branch string) (json.RawMessage, error)
BugCreateParams returns parameters and schema needed to create a bug (m=bug&f=create&productID=<id>&branch=<branch>).
func (*Client) BugDelete ¶
BugDelete deletes a bug by ID (GET/POST m=bug&f=delete&bugID=<id>&confirm=yes).
func (*Client) BugResolve ¶
func (c *Client) BugResolve(ctx context.Context, bugID string, params Params) (json.RawMessage, error)
BugResolve resolves a bug (POST m=bug&f=resolve&bugID=<id>). Common fields: resolution, resolvedBuild, comment.
func (*Client) BugResolveParams ¶
BugResolveParams returns parameters and schema needed to resolve a bug (m=bug&f=resolve&bugID=<id>).
func (*Client) Login ¶
Login performs the session handshake: getSessionID then user/login. It is safe to call once per process; every endpoint method assumes a valid session (mirrors the PHP SDK, which logs in in its constructor).
func (*Client) MyBugs ¶
MyBugs returns bugs for current user (m=my&f=bug). ZenTao 21.7 signature: bug(type='assignedTo', param=0, orderBy='id_desc', recTotal=0, recPerPage=20, pageID=1)
func (*Client) MyDynamics ¶
MyDynamics returns recent activity stream for current user (m=my&f=dynamic). ZenTao 21.7 signature: dynamic(type='today', recTotal=0, date=”, direction='next')
func (*Client) MyProjects ¶
MyProjects returns projects for current user (m=my&f=project). ZenTao 21.7 signature: project(status='doing', orderBy='id_desc', recTotal=0, recPerPage=15, pageID=1)
func (*Client) MyStories ¶
MyStories returns stories/requirements for current user (m=my&f=story). ZenTao 21.7 signature: story(type='assignedTo', param=0, orderBy='id_desc', recTotal=0, recPerPage=20, pageID=1)
func (*Client) MyTasks ¶
MyTasks returns tasks for current user (m=my&f=task). ZenTao 21.7 signature: task(type='assignedTo', param=0, orderBy='id_desc', recTotal=0, recPerPage=20, pageID=1)
func (*Client) MyTodos ¶
MyTodos returns todos for current user (m=my&f=todo). ZenTao 21.7 signature: todo(type='before', userID=”, status='all', orderBy='date_desc,status,begin', recTotal=0, recPerPage=20, pageID=1)
func (*Client) ProductAdd ¶
ProductAdd creates a product (POST m=product&f=create). Common fields: name, code, PO, QD, RD, acl, status, desc.
func (*Client) ProductCreateParams ¶ added in v1.0.8
func (c *Client) ProductCreateParams(ctx context.Context, programID string) (json.RawMessage, error)
ProductCreateParams returns parameters and metadata needed to create a product (m=product&f=create&programID=<id>).
func (*Client) ProductList ¶
ProductList returns products (m=product&f=all or m=product&f=browse).
func (*Client) ProjectAdd ¶
ProjectAdd creates a project (POST m=project&f=create). Common fields: name, code, begin, end, days, team, type, status, acl, PM, PO, QD, RD, desc.
func (*Client) ProjectCreateParams ¶ added in v1.0.8
func (c *Client) ProjectCreateParams(ctx context.Context, programID string) (json.RawMessage, error)
ProjectCreateParams returns parameters and metadata needed to create a project (m=project&f=create&programID=<id>).
func (*Client) ProjectList ¶
ProjectList returns projects.
func (*Client) TaskCreate ¶
TaskCreate creates a task (POST m=task&f=create&project=<id>). Common fields: name, type, pri, estimate, assignedTo, module, story, desc.
func (*Client) TaskCreateParams ¶
TaskCreateParams returns parameters and schema needed to create a task (m=task&f=create&project=<id>).
func (*Client) TaskDelete ¶
TaskDelete deletes a task by ID (GET/POST m=task&f=delete&taskID=<id>&confirm=yes).
func (*Client) TaskFinish ¶
func (c *Client) TaskFinish(ctx context.Context, taskID string, params Params) (json.RawMessage, error)
TaskFinish completes a task (POST m=task&f=finish&taskID=<id>). Common fields: real (actual hours), comment.
func (*Client) TaskFinishParams ¶
TaskFinishParams returns parameters and current state needed to finish a task (m=task&f=finish&taskID=<id>).
func (*Client) TodoCreate ¶
TodoCreate creates a todo item (POST m=todo&f=create). Common fields: name, date (YYYY-MM-DD), begin, end, type (custom, task, bug, story), pri, desc.
func (*Client) TodoDelete ¶
TodoDelete deletes a todo by ID (GET/POST m=todo&f=delete&todoID=<id>&confirm=yes).
func (*Client) TodoFinish ¶
TodoFinish marks a todo as completed (POST m=todo&f=finish&todoID=<id>).
func (*Client) TodoStart ¶
TodoStart marks a todo as started/doing (POST m=todo&f=start&todoID=<id>).
func (*Client) UserAdd ¶
UserAdd creates a user (POST m=user&f=create&dept=<dept>), including the md5+session-rand password encryption from the PHP SDK addUser():
password1 = md5(pwd1) + rand password2 = md5(pwd2) + rand verifyPassword = md5(md5(masterPassword) + rand)
field "password" is treated as both password1 and password2; "verifyPassword" defaults to the master (login) password, like the SDK.
func (*Client) UserCreateParams ¶ added in v1.0.8
UserCreateParams returns parameters and schema needed to create a user (m=user&f=create&dept=<dept>).
type Config ¶
type Config struct {
URL string `json:"url"`
Account string `json:"account"`
Password string `json:"password,omitempty"`
AccessMode string `json:"accessMode,omitempty"`
Timeout time.Duration `json:"-"`
Insecure bool `json:"-"`
}
Config holds connection settings. Resolution order: CLI flags > env vars > config file. See cmd config loading for details.
type Department ¶
type Department struct {
ID string `json:"id"`
Name string `json:"name"`
Parent string `json:"parent"`
Path string `json:"path"`
Grade string `json:"grade"`
Order string `json:"order"`
Position string `json:"position"`
Function string `json:"function"`
Manager string `json:"manager"`
}
Department represents a ZenTao department.
type Params ¶
Params is an alias so command builders read naturally:
zentao.Params{"status": "all", "orderBy": "id_desc"}
type Product ¶
type Product struct {
ID string `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
Line string `json:"line"`
Type string `json:"type"`
Status string `json:"status"`
Desc string `json:"desc"`
PO string `json:"PO"`
QD string `json:"QD"`
RD string `json:"RD"`
ACL string `json:"acl"`
Whitelist string `json:"whitelist"`
CreatedBy string `json:"createdBy"`
CreatedDate string `json:"createdDate"`
CreatedVersion string `json:"createdVersion"`
Order string `json:"order"`
Deleted string `json:"deleted"`
}
Product represents a ZenTao product.
type Project ¶
type Project struct {
ID string `json:"id"`
IsCat string `json:"isCat"`
CatID string `json:"catID"`
Type string `json:"type"`
Parent string `json:"parent"`
Name string `json:"name"`
Code string `json:"code"`
Begin string `json:"begin"`
End string `json:"end"`
Days string `json:"days"`
Status string `json:"status"`
Statge string `json:"statge"`
Pri string `json:"pri"`
Desc string `json:"desc"`
OpenedBy string `json:"openedBy"`
OpenedDate string `json:"openedDate"`
OpenedVersion string `json:"openedVersion"`
ClosedBy string `json:"closedBy"`
ClosedDate string `json:"closedDate"`
CanceledBy string `json:"canceledBy"`
CanceledDate string `json:"canceledDate"`
PO string `json:"PO"`
PM string `json:"PM"`
QD string `json:"QD"`
RD string `json:"RD"`
Team string `json:"team"`
ACL string `json:"acl"`
Whitelist string `json:"whitelist"`
Order string `json:"order"`
Deleted string `json:"deleted"`
}
Project represents a ZenTao project / execution.
type Task ¶
type Task struct {
ID string `json:"id"`
Parent string `json:"parent"`
Project string `json:"project"`
Module string `json:"module"`
Story string `json:"story"`
StoryVersion string `json:"storyVersion"`
FromBug string `json:"fromBug"`
Name string `json:"name"`
Type string `json:"type"`
Pri string `json:"pri"`
Estimate string `json:"estimate"`
Consumed string `json:"consumed"`
Left string `json:"left"`
Deadline string `json:"deadline"`
Status string `json:"status"`
Color string `json:"color"`
Mailto string `json:"mailto"`
Desc string `json:"desc"`
OpenedBy string `json:"openedBy"`
OpenedDate string `json:"openedDate"`
AssignedTo string `json:"assignedTo"`
AssignedDate string `json:"assignedDate"`
EstStarted string `json:"estStarted"`
RealStarted string `json:"realStarted"`
FinishedBy string `json:"finishedBy"`
FinishedDate string `json:"finishedDate"`
FinishedList string `json:"finishedList"`
CanceledBy string `json:"canceledBy"`
CanceledDate string `json:"canceledDate"`
ClosedBy string `json:"closedBy"`
ClosedDate string `json:"closedDate"`
ClosedReason string `json:"closedReason"`
LastEditedBy string `json:"lastEditedBy"`
LastEditedDate string `json:"lastEditedDate"`
Deleted string `json:"deleted"`
}
Task represents a ZenTao task.
type User ¶
type User struct {
ID string `json:"id"`
Dept string `json:"dept"`
Account string `json:"account"`
Realname string `json:"realname"`
Role string `json:"role"`
Email string `json:"email"`
Gender string `json:"gender"`
Mobile string `json:"mobile"`
Phone string `json:"phone"`
QQ string `json:"qq"`
Address string `json:"address"`
Zipcode string `json:"zipcode"`
Join string `json:"join"`
Visits string `json:"visits"`
IP string `json:"ip"`
Last string `json:"last"`
Fails string `json:"fails"`
Locked string `json:"locked"`
Ranzhi string `json:"ranzhi"`
Deleted string `json:"deleted"`
}
User represents a ZenTao user.