mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-18 15:55:30 +00:00
Major updates
This commit is contained in:
parent
d5c0a11b28
commit
cd66a816e2
85
src/API.js
85
src/API.js
@ -1,85 +0,0 @@
|
||||
import Request from 'request-promise';
|
||||
import { Groups, Projects, Issues, Runners, Users, MergeRequests, Version } from './Models';
|
||||
|
||||
function defaultRequest(url, endpoint, {
|
||||
headers,
|
||||
body,
|
||||
qs,
|
||||
formData,
|
||||
resolveWithFullResponse = false,
|
||||
}) {
|
||||
const params = {
|
||||
url: `${url}${endpoint}`,
|
||||
headers,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (body) params.body = body;
|
||||
if (qs) params.qs = qs;
|
||||
if (formData) params.formData = formData;
|
||||
|
||||
params.resolveWithFullResponse = resolveWithFullResponse;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
class API {
|
||||
constructor({ url = 'https://gitlab.com', token, oauthToken }) {
|
||||
this.url = `${url}/api/v4/`;
|
||||
this.headers = {};
|
||||
|
||||
if (oauthToken) {
|
||||
this.headers.Authorization = `Bearer ${oauthToken}`;
|
||||
} else if (token) {
|
||||
this.headers['private-token'] = token;
|
||||
} else {
|
||||
throw new Error('`token` (private-token) or `oauth_token` is mandatory');
|
||||
}
|
||||
|
||||
this.groups = new Groups(this);
|
||||
this.projects = new Projects(this);
|
||||
this.issues = new Issues(this);
|
||||
this.users = new Users(this);
|
||||
this.runners = new Runners(this);
|
||||
this.mergeRequests = new MergeRequests(this);
|
||||
this.version = new Version(this);
|
||||
}
|
||||
|
||||
get(endpoint, options, fullResponse = false) {
|
||||
return Request.get(defaultRequest(this.url, endpoint, {
|
||||
headers: this.headers,
|
||||
qs: options,
|
||||
resolveWithFullResponse: fullResponse,
|
||||
}));
|
||||
}
|
||||
|
||||
post(endpoint, options) {
|
||||
return Request.post(defaultRequest(this.url, endpoint, {
|
||||
headers: this.headers,
|
||||
body: options,
|
||||
}));
|
||||
}
|
||||
|
||||
postForm(endpoint, options) {
|
||||
return Request.post(defaultRequest(this.url, endpoint, {
|
||||
headers: this.headers,
|
||||
formData: options,
|
||||
}));
|
||||
}
|
||||
|
||||
put(endpoint, options) {
|
||||
return Request.put(defaultRequest(this.url, endpoint, {
|
||||
headers: this.headers,
|
||||
body: options,
|
||||
}));
|
||||
}
|
||||
|
||||
delete(endpoint, options) {
|
||||
return Request.delete(defaultRequest(this.url, endpoint, {
|
||||
headers: this.headers,
|
||||
qs: options,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export default API;
|
||||
@ -1,18 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class GroupProjects extends BaseModel {
|
||||
all(groupId, options = {}) {
|
||||
const gId = parse(groupId);
|
||||
|
||||
return this.get(`groups/${gId}/projects`, options);
|
||||
}
|
||||
|
||||
add(groupId, projectId) {
|
||||
const [gId, pId] = [groupId, projectId].map(parse);
|
||||
|
||||
return this.post(`groups/${gId}/projects/${pId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupProjects;
|
||||
@ -1,53 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import GroupProjects from './GroupProjects';
|
||||
import ResourceAccessRequests from './ResourceAccessRequests';
|
||||
import ResourceCustomAttributes from './ResourceCustomAttributes';
|
||||
import ResourceMembers from './ResourceMembers';
|
||||
import ResourceMilestones from './ResourceMilestones';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class Groups extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.projects = new GroupProjects(...args);
|
||||
this.accessRequests = new ResourceAccessRequests('groups', ...args);
|
||||
this.customAttributes = new ResourceCustomAttributes('groups', ...args);
|
||||
this.members = new ResourceMembers('groups', ...args);
|
||||
this.milestones = new ResourceMilestones('groups', ...args);
|
||||
}
|
||||
|
||||
all(options = {}) {
|
||||
return this.get('groups', options);
|
||||
}
|
||||
|
||||
allSubgroups(groupId, options = {}) {
|
||||
const gId = parse(groupId);
|
||||
|
||||
return this.get(`groups/${gId}/subgroups`, options);
|
||||
}
|
||||
|
||||
show(groupId) {
|
||||
const gId = parse(groupId);
|
||||
|
||||
return this.get(`groups/${gId}`);
|
||||
}
|
||||
|
||||
create(options = {}) {
|
||||
return this.post('groups', options);
|
||||
}
|
||||
|
||||
remove(groupId) {
|
||||
const gId = parse(groupId);
|
||||
|
||||
return this.delete(`groups/${gId}`);
|
||||
}
|
||||
|
||||
search(nameOrPath) {
|
||||
return this.get('groups', {
|
||||
search: nameOrPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Groups;
|
||||
@ -1,9 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
|
||||
class Issues extends BaseModel {
|
||||
all(options = {}) {
|
||||
return this.get('issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Issues;
|
||||
@ -1,9 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
|
||||
class MergeRequests extends BaseModel {
|
||||
all(options = {}) {
|
||||
return this.get('merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default MergeRequests;
|
||||
@ -1,24 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectDeployKeys extends BaseModel {
|
||||
add(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/deploy_keys`, options);
|
||||
}
|
||||
|
||||
all(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/deploy_keys`);
|
||||
}
|
||||
|
||||
show(projectId, keyId) {
|
||||
const [pId, kId] = [projectId, keyId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/deploy_keys/${kId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectDeployKeys;
|
||||
@ -1,12 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class Environments extends BaseModel {
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/environments`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Environments;
|
||||
@ -1,36 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectHooks extends BaseModel {
|
||||
all(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/hooks`);
|
||||
}
|
||||
|
||||
show(projectId, hookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/hooks/${hId}`);
|
||||
}
|
||||
|
||||
add(projectId, url, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/hooks`, Object.assign({ url }, options));
|
||||
}
|
||||
|
||||
edit(projectId, hookId, url, options = {}) {
|
||||
const [pId, hId] = [projectId, hookId].map(parse);
|
||||
|
||||
return this.put(`projects/${pId}/hooks/${hId}`, Object.assign({ url }, options));
|
||||
}
|
||||
|
||||
remove(projectId, hookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/hooks/${hId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectHooks;
|
||||
@ -1,62 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import ResourceNotes from './ResourceNotes';
|
||||
|
||||
class ProjectIssues extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.notes = new ResourceNotes('projects', 'issues', ...args);
|
||||
}
|
||||
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
edit(projectId, issueId, options = {}) {
|
||||
const [pId, iId] = [projectId, issueId].map(parse);
|
||||
|
||||
return this.put(`projects/${pId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
link(projectId, issueIId, targetProjectId, targetIssueId, options = {}) {
|
||||
const [pId, iId] = [projectId, issueIId].map(parse);
|
||||
const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/issues/${iId}/links`, Object.assign({ target_project_id: targetpId, target_issue_id: targetIId }, options));
|
||||
}
|
||||
|
||||
remove(projectId, issueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
show(projectId, issueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
subscribe(projectId, issueId, options = {}) {
|
||||
const [pId, iId] = [projectId, issueId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/issues/${iId}/subscribe`, options);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, issueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/issues/${iId}/unsubscribe`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectIssues;
|
||||
@ -1,12 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class Jobs extends BaseModel {
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/jobs`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Jobs;
|
||||
@ -1,42 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectLabels extends BaseModel {
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
edit(projectId, labelName, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.put(`projects/${pId}/labels`, Object.assign({ name: labelName }, options));
|
||||
}
|
||||
|
||||
remove(projectId, labelName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.delete(`projects/${pId}/labels`, { name: labelName });
|
||||
}
|
||||
|
||||
subscribe(projectId, labelId, options = {}) {
|
||||
const [pId, lId] = [projectId, labelId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/issues/${lId}/subscribe`, options);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, labelId) {
|
||||
const [pId, lId] = [projectId, labelId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/issues/${lId}/unsubscribe`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectLabels;
|
||||
@ -1,12 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectMergeRequestChanges extends BaseModel {
|
||||
show(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}/changes`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMergeRequestChanges;
|
||||
@ -1,12 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectMergeRequestCommits extends BaseModel {
|
||||
show(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}/commits`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMergeRequestCommits;
|
||||
@ -1,18 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectMergeRequestVersions extends BaseModel {
|
||||
all(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}/versions`);
|
||||
}
|
||||
|
||||
show(projectId, mergerequestId, versionId) {
|
||||
const [pId, mId, vId] = [projectId, mergerequestId, versionId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}/versions/${vId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMergeRequestVersions;
|
||||
@ -1,120 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import ProjectMergeRequestVersions from './ProjectMergeRequestVersions';
|
||||
import ProjectMergeRequestChanges from './ProjectMergeRequestChanges';
|
||||
import ProjectMergeRequestCommits from './ProjectMergeRequestCommits';
|
||||
import ResourceNotes from './ResourceNotes';
|
||||
|
||||
class ProjectMergeRequests extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.commits = new ProjectMergeRequestCommits(...args);
|
||||
this.changes = new ProjectMergeRequestChanges(...args);
|
||||
this.versions = new ProjectMergeRequestVersions(...args);
|
||||
this.notes = new ResourceNotes('projects', 'merge_requests', ...args);
|
||||
}
|
||||
|
||||
accept(projectId, mergerequestId, options = {}) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.put(`projects/${pId}/merge_requests/${mId}/merge`, options);
|
||||
}
|
||||
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests`, options);
|
||||
}
|
||||
|
||||
cancelOnPipelineSucess(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.put(`projects/${pId}/merge_requests/${mId}/cancel_merge_when_pipeline_succeeds`);
|
||||
}
|
||||
|
||||
closesIssues(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}/closes_issues`);
|
||||
}
|
||||
|
||||
create(projectId, sourceBranch, targetBranch, title, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests`, Object.assign({
|
||||
id: pId,
|
||||
source_branch: sourceBranch,
|
||||
target_branch: targetBranch,
|
||||
title,
|
||||
}, options));
|
||||
}
|
||||
|
||||
createTodo(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests/${mId}/todo`);
|
||||
}
|
||||
|
||||
edit(projectId, mergerequestId, options = {}) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.put(`projects/${pId}/merge_requests/${mId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/merge_requests/${mId}`);
|
||||
}
|
||||
|
||||
show(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}`);
|
||||
}
|
||||
|
||||
subscribe(projectId, mergerequestId, options = {}) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests/${mId}/subscribe`, options);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests/${mId}/reset_spent_time`);
|
||||
}
|
||||
|
||||
resetTimeEstimate(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests/${mId}/reset_time_estimate`);
|
||||
}
|
||||
|
||||
spentTime(projectId, mergerequestId, duration) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests/${mId}/add_spent_time`, { duration });
|
||||
}
|
||||
|
||||
timeEstimate(projectId, mergerequestId, duration) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/merge_requests/${mId}/time_estimate`, { duration });
|
||||
}
|
||||
|
||||
timeStats(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/merge_requests/${mId}/time_stats`);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/merge_requests/${mId}/unsubscribe`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMergeRequests;
|
||||
@ -1,12 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class Pipelines extends BaseModel {
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/pipelines`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Pipelines;
|
||||
@ -1,30 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectProtectedBranches extends BaseModel {
|
||||
all(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/protected_branches`);
|
||||
}
|
||||
|
||||
protect(projectId, branchName, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/protected_branches`, Object.assign(options, { name: branchName }));
|
||||
}
|
||||
|
||||
show(projectId, branchName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/protected_branches/${branchName}`);
|
||||
}
|
||||
|
||||
unprotect(projectId, branchName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.delete(`projects/${pId}/protected_branches/${branchName}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectProtectedBranches;
|
||||
@ -1,55 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import ProjectRepositoryBranches from './ProjectRepositoryBranches';
|
||||
import ProjectRepositoryTags from './ProjectRepositoryTags';
|
||||
import ProjectRepositoryCommits from './ProjectRepositoryCommits';
|
||||
import ProjectRepositoryFiles from './ProjectRepositoryFiles';
|
||||
|
||||
class ProjectRepository extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.branches = new ProjectRepositoryBranches(...args);
|
||||
this.tags = new ProjectRepositoryTags(...args);
|
||||
this.commits = new ProjectRepositoryCommits(...args);
|
||||
this.files = new ProjectRepositoryFiles(...args);
|
||||
}
|
||||
|
||||
compare(projectId, from, to) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/compare`, { from, to });
|
||||
}
|
||||
|
||||
contributors(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/contributors`);
|
||||
}
|
||||
|
||||
showArchive(projectId, { sha }) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/archive`, { sha });
|
||||
}
|
||||
|
||||
showBlob(projectId, sha) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/blobs/${sha}`);
|
||||
}
|
||||
|
||||
showBlobRaw(projectId, sha) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/blobs/${sha}/raw`);
|
||||
}
|
||||
|
||||
tree(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/tree`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRepository;
|
||||
@ -1,42 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectRepositoryBranches extends BaseModel {
|
||||
all(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/branches`);
|
||||
}
|
||||
|
||||
create(projectId, branchName, ref) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/repository/branches`, { branch: branchName, ref });
|
||||
}
|
||||
|
||||
protect(projectId, branchName, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.put(`projects/${pId}/repository/branches/${branchName}/protect`, options);
|
||||
}
|
||||
|
||||
remove(projectId, branchName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.delete(`projects/${pId}/repository/branches/${branchName}`);
|
||||
}
|
||||
|
||||
show(projectId, branchName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/branches/${branchName}`);
|
||||
}
|
||||
|
||||
unprotect(projectId, branchName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.put(`projects/${pId}/repository/branches/${branchName}/unprotect`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRepositoryBranches;
|
||||
@ -1,18 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectRepositoryCommitComments extends BaseModel {
|
||||
all(projectId, sha, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/commits/${sha}/comments`, options);
|
||||
}
|
||||
|
||||
create(projectId, sha, note, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/repository/commits/${sha}/comments`, Object.assign({ note }, options));
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRepositoryCommitComments;
|
||||
@ -1,37 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import ProjectRepositoryCommitComments from './ProjectRepositoryCommitComments';
|
||||
|
||||
class ProjectRepositoryCommits extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.comments = new ProjectRepositoryCommitComments(...args);
|
||||
}
|
||||
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/commits`, options);
|
||||
}
|
||||
|
||||
diff(projectId, sha) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/commits/${sha}/diff`);
|
||||
}
|
||||
|
||||
show(projectId, sha) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/commits/${sha}`);
|
||||
}
|
||||
|
||||
statuses(projectId, sha, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/commits/${sha}/statuses`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRepositoryCommits;
|
||||
@ -1,44 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectRepositoryFiles extends BaseModel {
|
||||
create(projectId, filePath, branch, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
const path = parse(filePath);
|
||||
const extendedOptions = Object.assign({ branch }, options);
|
||||
|
||||
return this.post(`projects/${pId}/repository/files/${path}`, extendedOptions);
|
||||
}
|
||||
|
||||
edit(projectId, filePath, branch, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
const path = parse(filePath);
|
||||
const extendedOptions = Object.assign({ branch }, options);
|
||||
|
||||
return this.put(`projects/${pId}/repository/files/${path}`, extendedOptions);
|
||||
}
|
||||
|
||||
remove(projectId, filePath, branch, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
const path = parse(filePath);
|
||||
const extendedOptions = Object.assign({ branch }, options);
|
||||
|
||||
return this.delete(`projects/${pId}/repository/files/${path}`, extendedOptions);
|
||||
}
|
||||
|
||||
show(projectId, filePath, ref) {
|
||||
const pId = parse(projectId);
|
||||
const path = parse(filePath);
|
||||
|
||||
return this.get(`projects/${pId}/repository/files/${path}`, { ref });
|
||||
}
|
||||
|
||||
showRaw(projectId, filePath, ref) {
|
||||
const pId = parse(projectId);
|
||||
const path = parse(filePath);
|
||||
|
||||
return this.get(`projects/${pId}/repository/files/${path}/raw`, { ref });
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRepositoryFiles;
|
||||
@ -1,30 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectRepositoryTags extends BaseModel {
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
remove(projectId, tagName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.delete(`projects/${pId}/repository/tags/${encodeURI(tagName)}`);
|
||||
}
|
||||
|
||||
show(projectId, tagName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/repository/tags/${encodeURI(tagName)}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRepositoryTags;
|
||||
@ -1,26 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectRunners extends BaseModel {
|
||||
all(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/runners`, options);
|
||||
}
|
||||
|
||||
enable(projectId, runnerId) {
|
||||
const [pId, rId] = [projectId, runnerId].map(parse);
|
||||
|
||||
return this.post(`projects/${pId}/runners`, {
|
||||
runner_id: rId,
|
||||
});
|
||||
}
|
||||
|
||||
disable(projectId, runnerId) {
|
||||
const [pId, rId] = [projectId, runnerId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/runners/${rId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRunners;
|
||||
@ -1,24 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectServices extends BaseModel {
|
||||
edit(projectId, serviceName, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.put(`projects/${pId}/services/${serviceName}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, serviceName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.delete(`projects/${pId}/services/${serviceName}`);
|
||||
}
|
||||
|
||||
show(projectId, serviceName) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/services/${serviceName}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectServices;
|
||||
@ -1,36 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ProjectTriggers extends BaseModel {
|
||||
add(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/triggers`, options);
|
||||
}
|
||||
|
||||
all(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}/triggers`);
|
||||
}
|
||||
|
||||
edit(projectId, triggerId, options = {}) {
|
||||
const [pId, tId] = [projectId, triggerId].map(parse);
|
||||
|
||||
return this.put(`projects/${pId}/triggers/${tId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, triggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/triggers/${tId}`);
|
||||
}
|
||||
|
||||
show(projectId, triggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(parse);
|
||||
|
||||
return this.get(`projects/${pId}/triggers/${tId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectTriggers;
|
||||
@ -1,142 +0,0 @@
|
||||
import Fs from 'fs';
|
||||
import Path from 'path';
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import ProjectHooks from './ProjectHooks';
|
||||
import ProjectIssues from './ProjectIssues';
|
||||
import ProjectLabels from './ProjectLabels';
|
||||
import ProjectRepository from './ProjectRepository';
|
||||
import ProjectProtectedBranches from './ProjectProtectedBranches';
|
||||
import ProjectDeployKeys from './ProjectDeployKeys';
|
||||
import ProjectMergeRequests from './ProjectMergeRequests';
|
||||
import ProjectServices from './ProjectServices';
|
||||
import ProjectTriggers from './ProjectTriggers';
|
||||
import ProjectRunners from './ProjectRunners';
|
||||
import ProjectPipelines from './ProjectPipelines';
|
||||
import ProjectJobs from './ProjectJobs';
|
||||
import ProjectEnvironments from './ProjectEnvironments';
|
||||
import ResourceCustomAttributes from './ResourceCustomAttributes';
|
||||
import ResourceMembers from './ResourceMembers';
|
||||
import ResourceAccessRequests from './ResourceAccessRequests';
|
||||
import ResourceMilestones from './ResourceMilestones';
|
||||
import ResourceNotes from './ResourceNotes';
|
||||
|
||||
|
||||
class Projects extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.hooks = new ProjectHooks(...args);
|
||||
this.issues = new ProjectIssues(...args);
|
||||
this.labels = new ProjectLabels(...args);
|
||||
this.repository = new ProjectRepository(...args);
|
||||
this.protectedBranches = new ProjectProtectedBranches(...args);
|
||||
this.deployKeys = new ProjectDeployKeys(...args);
|
||||
this.mergeRequests = new ProjectMergeRequests(...args);
|
||||
this.services = new ProjectServices(...args);
|
||||
this.triggers = new ProjectTriggers(...args);
|
||||
this.pipelines = new ProjectPipelines(...args);
|
||||
this.jobs = new ProjectJobs(...args);
|
||||
this.environments = new ProjectEnvironments(...args);
|
||||
this.runners = new ProjectRunners(...args);
|
||||
this.customAttributes = new ResourceCustomAttributes('projects', ...args);
|
||||
this.members = new ResourceMembers('projects', ...args);
|
||||
this.accessRequests = new ResourceAccessRequests('projects', ...args);
|
||||
this.milestones = new ResourceMilestones('projects', ...args);
|
||||
this.snippets = new ResourceNotes('projects', 'snippets', ...args);
|
||||
}
|
||||
|
||||
all(options = {}) {
|
||||
return this.get('projects', options);
|
||||
}
|
||||
|
||||
create(options = {}) {
|
||||
if (options.userId) {
|
||||
const uId = parse(options.userId);
|
||||
|
||||
return this.post(`projects/user/${uId}`, options);
|
||||
}
|
||||
|
||||
return this.post('projects', options);
|
||||
}
|
||||
|
||||
edit(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.put(`projects/${pId}`, options);
|
||||
}
|
||||
|
||||
fork(projectId, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/fork`, options);
|
||||
}
|
||||
|
||||
remove(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.delete(`projects/${pId}`);
|
||||
}
|
||||
|
||||
search(projectName) {
|
||||
return this.get('projects', { search: projectName });
|
||||
}
|
||||
|
||||
share(projectId, groupId, groupAccess, options) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
if (!groupId || !groupAccess) throw new Error('Missing required arguments');
|
||||
|
||||
options.group_id = groupId;
|
||||
options.group_access = groupAccess;
|
||||
|
||||
return this.post(`projects/${pId}/share`, options);
|
||||
}
|
||||
|
||||
show(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.get(`projects/${pId}`);
|
||||
}
|
||||
|
||||
star(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/star`);
|
||||
}
|
||||
|
||||
statuses(projectId, sha, state, options = {}) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/statuses/${sha}`, Object.assign({ state }, options));
|
||||
}
|
||||
|
||||
unshare(projectId, groupId) {
|
||||
const [pId, gId] = [projectId, groupId].map(parse);
|
||||
|
||||
return this.delete(`projects/${pId}/share${gId}`);
|
||||
}
|
||||
|
||||
unstar(projectId) {
|
||||
const pId = parse(projectId);
|
||||
|
||||
return this.post(`projects/${pId}/unstar`);
|
||||
}
|
||||
|
||||
upload(projectId, filePath, { fileName = Path.basename(filePath) } = {}) {
|
||||
const pId = parse(projectId);
|
||||
const file = Fs.readFileSync(filePath);
|
||||
|
||||
return this.postForm(`projects/${pId}/uploads`, {
|
||||
file: {
|
||||
value: file,
|
||||
options: {
|
||||
filename: fileName,
|
||||
contentType: 'application/octet-stream',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Projects;
|
||||
@ -1,45 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
const ACCESS_LEVELS = {
|
||||
GUEST: 10,
|
||||
REPORTER: 20,
|
||||
DEVELOPER: 30,
|
||||
MASTER: 40,
|
||||
OWNER: 50,
|
||||
};
|
||||
|
||||
class ResourceAccessRequests extends BaseModel {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
this.ACCESS_LEVELS = ACCESS_LEVELS;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
const rId = parse(resourceId);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/access_requests`);
|
||||
}
|
||||
|
||||
request(resourceId) {
|
||||
const rId = parse(resourceId);
|
||||
|
||||
return this.post(`${this.resourceType}/${rId}/access_requests`);
|
||||
}
|
||||
|
||||
approve(resourceId, userId, { access_level = 30 }) {
|
||||
const [rId, uId] = [resourceId, userId].map(parse);
|
||||
|
||||
return this.post(`${this.resourceType}/${rId}/access_requests/${uId}/approve`, { access_level });
|
||||
}
|
||||
|
||||
deny(resourceId, userId) {
|
||||
const [rId, uId] = [resourceId, userId].map(parse);
|
||||
|
||||
return this.delete(`${this.resourceType}/${rId}/access_requests/${uId}/approve`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceAccessRequests;
|
||||
@ -1,36 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ResourceCustomAttributes extends BaseModel {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
const rId = parse(resourceId);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/custom_attributes`);
|
||||
}
|
||||
|
||||
set(resourceId, customAttributeId, value) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(parse);
|
||||
|
||||
return this.put(`${this.resourceType}/${rId}/custom_attributes/${cId}`, { value });
|
||||
}
|
||||
|
||||
remove(resourceId, customAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(parse);
|
||||
|
||||
return this.delete(`${this.resourceType}/${rId}/custom_attributes/${cId}`);
|
||||
}
|
||||
|
||||
show(resourceId, customAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/custom_attributes/${cId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceCustomAttributes;
|
||||
@ -1,47 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ResourceMembers extends BaseModel {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
const rId = parse(resourceId);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/members`);
|
||||
}
|
||||
|
||||
add(resourceId, userId, accessLevel) {
|
||||
const [rId, uId] = [resourceId, userId].map(parse);
|
||||
|
||||
return this.post(`${this.resourceType}/${rId}/members`, {
|
||||
user_id: uId,
|
||||
access_level: parseInt(accessLevel, 10),
|
||||
});
|
||||
}
|
||||
|
||||
edit(resourceId, userId, accessLevel) {
|
||||
const [rId, uId] = [resourceId, userId].map(parse);
|
||||
|
||||
return this.put(`${this.resourceType}/${rId}/members/${uId}`, {
|
||||
access_level: parseInt(accessLevel, 10),
|
||||
});
|
||||
}
|
||||
|
||||
show(resourceId, userId) {
|
||||
const [rId, uId] = [resourceId, userId].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/members/${uId}`);
|
||||
}
|
||||
|
||||
remove(resourceId, userId) {
|
||||
const [rId, uId] = [resourceId, userId].map(parse);
|
||||
|
||||
return this.delete(`${this.resourceType}/${rId}/members/${uId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceMembers;
|
||||
@ -1,18 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class GroupMilestoneIssues extends BaseModel {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId, milestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/milestones/${mId}/issues`);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupMilestoneIssues;
|
||||
@ -1,18 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ResourceMilestoneMergeRequests extends BaseModel {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId, milestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/milestones/${mId}/merge_requests`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceMilestoneMergeRequests;
|
||||
@ -1,40 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import ResourceMilestoneIssues from './ResourceMilestoneIssues';
|
||||
import ResourceMilestoneMergeRequests from './ResourceMilestoneMergeRequests';
|
||||
|
||||
class ResourceMilestones extends BaseModel {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
this.issues = new ResourceMilestoneIssues(resourceType, ...args);
|
||||
this.mergeRequests = new ResourceMilestoneMergeRequests(resourceType, ...args);
|
||||
}
|
||||
|
||||
all(resourceId, options = {}) {
|
||||
const rId = parse(resourceId);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/milestones`, options);
|
||||
}
|
||||
|
||||
create(resourceId, title, options) {
|
||||
const rId = parse(resourceId);
|
||||
|
||||
return this.post(`${this.resourceType}/${rId}/milestones`, options);
|
||||
}
|
||||
|
||||
edit(resourceId, milestoneId, options) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(parse);
|
||||
|
||||
return this.put(`${this.resourceType}/${rId}/milestones/${mId}`, options);
|
||||
}
|
||||
|
||||
show(resourceId, milestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/milestones/${mId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceMilestones;
|
||||
@ -1,47 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class ResourceNotes extends BaseModel {
|
||||
constructor(resourceType, resource2Type, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
this.resource2Type = resource2Type;
|
||||
}
|
||||
|
||||
all(resourceId, resource2Id, options = {}) {
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes`, options);
|
||||
}
|
||||
|
||||
create(resourceId, resource2Id, options = {}) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(parse);
|
||||
|
||||
return this.post(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes`, options);
|
||||
}
|
||||
|
||||
edit(resourceId, resource2Id, noteId, options = {}) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(parse);
|
||||
|
||||
return this.put(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`, options);
|
||||
}
|
||||
|
||||
remove(resourceId, resource2Id, noteId) {
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(parse);
|
||||
|
||||
return this.delete(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
|
||||
}
|
||||
|
||||
show(resourceId, resource2Id, noteId) {
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(parse);
|
||||
|
||||
return this.get(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceNotes;
|
||||
@ -1,38 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class Runners extends BaseModel {
|
||||
all(options = {}) {
|
||||
return this.get('runners/all', options);
|
||||
}
|
||||
|
||||
allOwned(options = {}) {
|
||||
return this.get('runners', options);
|
||||
}
|
||||
|
||||
edit(runnerId, attributes) {
|
||||
const rId = parse(runnerId);
|
||||
|
||||
return this.put(`runners/${rId}`, attributes);
|
||||
}
|
||||
|
||||
remove(runnerId) {
|
||||
const rId = parse(runnerId);
|
||||
|
||||
return this.delete(`runners/${rId}`);
|
||||
}
|
||||
|
||||
show(runnerId) {
|
||||
const rId = parse(runnerId);
|
||||
|
||||
return this.get(`runners/${rId}`);
|
||||
}
|
||||
|
||||
showJobs(runnerId) {
|
||||
const rId = parse(runnerId);
|
||||
|
||||
return this.get(`runners/${rId}/jobs`);
|
||||
}
|
||||
}
|
||||
|
||||
export default Runners;
|
||||
@ -1,28 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
|
||||
class UserKeys extends BaseModel {
|
||||
add(userId, title, key) {
|
||||
const uId = parse(userId);
|
||||
|
||||
return this.post(`users/${uId}/keys`, {
|
||||
title,
|
||||
key,
|
||||
});
|
||||
}
|
||||
|
||||
remove(userId, keyId) {
|
||||
const uId = parse(userId);
|
||||
const kId = parse(keyId);
|
||||
|
||||
return this.delete(`users/${uId}/keys/${kId}`);
|
||||
}
|
||||
|
||||
all(userId) {
|
||||
const uId = parse(userId);
|
||||
|
||||
return this.get(`users/${uId}/keys`);
|
||||
}
|
||||
}
|
||||
|
||||
export default UserKeys;
|
||||
@ -1,46 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { parse } from '../Utils';
|
||||
import UserKeys from './UserKeys';
|
||||
import ResourceCustomAttributes from './ResourceCustomAttributes';
|
||||
|
||||
class Users extends BaseModel {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.customAttributes = new ResourceCustomAttributes('users', ...args);
|
||||
this.keys = new UserKeys(...args);
|
||||
}
|
||||
|
||||
all(options = {}) {
|
||||
return this.get('users', options);
|
||||
}
|
||||
|
||||
create(options = {}) {
|
||||
return this.post('users', options);
|
||||
}
|
||||
|
||||
current() {
|
||||
return this.get('user');
|
||||
}
|
||||
|
||||
session(email, password) {
|
||||
return this.post('session', {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
}
|
||||
|
||||
search(emailOrUsername) {
|
||||
return this.get('users', {
|
||||
search: emailOrUsername,
|
||||
});
|
||||
}
|
||||
|
||||
show(userId) {
|
||||
const uId = parse(userId);
|
||||
|
||||
return this.get(`users/${uId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default Users;
|
||||
@ -1,9 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
|
||||
class Version extends BaseModel {
|
||||
show() {
|
||||
return this.get('version');
|
||||
}
|
||||
}
|
||||
|
||||
export default Version;
|
||||
@ -1,17 +0,0 @@
|
||||
import Groups from './Groups';
|
||||
import Projects from './Projects';
|
||||
import Issues from './Issues';
|
||||
import Users from './Users';
|
||||
import Runners from './Runners';
|
||||
import MergeRequests from './MergeRequests';
|
||||
import Version from './Version';
|
||||
|
||||
export {
|
||||
Groups,
|
||||
Projects,
|
||||
Runners,
|
||||
Issues,
|
||||
Users,
|
||||
MergeRequests,
|
||||
Version,
|
||||
};
|
||||
@ -1,9 +0,0 @@
|
||||
function parse(value) {
|
||||
if (Number.isInteger(value)) return value;
|
||||
|
||||
return encodeURIComponent(value);
|
||||
}
|
||||
|
||||
export {
|
||||
parse,
|
||||
};
|
||||
10
src/index.js
10
src/index.js
@ -1,3 +1,9 @@
|
||||
import API from './API';
|
||||
import * as Services from './services';
|
||||
|
||||
module.exports = ({ url, token, oauthToken }) => new API({ url, token, oauthToken });
|
||||
export const API = credentials =>
|
||||
Object.entries(Services).reduce(
|
||||
(output, [key, Value]) => { output[key] = new Value(credentials); return output; },
|
||||
{},
|
||||
);
|
||||
|
||||
export * from './services';
|
||||
|
||||
@ -19,32 +19,17 @@ async function getAllPages(client, endpoint, options, results = []) {
|
||||
}
|
||||
|
||||
class BaseModel {
|
||||
constructor(APIClient) {
|
||||
this.client = APIClient;
|
||||
}
|
||||
constructor({ url = 'https://gitlab.com', token, oauthToken }) {
|
||||
this.url = `${url}/api/v4/`;
|
||||
this.headers = {};
|
||||
|
||||
get(endpoint, options = {}) {
|
||||
if (!options.page) {
|
||||
return getAllPages(this.client, endpoint, options);
|
||||
if (oauthToken) {
|
||||
this.headers.Authorization = `Bearer ${oauthToken}`;
|
||||
} else if (token) {
|
||||
this.headers['private-token'] = token;
|
||||
} else {
|
||||
throw new Error('`token` (private-token) or `oauth_token` is mandatory');
|
||||
}
|
||||
|
||||
return this.client.get(endpoint, options);
|
||||
}
|
||||
|
||||
post(endpoint, options = {}) {
|
||||
return this.client.post(endpoint, options);
|
||||
}
|
||||
|
||||
postForm(endpoint, options = {}) {
|
||||
return this.client.postForm(endpoint, options);
|
||||
}
|
||||
|
||||
put(endpoint, options = {}) {
|
||||
return this.client.put(endpoint, options);
|
||||
}
|
||||
|
||||
delete(endpoint, options = {}) {
|
||||
return this.client.delete(endpoint, options);
|
||||
}
|
||||
}
|
||||
|
||||
59
src/infrastructure/RequestHelper.js
Normal file
59
src/infrastructure/RequestHelper.js
Normal file
@ -0,0 +1,59 @@
|
||||
import Request from 'request-promise';
|
||||
import Humps from 'humps';
|
||||
|
||||
function defaultRequest(url, endpoint, {
|
||||
headers,
|
||||
body,
|
||||
qs,
|
||||
formData,
|
||||
resolveWithFullResponse = false,
|
||||
}) {
|
||||
const params = {
|
||||
url: `${url}${endpoint}`,
|
||||
headers,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (body) params.body = Humps.decamelizeKeys(body);
|
||||
if (qs) params.qs = Humps.decamelizeKeys(qs);
|
||||
if (formData) params.formData = formData;
|
||||
|
||||
params.resolveWithFullResponse = resolveWithFullResponse;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
class RequestHelper {
|
||||
static get(service, endpoint, options, fullResponse = false) {
|
||||
return Request.get(defaultRequest(service.url, endpoint, {
|
||||
headers: service.headers,
|
||||
qs: options,
|
||||
resolveWithFullResponse: fullResponse,
|
||||
}));
|
||||
}
|
||||
|
||||
static post(service, endpoint, options, form = false) {
|
||||
const body = form ? 'fromData' : 'body';
|
||||
|
||||
return Request.post(defaultRequest(service.url, endpoint, {
|
||||
headers: service.headers,
|
||||
[body]: options,
|
||||
}));
|
||||
}
|
||||
|
||||
static put(service, endpoint, options) {
|
||||
return Request.put(defaultRequest(service.url, endpoint, {
|
||||
headers: service.headers,
|
||||
body: options,
|
||||
}));
|
||||
}
|
||||
|
||||
static delete(service, endpoint, options) {
|
||||
return Request.delete(defaultRequest(service.url, endpoint, {
|
||||
headers: service.headers,
|
||||
qs: options,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export default RequestHelper;
|
||||
2
src/infrastructure/index.js
Normal file
2
src/infrastructure/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
export { default as BaseService } from './BaseService';
|
||||
export { default as RequestHelper } from './RequestHelper';
|
||||
57
src/services/Branches.js
Normal file
57
src/services/Branches.js
Normal file
@ -0,0 +1,57 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Branches extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/branches`, options);
|
||||
}
|
||||
|
||||
create(projectId, branchName, ref) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/branches`, {
|
||||
branch: branchName,
|
||||
ref,
|
||||
});
|
||||
}
|
||||
|
||||
protect(projectId, branchName, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/repository/branches/${branchName}/protect`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, branchName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/repository/branches/${branchName}`,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, branchName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/branches/${branchName}`,
|
||||
);
|
||||
}
|
||||
|
||||
unprotect(projectId, branchName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/repository/branches/${branchName}/unprotect`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Branches;
|
||||
59
src/services/Commits.js
Normal file
59
src/services/Commits.js
Normal file
@ -0,0 +1,59 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Commits extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/commits`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
allComments(projectId, sha) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/comments`,
|
||||
);
|
||||
}
|
||||
|
||||
createComment(projectId, sha, note, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/comments`,
|
||||
Object.assign({ note }, options),
|
||||
);
|
||||
}
|
||||
|
||||
diff(projectId, sha) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/diff`,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, sha) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}`);
|
||||
}
|
||||
|
||||
statuses(projectId, sha, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/statuses`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Commits;
|
||||
23
src/services/DeployKeys.js
Normal file
23
src/services/DeployKeys.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class DeployKeys extends BaseService {
|
||||
add(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deploy_keys`, options);
|
||||
}
|
||||
|
||||
all(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deploy_keys`);
|
||||
}
|
||||
|
||||
show(projectId, keyId) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deploy_keys/${kId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default DeployKeys;
|
||||
11
src/services/Environments.js
Normal file
11
src/services/Environments.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Environments extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/environments`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Environments;
|
||||
9
src/services/GroupAccessRequests.js
Normal file
9
src/services/GroupAccessRequests.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceAccessRequests } from '../templates';
|
||||
|
||||
export class GroupAccessRequests {
|
||||
constructor(options) {
|
||||
return new ResourceAccessRequests('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupAccessRequests;
|
||||
9
src/services/GroupCustomAttributes.js
Normal file
9
src/services/GroupCustomAttributes.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
|
||||
export class GroupCustomAttributes {
|
||||
constructor(options) {
|
||||
return new ResourceCustomAttributes('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupCustomAttributes;
|
||||
9
src/services/GroupMembers.js
Normal file
9
src/services/GroupMembers.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceMembers } from '../templates';
|
||||
|
||||
export class GroupMembers {
|
||||
constructor(options) {
|
||||
return new ResourceMembers('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupMembers;
|
||||
9
src/services/GroupMilestones.js
Normal file
9
src/services/GroupMilestones.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceMilestones } from '../templates';
|
||||
|
||||
export class GroupMilestones {
|
||||
constructor(options) {
|
||||
return new ResourceMilestones('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupMilestones;
|
||||
17
src/services/GroupProjects.js
Normal file
17
src/services/GroupProjects.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class GroupProjects extends BaseService {
|
||||
all(groupId, options = {}) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/projects`, options);
|
||||
}
|
||||
|
||||
add(groupId, projectId) {
|
||||
const [gId, pId] = [groupId, projectId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/projects/${pId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default GroupProjects;
|
||||
37
src/services/Groups.js
Normal file
37
src/services/Groups.js
Normal file
@ -0,0 +1,37 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Groups extends BaseService {
|
||||
all(options = {}) {
|
||||
return RequestHelper.get(this, 'groups', options);
|
||||
}
|
||||
|
||||
allSubgroups(groupId, options = {}) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/subgroups`, options);
|
||||
}
|
||||
|
||||
show(groupId) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}`);
|
||||
}
|
||||
|
||||
create(options = {}) {
|
||||
return RequestHelper.post(this, 'groups', options);
|
||||
}
|
||||
|
||||
remove(groupId) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.delete(this, `groups/${gId}`);
|
||||
}
|
||||
|
||||
search(nameOrPath) {
|
||||
return RequestHelper.get(this, 'groups', {
|
||||
search: nameOrPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Groups;
|
||||
72
src/services/Issues.js
Normal file
72
src/services/Issues.js
Normal file
@ -0,0 +1,72 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Issues extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
if (projectId) {
|
||||
return RequestHelper.get(this, `projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, 'issues', options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
edit(projectId, issueId, options = {}) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
link(projectId, issueIId, targetProjectId, targetIssueId, options = {}) {
|
||||
const [pId, iId] = [projectId, issueIId].map(encodeURIComponent);
|
||||
const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/links`,
|
||||
Object.assign(
|
||||
{ target_project_id: targetpId, target_issue_id: targetIId },
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, issueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
show(projectId, issueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
subscribe(projectId, issueId, options = {}) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/subscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, issueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/unsubscribe`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Issues;
|
||||
11
src/services/Jobs.js
Normal file
11
src/services/Jobs.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Jobs extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Jobs;
|
||||
54
src/services/Labels.js
Normal file
54
src/services/Labels.js
Normal file
@ -0,0 +1,54 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Labels extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
edit(projectId, labelName, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/labels`,
|
||||
Object.assign({ name: labelName }, options),
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, labelName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/labels`, {
|
||||
name: labelName,
|
||||
});
|
||||
}
|
||||
|
||||
subscribe(projectId, labelId, options = {}) {
|
||||
const [pId, lId] = [projectId, labelId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/issues/${lId}/subscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, labelId) {
|
||||
const [pId, lId] = [projectId, labelId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/issues/${lId}/unsubscribe`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Labels;
|
||||
9
src/services/MergeRequestNotes.js
Normal file
9
src/services/MergeRequestNotes.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceNotes } from '../templates';
|
||||
|
||||
export class MergeRequestNotes {
|
||||
constructor(options) {
|
||||
return new ResourceNotes('mergerequests', 'notes', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default MergeRequestNotes;
|
||||
23
src/services/MergeRequestVersions.js
Normal file
23
src/services/MergeRequestVersions.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class MergeRequestVersions extends BaseService {
|
||||
all(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/versions`,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, mergerequestId, versionId) {
|
||||
const [pId, mId, vId] = [projectId, mergerequestId, versionId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/versions/${vId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default MergeRequestVersions;
|
||||
176
src/services/MergeRequests.js
Normal file
176
src/services/MergeRequests.js
Normal file
@ -0,0 +1,176 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class MergeRequests extends BaseService {
|
||||
accept(projectId, mergerequestId, options = {}) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/merge`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
if (projectId) {
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests`, options);
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, 'merge_requests', options);
|
||||
}
|
||||
|
||||
cancelOnPipelineSucess(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/cancel_merge_when_pipeline_succeeds`,
|
||||
);
|
||||
}
|
||||
|
||||
changes(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/changes`,
|
||||
);
|
||||
}
|
||||
|
||||
closesIssues(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/closes_issues`,
|
||||
);
|
||||
}
|
||||
|
||||
commits(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/commits`,
|
||||
);
|
||||
}
|
||||
|
||||
create(projectId, sourceBranch, targetBranch, title, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests`,
|
||||
Object.assign(
|
||||
{
|
||||
id: pId,
|
||||
source_branch: sourceBranch,
|
||||
target_branch: targetBranch,
|
||||
title,
|
||||
},
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
createTodo(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/todo`,
|
||||
);
|
||||
}
|
||||
|
||||
edit(projectId, mergerequestId, options = {}) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/merge_requests/${mId}`);
|
||||
}
|
||||
|
||||
show(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}`);
|
||||
}
|
||||
|
||||
subscribe(projectId, mergerequestId, options = {}) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/subscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/reset_spent_time`,
|
||||
);
|
||||
}
|
||||
|
||||
resetTimeEstimate(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/reset_time_estimate`,
|
||||
);
|
||||
}
|
||||
|
||||
spentTime(projectId, mergerequestId, duration) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/add_spent_time`,
|
||||
{ duration },
|
||||
);
|
||||
}
|
||||
|
||||
timeEstimate(projectId, mergerequestId, duration) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/time_estimate`,
|
||||
{ duration },
|
||||
);
|
||||
}
|
||||
|
||||
timeStats(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/time_stats`,
|
||||
);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, mergerequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mId}/unsubscribe`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default MergeRequests;
|
||||
11
src/services/Pipelines.js
Normal file
11
src/services/Pipelines.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Pipelines extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Pipelines;
|
||||
9
src/services/ProjectAccessRequests.js
Normal file
9
src/services/ProjectAccessRequests.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceAccessRequests } from '../templates';
|
||||
|
||||
export class ProjectAccessRequests {
|
||||
constructor(options) {
|
||||
return new ResourceAccessRequests('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectAccessRequests;
|
||||
9
src/services/ProjectCustomAttributes.js
Normal file
9
src/services/ProjectCustomAttributes.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
|
||||
export class ProjectCustomAttributes {
|
||||
constructor(options) {
|
||||
return new ResourceCustomAttributes('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectCustomAttributes;
|
||||
43
src/services/ProjectHooks.js
Normal file
43
src/services/ProjectHooks.js
Normal file
@ -0,0 +1,43 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ProjectHooks extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks`, options);
|
||||
}
|
||||
|
||||
show(projectId, hookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks/${hId}`);
|
||||
}
|
||||
|
||||
add(projectId, url, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/hooks`,
|
||||
Object.assign({ url }, options),
|
||||
);
|
||||
}
|
||||
|
||||
edit(projectId, hookId, url, options = {}) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/hooks/${hId}`,
|
||||
Object.assign({ url }, options),
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, hookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/hooks/${hId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectHooks;
|
||||
9
src/services/ProjectMembers.js
Normal file
9
src/services/ProjectMembers.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceMembers } from '../templates';
|
||||
|
||||
export class ProjectMembers {
|
||||
constructor(options) {
|
||||
return new ResourceMembers('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMembers;
|
||||
9
src/services/ProjectMilestones.js
Normal file
9
src/services/ProjectMilestones.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceMilestones } from '../templates';
|
||||
|
||||
export class ProjectMilestones {
|
||||
constructor(options) {
|
||||
return new ResourceMilestones('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMilestones;
|
||||
25
src/services/ProjectRunners.js
Normal file
25
src/services/ProjectRunners.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ProjectRunners extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/runners`, options);
|
||||
}
|
||||
|
||||
enable(projectId, runnerId) {
|
||||
const [pId, rId] = [projectId, runnerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/runners`, {
|
||||
runner_id: rId,
|
||||
});
|
||||
}
|
||||
|
||||
disable(projectId, runnerId) {
|
||||
const [pId, rId] = [projectId, runnerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/runners/${rId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectRunners;
|
||||
9
src/services/ProjectSnippets.js
Normal file
9
src/services/ProjectSnippets.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceNotes } from '../templates';
|
||||
|
||||
export class ProjectSnippets {
|
||||
constructor(options) {
|
||||
return new ResourceNotes('projects', 'snippets', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectSnippets;
|
||||
108
src/services/Projects.js
Normal file
108
src/services/Projects.js
Normal file
@ -0,0 +1,108 @@
|
||||
import Fs from 'fs';
|
||||
import Path from 'path';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Projects extends BaseService {
|
||||
all(options = {}) {
|
||||
return RequestHelper.get(this, 'projects', options);
|
||||
}
|
||||
|
||||
create(options = {}) {
|
||||
if (options.userId) {
|
||||
const uId = encodeURIComponent(options.userId);
|
||||
|
||||
return RequestHelper.post(this, `projects/user/${uId}`, options);
|
||||
}
|
||||
|
||||
return RequestHelper.post(this, 'projects', options);
|
||||
}
|
||||
|
||||
edit(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
fork(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/fork`, options);
|
||||
}
|
||||
|
||||
remove(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}`);
|
||||
}
|
||||
|
||||
search(projectName) {
|
||||
return RequestHelper.get(this, 'projects', { search: projectName });
|
||||
}
|
||||
|
||||
share(projectId, groupId, groupAccess, options) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
if (!groupId || !groupAccess) throw new Error('Missing required arguments');
|
||||
|
||||
options.group_id = groupId;
|
||||
options.group_access = groupAccess;
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/share`, options);
|
||||
}
|
||||
|
||||
show(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}`);
|
||||
}
|
||||
|
||||
star(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/star`);
|
||||
}
|
||||
|
||||
statuses(projectId, sha, state, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/statuses/${sha}`,
|
||||
Object.assign({ state }, options),
|
||||
);
|
||||
}
|
||||
|
||||
unshare(projectId, groupId) {
|
||||
const [pId, gId] = [projectId, groupId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/share${gId}`);
|
||||
}
|
||||
|
||||
unstar(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/unstar`);
|
||||
}
|
||||
|
||||
upload(projectId, filePath, { fileName = Path.basename(filePath) } = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const file = Fs.readFileSync(filePath);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/uploads`,
|
||||
{
|
||||
file: {
|
||||
value: file,
|
||||
options: {
|
||||
filename: fileName,
|
||||
contentType: 'application/octet-stream',
|
||||
},
|
||||
},
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Projects;
|
||||
39
src/services/ProtectedBranches.js
Normal file
39
src/services/ProtectedBranches.js
Normal file
@ -0,0 +1,39 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ProtectedBranches extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_branches`, options);
|
||||
}
|
||||
|
||||
protect(projectId, branchName, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/protected_branches`,
|
||||
Object.assign(options, { name: branchName }),
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, branchName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/protected_branches/${branchName}`,
|
||||
);
|
||||
}
|
||||
|
||||
unprotect(projectId, branchName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/protected_branches/${branchName}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProtectedBranches;
|
||||
49
src/services/Repositories.js
Normal file
49
src/services/Repositories.js
Normal file
@ -0,0 +1,49 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Repositories extends BaseService {
|
||||
compare(projectId, from, to) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/compare`, {
|
||||
from,
|
||||
to,
|
||||
});
|
||||
}
|
||||
|
||||
contributors(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/contributors`);
|
||||
}
|
||||
|
||||
showArchive(projectId, { sha }) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/archive`, {
|
||||
sha,
|
||||
});
|
||||
}
|
||||
|
||||
showBlob(projectId, sha) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}`);
|
||||
}
|
||||
|
||||
showBlobRaw(projectId, sha) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/blobs/${sha}/raw`,
|
||||
);
|
||||
}
|
||||
|
||||
tree(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tree`, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Repositories;
|
||||
56
src/services/RepositoryFiles.js
Normal file
56
src/services/RepositoryFiles.js
Normal file
@ -0,0 +1,56 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class RepositoryFiles extends BaseService {
|
||||
create(projectId, filePath, branch, options = {}) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
const extendedOptions = Object.assign({ branch }, options);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}`,
|
||||
extendedOptions,
|
||||
);
|
||||
}
|
||||
|
||||
edit(projectId, filePath, branch, options = {}) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
const extendedOptions = Object.assign({ branch }, options);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}`,
|
||||
extendedOptions,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, filePath, branch, options = {}) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
const extendedOptions = Object.assign({ branch }, options);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}`,
|
||||
extendedOptions,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, filePath, ref) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/files/${path}`, {
|
||||
ref,
|
||||
});
|
||||
}
|
||||
|
||||
showRaw(projectId, filePath, ref) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}/raw`,
|
||||
{ ref },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default RepositoryFiles;
|
||||
37
src/services/Runners.js
Normal file
37
src/services/Runners.js
Normal file
@ -0,0 +1,37 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Runners extends BaseService {
|
||||
all(options = {}) {
|
||||
return RequestHelper.get(this, 'runners/all', options);
|
||||
}
|
||||
|
||||
allOwned(options = {}) {
|
||||
return RequestHelper.get(this, 'runners', options);
|
||||
}
|
||||
|
||||
edit(runnerId, attributes) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.put(this, `runners/${rId}`, attributes);
|
||||
}
|
||||
|
||||
remove(runnerId) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.delete(this, `runners/${rId}`);
|
||||
}
|
||||
|
||||
show(runnerId) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.get(this, `runners/${rId}`);
|
||||
}
|
||||
|
||||
showJobs(runnerId) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.get(this, `runners/${rId}/jobs`);
|
||||
}
|
||||
}
|
||||
|
||||
export default Runners;
|
||||
30
src/services/Services.js
Normal file
30
src/services/Services.js
Normal file
@ -0,0 +1,30 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Services extends BaseService {
|
||||
edit(projectId, serviceName, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`projects/${pId}/services/${serviceName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, serviceName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/services/${serviceName}`,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, serviceName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/services/${serviceName}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default Services;
|
||||
41
src/services/SystemHooks.js
Normal file
41
src/services/SystemHooks.js
Normal file
@ -0,0 +1,41 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class SystemHooks extends BaseService {
|
||||
all(options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `hooks`, options);
|
||||
}
|
||||
|
||||
show(hookId) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.get(this, `hooks/${hId}`);
|
||||
}
|
||||
|
||||
add(url, options = {}) {
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`hooks`,
|
||||
Object.assign({ url }, options),
|
||||
);
|
||||
}
|
||||
|
||||
edit(hookId, url, options = {}) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`hooks/${hId}`,
|
||||
Object.assign({ url }, options),
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId, hookId) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.delete(this, `hooks/${hId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default SystemHooks;
|
||||
35
src/services/Tags.js
Normal file
35
src/services/Tags.js
Normal file
@ -0,0 +1,35 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Tags extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
remove(projectId, tagName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`projects/${pId}/repository/tags/${encodeURI(tagName)}`,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId, tagName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/repository/tags/${encodeURI(tagName)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Tags;
|
||||
35
src/services/Triggers.js
Normal file
35
src/services/Triggers.js
Normal file
@ -0,0 +1,35 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Triggers extends BaseService {
|
||||
add(projectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/triggers`, options);
|
||||
}
|
||||
|
||||
all(projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers`);
|
||||
}
|
||||
|
||||
edit(projectId, triggerId, options = {}) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/triggers/${tId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, triggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/triggers/${tId}`);
|
||||
}
|
||||
|
||||
show(projectId, triggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers/${tId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default Triggers;
|
||||
9
src/services/UserCustomAttributes.js
Normal file
9
src/services/UserCustomAttributes.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
|
||||
export class UserCustomAttributes {
|
||||
constructor(options) {
|
||||
return new ResourceCustomAttributes('users', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default UserCustomAttributes;
|
||||
174
src/services/Users.js
Normal file
174
src/services/Users.js
Normal file
@ -0,0 +1,174 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class Users extends BaseService {
|
||||
all(options = {}) {
|
||||
return RequestHelper.get(this, 'users', options);
|
||||
}
|
||||
|
||||
activities() {
|
||||
return RequestHelper.get(this, 'users/activities');
|
||||
}
|
||||
|
||||
block(userId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/block`);
|
||||
}
|
||||
|
||||
create(options = {}) {
|
||||
return RequestHelper.post(this, 'users', options);
|
||||
}
|
||||
|
||||
current() {
|
||||
return RequestHelper.get(this, 'user');
|
||||
}
|
||||
|
||||
session(email, password) {
|
||||
return RequestHelper.post(this, 'session', {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
}
|
||||
|
||||
search(emailOrUsername) {
|
||||
return RequestHelper.get(this, 'users', {
|
||||
search: emailOrUsername,
|
||||
});
|
||||
}
|
||||
|
||||
show(userId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}`);
|
||||
}
|
||||
|
||||
remove(userId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.delete(this, `users/${uId}`);
|
||||
}
|
||||
|
||||
unblock(userId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/unblock`);
|
||||
}
|
||||
|
||||
// Emails
|
||||
addEmail(email, userId) {
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/emails` : 'users/emails';
|
||||
|
||||
return RequestHelper.post(this, url, {
|
||||
email,
|
||||
});
|
||||
}
|
||||
|
||||
allEmails(userId) {
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/emails` : 'users/emails';
|
||||
|
||||
return RequestHelper.get(this, url);
|
||||
}
|
||||
|
||||
showEmail(emailId) {
|
||||
const eId = encodeURIComponent(emailId);
|
||||
|
||||
return RequestHelper.get(this, `users/emails/${eId}`);
|
||||
}
|
||||
|
||||
removeEmail(emailId, userId) {
|
||||
const eId = encodeURIComponent(emailId);
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/emails` : 'users/emails';
|
||||
|
||||
return RequestHelper.delete(this, `${url}/${eId}`);
|
||||
}
|
||||
|
||||
// Impersonation Tokens
|
||||
allImpersonationTokens(userId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/impersonation_tokens`);
|
||||
}
|
||||
|
||||
createImpersonationToken(userId, name, scopes, expiresAt) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/impersonation_tokens`, {
|
||||
name,
|
||||
expiresAt,
|
||||
scopes,
|
||||
});
|
||||
}
|
||||
|
||||
showImpersonationToken(userId, tokenId) {
|
||||
const [uId, tId] = [userId, tokenId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/impersonation_tokens/${tId}`);
|
||||
}
|
||||
|
||||
revokeImpersonationToken(userId, tokenId) {
|
||||
const [uId, tId] = [userId, tokenId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `users/${uId}/impersonation_tokens/${tId}`);
|
||||
}
|
||||
|
||||
// GPG Keys
|
||||
allGPGKeys(userId) {
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys';
|
||||
|
||||
return RequestHelper.get(this, url);
|
||||
}
|
||||
|
||||
addGPGKey(title, key, userId) {
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys';
|
||||
|
||||
return RequestHelper.post(this, url, {
|
||||
title,
|
||||
key,
|
||||
});
|
||||
}
|
||||
|
||||
showGPGKey(keyId, userId) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys';
|
||||
|
||||
return RequestHelper.get(this, `${url}/${kId}`);
|
||||
}
|
||||
|
||||
removeGPGKey(keyId, userId) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys';
|
||||
|
||||
return RequestHelper.delete(this, `${url}/${kId}`);
|
||||
}
|
||||
|
||||
// SSH Keys
|
||||
allKeys(userId) {
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/keys` : 'users/keys';
|
||||
|
||||
return RequestHelper.get(this, url);
|
||||
}
|
||||
|
||||
addKey(title, key, userId) {
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/keys` : 'users/keys';
|
||||
|
||||
return RequestHelper.post(this, url, {
|
||||
title,
|
||||
key,
|
||||
});
|
||||
}
|
||||
|
||||
showKey(keyId) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(this, `users/keys/${kId}`);
|
||||
}
|
||||
|
||||
removeKey(keyId, userId) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
const url = userId ? `users/${encodeURIComponent(userId)}/keys` : 'users/keys';
|
||||
|
||||
return RequestHelper.delete(this, `${url}/${kId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default Users;
|
||||
9
src/services/Version.js
Normal file
9
src/services/Version.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
class Version extends BaseService {
|
||||
show() {
|
||||
return RequestHelper.get(this, 'version');
|
||||
}
|
||||
}
|
||||
|
||||
export default Version;
|
||||
41
src/services/index.js
Normal file
41
src/services/index.js
Normal file
@ -0,0 +1,41 @@
|
||||
// Groups
|
||||
export * from './GroupAccessRequests';
|
||||
export * from './GroupCustomAttributes';
|
||||
export * from './GroupMembers';
|
||||
export * from './GroupMilestones';
|
||||
export * from './GroupProjects';
|
||||
export * from './Groups';
|
||||
|
||||
// Projects
|
||||
export * from './Branches';
|
||||
export * from './Commits';
|
||||
export * from './CommitNotes';
|
||||
export * from './DeployKeys';
|
||||
export * from './Environments';
|
||||
export * from './Issues';
|
||||
export * from './Jobs';
|
||||
export * from './Labels';
|
||||
export * from './MergeRequests';
|
||||
export * from './MergeRequestNotes';
|
||||
export * from './MergeRequestVersions';
|
||||
export * from './Pipelines';
|
||||
export * from './Projects';
|
||||
export * from './ProjectAccessRequests';
|
||||
export * from './ProjectCustomAttributes';
|
||||
export * from './ProjectHooks';
|
||||
export * from './ProjectMembers';
|
||||
export * from './ProjectMilestones';
|
||||
export * from './ProjectSnippets';
|
||||
export * from './ProtectedBranches';
|
||||
export * from './Repositories';
|
||||
export * from './RepositoryFiles';
|
||||
export * from './Runners';
|
||||
export * from './Services';
|
||||
export * from './Tags';
|
||||
export * from './Triggers';
|
||||
|
||||
// General
|
||||
export * from './SystemHooks';
|
||||
export * from './Users';
|
||||
// export * from './UserKeys';
|
||||
// export * from './UserGPGKeys';
|
||||
57
src/templates/ResourceAccessRequests.js
Normal file
57
src/templates/ResourceAccessRequests.js
Normal file
@ -0,0 +1,57 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export const ACCESS_LEVELS = {
|
||||
GUEST: 10,
|
||||
REPORTER: 20,
|
||||
DEVELOPER: 30,
|
||||
MASTER: 40,
|
||||
OWNER: 50,
|
||||
};
|
||||
|
||||
export class ResourceAccessRequests extends BaseService {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
this.ACCESS_LEVELS = ACCESS_LEVELS;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/access_requests`,
|
||||
);
|
||||
}
|
||||
|
||||
request(resourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/access_requests`,
|
||||
);
|
||||
}
|
||||
|
||||
approve(resourceId, userId, { accessLevel = 30 }) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/access_requests/${uId}/approve`,
|
||||
{ accessLevel },
|
||||
);
|
||||
}
|
||||
|
||||
deny(resourceId, userId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/access_requests/${uId}/approve`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceAccessRequests;
|
||||
48
src/templates/ResourceCustomAttributes.js
Normal file
48
src/templates/ResourceCustomAttributes.js
Normal file
@ -0,0 +1,48 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ResourceCustomAttributes extends BaseService {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/custom_attributes`,
|
||||
);
|
||||
}
|
||||
|
||||
set(resourceId, customAttributeId, value) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/custom_attributes/${cId}`,
|
||||
{ value },
|
||||
);
|
||||
}
|
||||
|
||||
remove(resourceId, customAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/custom_attributes/${cId}`,
|
||||
);
|
||||
}
|
||||
|
||||
show(resourceId, customAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/custom_attributes/${cId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceCustomAttributes;
|
||||
56
src/templates/ResourceMembers.js
Normal file
56
src/templates/ResourceMembers.js
Normal file
@ -0,0 +1,56 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ResourceMembers extends BaseService {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${this.resourceType}/${rId}/members`);
|
||||
}
|
||||
|
||||
add(resourceId, userId, accessLevel) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `${this.resourceType}/${rId}/members`, {
|
||||
user_id: uId,
|
||||
access_level: parseInt(accessLevel, 10),
|
||||
});
|
||||
}
|
||||
|
||||
edit(resourceId, userId, accessLevel) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/members/${uId}`,
|
||||
{
|
||||
access_level: parseInt(accessLevel, 10),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
show(resourceId, userId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/members/${uId}`,
|
||||
);
|
||||
}
|
||||
|
||||
remove(resourceId, userId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/members/${uId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceMembers;
|
||||
50
src/templates/ResourceMilestones.js
Normal file
50
src/templates/ResourceMilestones.js
Normal file
@ -0,0 +1,50 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ResourceMilestones extends BaseService {
|
||||
constructor(resourceType, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(resourceId, options = {}) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${this.resourceType}/${rId}/milestones`, options);
|
||||
}
|
||||
|
||||
create(resourceId, title, options) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${this.resourceType}/${rId}/milestones`, options);
|
||||
}
|
||||
|
||||
edit(resourceId, milestoneId, options) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${this.resourceType}/${rId}/milestones/${mId}`, options);
|
||||
}
|
||||
|
||||
issues(resourceId, milestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`${this.resourceType}/${rId}/milestones/${mId}/issues`,
|
||||
);
|
||||
}
|
||||
|
||||
mergeRequests(resourceId, milestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${this.resourceType}/${rId}/milestones/${mId}/merge_requests`);
|
||||
}
|
||||
|
||||
show(resourceId, milestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${this.resourceType}/${rId}/milestones/${mId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceMilestones;
|
||||
46
src/templates/ResourceNotes.js
Normal file
46
src/templates/ResourceNotes.js
Normal file
@ -0,0 +1,46 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class ResourceNotes extends BaseService {
|
||||
constructor(resourceType, resource2Type, ...args) {
|
||||
super(...args);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
this.resource2Type = resource2Type;
|
||||
}
|
||||
|
||||
all(resourceId, resource2Id, options = {}) {
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes`, options);
|
||||
}
|
||||
|
||||
create(resourceId, resource2Id, options = {}) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes`, options);
|
||||
}
|
||||
|
||||
edit(resourceId, resource2Id, noteId, options = {}) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`, options);
|
||||
}
|
||||
|
||||
remove(resourceId, resource2Id, noteId) {
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
|
||||
}
|
||||
|
||||
show(resourceId, resource2Id, noteId) {
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ResourceNotes;
|
||||
5
src/templates/index.js
Normal file
5
src/templates/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
export * from './ResourceNotes';
|
||||
export * from './ResourceAccessRequests';
|
||||
export * from './ResourceMembers';
|
||||
export * from './ResourceMilestones';
|
||||
export * from './ResourceCustomAttributes';
|
||||
Loading…
x
Reference in New Issue
Block a user