2018-02-19 22:24:10 +00:00
|
|
|
// Copyright 2018 Drone.IO Inc.
|
2018-03-21 13:02:17 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2018-03-21 13:02:17 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2018-03-21 13:02:17 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-04-29 19:39:56 +00:00
|
|
|
package internal
|
2015-10-04 04:50:11 +00:00
|
|
|
|
2015-10-05 00:40:27 +00:00
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2015-10-04 04:50:11 +00:00
|
|
|
type Account struct {
|
2023-05-11 03:19:35 +00:00
|
|
|
ID int64 `json:"id"`
|
2015-10-04 04:50:11 +00:00
|
|
|
Login string `json:"username"`
|
|
|
|
Name string `json:"display_name"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
}
|
|
|
|
|
2022-09-18 07:26:13 +00:00
|
|
|
type Workspace struct {
|
|
|
|
UUID string `json:"uuid"`
|
|
|
|
Slug string `json:"slug"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type WorkspacesResp struct {
|
|
|
|
Page int `json:"page"`
|
|
|
|
Pages int `json:"pagelen"`
|
|
|
|
Size int `json:"size"`
|
|
|
|
Next string `json:"next"`
|
|
|
|
Values []*Workspace `json:"values"`
|
2015-10-04 04:50:11 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 01:24:12 +00:00
|
|
|
type PipelineStatus struct {
|
2016-03-27 00:24:09 +00:00
|
|
|
State string `json:"state"`
|
|
|
|
Key string `json:"key"`
|
|
|
|
Name string `json:"name,omitempty"`
|
2021-12-01 13:22:06 +00:00
|
|
|
URL string `json:"url"`
|
2016-03-27 00:24:09 +00:00
|
|
|
Desc string `json:"description,omitempty"`
|
2015-11-21 05:22:28 +00:00
|
|
|
}
|
|
|
|
|
2015-10-04 04:50:11 +00:00
|
|
|
type Email struct {
|
|
|
|
Email string `json:"email"`
|
|
|
|
IsConfirmed bool `json:"is_confirmed"`
|
|
|
|
IsPrimary bool `json:"is_primary"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type EmailResp struct {
|
2015-10-05 00:40:27 +00:00
|
|
|
Page int `json:"page"`
|
|
|
|
Pages int `json:"pagelen"`
|
|
|
|
Size int `json:"size"`
|
|
|
|
Next string `json:"next"`
|
|
|
|
Values []*Email `json:"values"`
|
2015-10-04 04:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Hook struct {
|
2021-12-01 13:22:06 +00:00
|
|
|
UUID string `json:"uuid,omitempty"`
|
2015-10-04 04:50:11 +00:00
|
|
|
Desc string `json:"description"`
|
2021-12-01 13:22:06 +00:00
|
|
|
URL string `json:"url"`
|
2015-10-04 04:50:11 +00:00
|
|
|
Events []string `json:"events"`
|
|
|
|
Active bool `json:"active"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type HookResp struct {
|
2015-10-05 00:40:27 +00:00
|
|
|
Page int `json:"page"`
|
|
|
|
Pages int `json:"pagelen"`
|
|
|
|
Size int `json:"size"`
|
|
|
|
Next string `json:"next"`
|
|
|
|
Values []*Hook `json:"values"`
|
2015-10-04 04:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Links struct {
|
2022-09-18 07:26:13 +00:00
|
|
|
Self Link `json:"self"`
|
2015-10-04 04:50:11 +00:00
|
|
|
Avatar Link `json:"avatar"`
|
2021-12-01 13:22:06 +00:00
|
|
|
HTML Link `json:"html"`
|
2015-10-04 04:50:11 +00:00
|
|
|
Clone []Link `json:"clone"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Link struct {
|
|
|
|
Href string `json:"href"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type LinkClone struct {
|
|
|
|
Link
|
|
|
|
}
|
|
|
|
|
|
|
|
type Repo struct {
|
2023-07-30 16:28:52 +00:00
|
|
|
UUID string `json:"uuid"`
|
|
|
|
Owner Account `json:"owner"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
FullName string `json:"full_name"`
|
|
|
|
Language string `json:"language"`
|
|
|
|
IsPrivate bool `json:"is_private"`
|
|
|
|
Scm string `json:"scm"`
|
|
|
|
Desc string `json:"desc"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
Mainbranch struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
} `json:"mainbranch"`
|
2015-10-04 04:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RepoResp struct {
|
2015-10-05 00:40:27 +00:00
|
|
|
Page int `json:"page"`
|
|
|
|
Pages int `json:"pagelen"`
|
|
|
|
Size int `json:"size"`
|
|
|
|
Next string `json:"next"`
|
|
|
|
Values []*Repo `json:"values"`
|
2015-10-04 04:50:11 +00:00
|
|
|
}
|
|
|
|
|
2016-04-30 08:00:39 +00:00
|
|
|
type Change struct {
|
|
|
|
New struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Target struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Hash string `json:"hash"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Date time.Time `json:"date"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
Author struct {
|
|
|
|
Raw string `json:"raw"`
|
|
|
|
User Account `json:"user"`
|
|
|
|
} `json:"author"`
|
|
|
|
} `json:"target"`
|
|
|
|
} `json:"new"`
|
|
|
|
}
|
|
|
|
|
2015-10-05 00:40:27 +00:00
|
|
|
type PushHook struct {
|
|
|
|
Actor Account `json:"actor"`
|
|
|
|
Repo Repo `json:"repository"`
|
|
|
|
Push struct {
|
2016-04-30 08:00:39 +00:00
|
|
|
Changes []Change `json:"changes"`
|
2015-10-05 00:40:27 +00:00
|
|
|
} `json:"push"`
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:34:06 +00:00
|
|
|
type PullRequestHook struct {
|
|
|
|
Actor Account `json:"actor"`
|
|
|
|
Repo Repo `json:"repository"`
|
|
|
|
PullRequest struct {
|
|
|
|
ID int `json:"id"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Reason string `json:"reason"`
|
|
|
|
Desc string `json:"description"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
State string `json:"state"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
Created time.Time `json:"created_on"`
|
|
|
|
Updated time.Time `json:"updated_on"`
|
|
|
|
|
|
|
|
Source struct {
|
2022-11-09 07:12:17 +00:00
|
|
|
Repo Repo `json:"repository"`
|
2015-10-05 01:34:06 +00:00
|
|
|
Commit struct {
|
|
|
|
Hash string `json:"hash"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
} `json:"commit"`
|
|
|
|
Branch struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
} `json:"branch"`
|
|
|
|
} `json:"source"`
|
|
|
|
|
|
|
|
Dest struct {
|
2022-11-09 07:12:17 +00:00
|
|
|
Repo Repo `json:"repository"`
|
2015-10-05 01:34:06 +00:00
|
|
|
Commit struct {
|
|
|
|
Hash string `json:"hash"`
|
|
|
|
Links Links `json:"links"`
|
|
|
|
} `json:"commit"`
|
|
|
|
Branch struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
} `json:"branch"`
|
|
|
|
} `json:"destination"`
|
|
|
|
} `json:"pullrequest"`
|
|
|
|
}
|
|
|
|
|
2022-07-25 01:09:35 +00:00
|
|
|
type WorkspaceMembershipResp struct {
|
|
|
|
Page int `json:"page"`
|
|
|
|
Pages int `json:"pagelen"`
|
|
|
|
Size int `json:"size"`
|
|
|
|
Next string `json:"next"`
|
|
|
|
Values []struct {
|
|
|
|
Permission string `json:"permission"`
|
|
|
|
User struct {
|
|
|
|
Nickname string `json:"nickname"`
|
|
|
|
}
|
|
|
|
} `json:"values"`
|
|
|
|
}
|
|
|
|
|
2015-10-04 04:50:11 +00:00
|
|
|
type ListOpts struct {
|
|
|
|
Page int
|
|
|
|
PageLen int
|
|
|
|
}
|
|
|
|
|
2015-10-05 00:40:27 +00:00
|
|
|
func (o *ListOpts) Encode() string {
|
2015-10-05 01:34:06 +00:00
|
|
|
params := url.Values{}
|
2015-10-05 00:40:27 +00:00
|
|
|
if o.Page != 0 {
|
|
|
|
params.Set("page", strconv.Itoa(o.Page))
|
|
|
|
}
|
|
|
|
if o.PageLen != 0 {
|
|
|
|
params.Set("pagelen", strconv.Itoa(o.PageLen))
|
|
|
|
}
|
|
|
|
return params.Encode()
|
|
|
|
}
|
|
|
|
|
2022-09-18 07:26:13 +00:00
|
|
|
type ListWorkspacesOpts struct {
|
2015-10-05 00:40:27 +00:00
|
|
|
Page int
|
|
|
|
PageLen int
|
|
|
|
Role string
|
|
|
|
}
|
|
|
|
|
2022-09-18 07:26:13 +00:00
|
|
|
func (o *ListWorkspacesOpts) Encode() string {
|
2015-10-05 01:34:06 +00:00
|
|
|
params := url.Values{}
|
2015-10-05 00:40:27 +00:00
|
|
|
if o.Page != 0 {
|
|
|
|
params.Set("page", strconv.Itoa(o.Page))
|
|
|
|
}
|
|
|
|
if o.PageLen != 0 {
|
|
|
|
params.Set("pagelen", strconv.Itoa(o.PageLen))
|
|
|
|
}
|
|
|
|
if len(o.Role) != 0 {
|
|
|
|
params.Set("role", o.Role)
|
|
|
|
}
|
|
|
|
return params.Encode()
|
|
|
|
}
|
|
|
|
|
2015-10-04 04:50:11 +00:00
|
|
|
type Error struct {
|
|
|
|
Status int
|
|
|
|
Body struct {
|
|
|
|
Message string `json:"message"`
|
|
|
|
} `json:"error"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e Error) Error() string {
|
|
|
|
return e.Body.Message
|
|
|
|
}
|
2018-04-27 15:59:36 +00:00
|
|
|
|
|
|
|
type RepoPermResp struct {
|
|
|
|
Page int `json:"page"`
|
|
|
|
Pages int `json:"pagelen"`
|
|
|
|
Values []*RepoPerm `json:"values"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type RepoPerm struct {
|
|
|
|
Permission string `json:"permission"`
|
|
|
|
}
|
2022-05-12 17:31:01 +00:00
|
|
|
|
|
|
|
type BranchResp struct {
|
|
|
|
Values []*Branch `json:"values"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Branch struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
2023-06-27 21:40:28 +00:00
|
|
|
|
|
|
|
type PullRequestResp struct {
|
|
|
|
Page uint `json:"page"`
|
|
|
|
PageLen uint `json:"pagelen"`
|
|
|
|
Size uint `json:"size"`
|
|
|
|
Values []*PullRequest `json:"values"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PullRequest struct {
|
|
|
|
ID uint `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
}
|
2023-07-17 19:30:06 +00:00
|
|
|
|
|
|
|
type CommitsResp struct {
|
|
|
|
Values []*Commit `json:"values"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Commit struct {
|
|
|
|
Hash string `json:"hash"`
|
|
|
|
}
|
2023-08-02 11:15:57 +00:00
|
|
|
|
|
|
|
type DirResp struct {
|
|
|
|
Page uint `json:"page"`
|
|
|
|
PageLen uint `json:"pagelen"`
|
|
|
|
Next *string `json:"next"`
|
|
|
|
Values []*Dir `json:"values"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Dir struct {
|
|
|
|
Path string `json:"path"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Size uint `json:"size"`
|
|
|
|
}
|