2021-06-07 05:10:26 -04:00
|
|
|
import createFlash from '~/flash';
|
2019-11-04 04:06:21 -05:00
|
|
|
import { __ } from '~/locale';
|
2021-02-01 10:08:56 -05:00
|
|
|
import axios from './lib/utils/axios_utils';
|
|
|
|
import { joinPaths } from './lib/utils/url_utility';
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2021-07-15 05:09:35 -04:00
|
|
|
export const DEFAULT_PER_PAGE = 20;
|
2019-11-22 13:06:00 -05:00
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* Slow deprecation Notice: Please rather use for new calls
|
|
|
|
* or during refactors /rest_api as this is doing named exports
|
|
|
|
* which support treeshaking
|
|
|
|
*/
|
|
|
|
|
2017-05-19 17:22:46 -04:00
|
|
|
const Api = {
|
2020-11-13 10:09:24 -05:00
|
|
|
DEFAULT_PER_PAGE,
|
2017-05-19 17:22:46 -04:00
|
|
|
groupsPath: '/api/:version/groups.json',
|
2018-01-30 04:10:58 -05:00
|
|
|
groupPath: '/api/:version/groups/:id',
|
2019-01-16 16:57:50 -05:00
|
|
|
groupMembersPath: '/api/:version/groups/:id/members',
|
2020-08-13 02:10:02 -04:00
|
|
|
groupMilestonesPath: '/api/:version/groups/:id/milestones',
|
2018-10-17 16:47:18 -04:00
|
|
|
subgroupsPath: '/api/:version/groups/:id/subgroups',
|
2021-06-08 17:10:05 -04:00
|
|
|
descendantGroupsPath: '/api/:version/groups/:id/descendant_groups',
|
2017-05-19 17:22:46 -04:00
|
|
|
namespacesPath: '/api/:version/namespaces.json',
|
2021-01-08 10:10:26 -05:00
|
|
|
groupInvitationsPath: '/api/:version/groups/:id/invitations',
|
2020-07-16 05:09:28 -04:00
|
|
|
groupPackagesPath: '/api/:version/groups/:id/packages',
|
|
|
|
projectPackagesPath: '/api/:version/projects/:id/packages',
|
|
|
|
projectPackagePath: '/api/:version/projects/:id/packages/:package_id',
|
2021-06-02 11:09:59 -04:00
|
|
|
projectPackageFilePath:
|
|
|
|
'/api/:version/projects/:id/packages/:package_id/package_files/:package_file_id',
|
2017-05-19 17:22:46 -04:00
|
|
|
groupProjectsPath: '/api/:version/groups/:id/projects.json',
|
2021-02-19 16:11:07 -05:00
|
|
|
groupSharePath: '/api/:version/groups/:id/share',
|
2017-09-04 11:41:55 -04:00
|
|
|
projectsPath: '/api/:version/projects.json',
|
2017-12-21 10:05:47 -05:00
|
|
|
projectPath: '/api/:version/projects/:id',
|
2019-06-19 06:21:48 -04:00
|
|
|
forkedProjectsPath: '/api/:version/projects/:id/forks',
|
2019-05-29 09:04:03 -04:00
|
|
|
projectLabelsPath: '/:namespace_path/:project_path/-/labels',
|
2020-09-16 08:10:15 -04:00
|
|
|
projectFileSchemaPath: '/:namespace_path/:project_path/-/schema/:ref/:filename',
|
2019-08-14 05:55:40 -04:00
|
|
|
projectUsersPath: '/api/:version/projects/:id/users',
|
2021-01-08 10:10:26 -05:00
|
|
|
projectInvitationsPath: '/api/:version/projects/:id/invitations',
|
2020-11-13 04:09:30 -05:00
|
|
|
projectMembersPath: '/api/:version/projects/:id/members',
|
2019-03-01 11:33:18 -05:00
|
|
|
projectMergeRequestsPath: '/api/:version/projects/:id/merge_requests',
|
2018-11-28 10:09:38 -05:00
|
|
|
projectMergeRequestPath: '/api/:version/projects/:id/merge_requests/:mrid',
|
|
|
|
projectMergeRequestChangesPath: '/api/:version/projects/:id/merge_requests/:mrid/changes',
|
|
|
|
projectMergeRequestVersionsPath: '/api/:version/projects/:id/merge_requests/:mrid/versions',
|
2018-12-05 02:22:00 -05:00
|
|
|
projectRunnersPath: '/api/:version/projects/:id/runners',
|
2020-02-14 04:08:43 -05:00
|
|
|
projectProtectedBranchesPath: '/api/:version/projects/:id/protected_branches',
|
2020-05-07 17:09:26 -04:00
|
|
|
projectSearchPath: '/api/:version/projects/:id/search',
|
2021-02-19 16:11:07 -05:00
|
|
|
projectSharePath: '/api/:version/projects/:id/share',
|
2020-05-07 17:09:26 -04:00
|
|
|
projectMilestonesPath: '/api/:version/projects/:id/milestones',
|
2020-10-19 05:08:58 -04:00
|
|
|
projectIssuePath: '/api/:version/projects/:id/issues/:issue_iid',
|
2018-05-11 05:37:10 -04:00
|
|
|
mergeRequestsPath: '/api/:version/merge_requests',
|
2021-03-26 08:09:15 -04:00
|
|
|
groupLabelsPath: '/api/:version/groups/:namespace_path/labels',
|
2017-05-19 17:22:46 -04:00
|
|
|
issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key',
|
2020-11-10 04:08:45 -05:00
|
|
|
issuableTemplatesPath: '/:namespace_path/:project_path/templates/:type',
|
2018-10-02 19:00:38 -04:00
|
|
|
projectTemplatePath: '/api/:version/projects/:id/templates/:type/:key',
|
|
|
|
projectTemplatesPath: '/api/:version/projects/:id/templates/:type',
|
2019-07-09 04:44:19 -04:00
|
|
|
userCountsPath: '/api/:version/user_counts',
|
2017-05-19 17:22:46 -04:00
|
|
|
usersPath: '/api/:version/users.json',
|
2018-12-07 22:12:23 -05:00
|
|
|
userPath: '/api/:version/users/:id',
|
|
|
|
userStatusPath: '/api/:version/users/:id/status',
|
2019-11-04 04:06:21 -05:00
|
|
|
userProjectsPath: '/api/:version/users/:id/projects',
|
2018-12-07 22:12:23 -05:00
|
|
|
userPostStatusPath: '/api/:version/user/status',
|
2020-07-09 02:09:37 -04:00
|
|
|
commitPath: '/api/:version/projects/:id/repository/commits/:sha',
|
|
|
|
commitsPath: '/api/:version/projects/:id/repository/commits',
|
2018-12-13 14:17:19 -05:00
|
|
|
applySuggestionPath: '/api/:version/suggestions/:id/apply',
|
2020-06-08 20:08:47 -04:00
|
|
|
applySuggestionBatchPath: '/api/:version/suggestions/batch_apply',
|
2018-05-25 06:08:53 -04:00
|
|
|
commitPipelinesPath: '/:project_id/commit/:sha/pipelines',
|
2017-10-12 17:04:17 -04:00
|
|
|
branchSinglePath: '/api/:version/projects/:id/repository/branches/:branch',
|
2017-10-26 06:14:31 -04:00
|
|
|
createBranchPath: '/api/:version/projects/:id/repository/branches',
|
2018-12-21 06:53:03 -05:00
|
|
|
releasesPath: '/api/:version/projects/:id/releases',
|
2019-10-16 14:08:01 -04:00
|
|
|
releasePath: '/api/:version/projects/:id/releases/:tag_name',
|
2020-04-01 08:08:00 -04:00
|
|
|
releaseLinksPath: '/api/:version/projects/:id/releases/:tag_name/assets/links',
|
|
|
|
releaseLinkPath: '/api/:version/projects/:id/releases/:tag_name/assets/links/:link_id',
|
2019-09-11 05:06:33 -04:00
|
|
|
mergeRequestsPipeline: '/api/:version/projects/:id/merge_requests/:merge_request_iid/pipelines',
|
2019-12-12 13:07:34 -05:00
|
|
|
adminStatisticsPath: '/api/:version/application/statistics',
|
2020-10-12 17:08:56 -04:00
|
|
|
pipelineJobsPath: '/api/:version/projects/:id/pipelines/:pipeline_id/jobs',
|
2020-01-22 10:08:48 -05:00
|
|
|
pipelineSinglePath: '/api/:version/projects/:id/pipelines/:pipeline_id',
|
2020-04-21 11:21:10 -04:00
|
|
|
pipelinesPath: '/api/:version/projects/:id/pipelines/',
|
2020-07-20 17:09:23 -04:00
|
|
|
createPipelinePath: '/api/:version/projects/:id/pipeline',
|
2020-02-18 13:09:07 -05:00
|
|
|
environmentsPath: '/api/:version/projects/:id/environments',
|
2020-08-04 14:09:49 -04:00
|
|
|
contextCommitsPath:
|
|
|
|
'/api/:version/projects/:id/merge_requests/:merge_request_iid/context_commits',
|
2020-04-06 11:10:04 -04:00
|
|
|
rawFilePath: '/api/:version/projects/:id/repository/files/:path/raw',
|
2020-06-02 17:08:00 -04:00
|
|
|
issuePath: '/api/:version/projects/:id/issues/:issue_iid',
|
2020-06-11 05:08:16 -04:00
|
|
|
tagsPath: '/api/:version/projects/:id/repository/tags',
|
2020-07-17 14:09:20 -04:00
|
|
|
freezePeriodsPath: '/api/:version/projects/:id/freeze_periods',
|
2021-03-16 17:11:53 -04:00
|
|
|
freezePeriodPath: '/api/:version/projects/:id/freeze_periods/:freeze_period_id',
|
2021-06-29 08:08:48 -04:00
|
|
|
serviceDataIncrementCounterPath: '/api/:version/usage_data/increment_counter',
|
|
|
|
serviceDataIncrementUniqueUsersPath: '/api/:version/usage_data/increment_unique_users',
|
2020-10-01 17:08:36 -04:00
|
|
|
featureFlagUserLists: '/api/:version/projects/:id/feature_flags_user_lists',
|
|
|
|
featureFlagUserList: '/api/:version/projects/:id/feature_flags_user_lists/:list_iid',
|
2020-11-04 07:09:14 -05:00
|
|
|
containerRegistryDetailsPath: '/api/:version/registry/repositories/:id/',
|
2021-01-29 16:09:34 -05:00
|
|
|
projectNotificationSettingsPath: '/api/:version/projects/:id/notification_settings',
|
|
|
|
groupNotificationSettingsPath: '/api/:version/groups/:id/notification_settings',
|
|
|
|
notificationSettingsPath: '/api/:version/notification_settings',
|
2021-11-23 01:12:53 -05:00
|
|
|
deployKeysPath: '/api/:version/deploy_keys',
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2020-06-03 08:08:21 -04:00
|
|
|
group(groupId, callback = () => {}) {
|
2018-03-23 06:45:43 -04:00
|
|
|
const url = Api.buildUrl(Api.groupPath).replace(':id', groupId);
|
|
|
|
return axios.get(url).then(({ data }) => {
|
|
|
|
callback(data);
|
2018-01-29 05:12:32 -05:00
|
|
|
|
2018-03-23 06:45:43 -04:00
|
|
|
return data;
|
|
|
|
});
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2020-07-16 05:09:28 -04:00
|
|
|
groupPackages(id, options = {}) {
|
|
|
|
const url = Api.buildUrl(this.groupPackagesPath).replace(':id', id);
|
|
|
|
return axios.get(url, options);
|
|
|
|
},
|
|
|
|
|
|
|
|
projectPackages(id, options = {}) {
|
|
|
|
const url = Api.buildUrl(this.projectPackagesPath).replace(':id', id);
|
|
|
|
return axios.get(url, options);
|
|
|
|
},
|
|
|
|
|
|
|
|
buildProjectPackageUrl(projectId, packageId) {
|
|
|
|
return Api.buildUrl(this.projectPackagePath)
|
|
|
|
.replace(':id', projectId)
|
|
|
|
.replace(':package_id', packageId);
|
|
|
|
},
|
|
|
|
|
|
|
|
projectPackage(projectId, packageId) {
|
|
|
|
const url = this.buildProjectPackageUrl(projectId, packageId);
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteProjectPackage(projectId, packageId) {
|
|
|
|
const url = this.buildProjectPackageUrl(projectId, packageId);
|
|
|
|
return axios.delete(url);
|
|
|
|
},
|
|
|
|
|
2021-06-02 11:09:59 -04:00
|
|
|
deleteProjectPackageFile(projectId, packageId, fileId) {
|
|
|
|
const url = Api.buildUrl(this.projectPackageFilePath)
|
|
|
|
.replace(':id', projectId)
|
|
|
|
.replace(':package_id', packageId)
|
|
|
|
.replace(':package_file_id', fileId);
|
|
|
|
|
|
|
|
return axios.delete(url);
|
|
|
|
},
|
|
|
|
|
2020-11-04 07:09:14 -05:00
|
|
|
containerRegistryDetails(registryId, options = {}) {
|
|
|
|
const url = Api.buildUrl(this.containerRegistryDetailsPath).replace(':id', registryId);
|
|
|
|
return axios.get(url, options);
|
|
|
|
},
|
|
|
|
|
2020-01-17 01:08:39 -05:00
|
|
|
groupMembers(id, options) {
|
2019-01-16 16:57:50 -05:00
|
|
|
const url = Api.buildUrl(this.groupMembersPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
2020-01-17 01:08:39 -05:00
|
|
|
return axios.get(url, {
|
|
|
|
params: {
|
2020-08-13 02:10:02 -04:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
...options,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-01-08 10:10:26 -05:00
|
|
|
addGroupMembersByUserId(id, data) {
|
2020-09-28 11:09:44 -04:00
|
|
|
const url = Api.buildUrl(this.groupMembersPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, data);
|
|
|
|
},
|
|
|
|
|
2021-01-08 10:10:26 -05:00
|
|
|
inviteGroupMembersByEmail(id, data) {
|
|
|
|
const url = Api.buildUrl(this.groupInvitationsPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, data);
|
|
|
|
},
|
|
|
|
|
2020-08-13 02:10:02 -04:00
|
|
|
groupMilestones(id, options) {
|
|
|
|
const url = Api.buildUrl(this.groupMilestonesPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.get(url, {
|
|
|
|
params: {
|
2020-01-17 01:08:39 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
...options,
|
|
|
|
},
|
|
|
|
});
|
2019-01-16 16:57:50 -05:00
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getGroups` method in `~/rest_api` instead.
|
|
|
|
*/
|
2020-03-17 05:09:20 -04:00
|
|
|
groups(query, options, callback = () => {}) {
|
2017-05-19 17:22:46 -04:00
|
|
|
const url = Api.buildUrl(Api.groupsPath);
|
2018-03-23 06:45:43 -04:00
|
|
|
return axios
|
|
|
|
.get(url, {
|
2020-05-07 17:09:26 -04:00
|
|
|
params: {
|
|
|
|
search: query,
|
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
...options,
|
|
|
|
},
|
2018-03-23 06:45:43 -04:00
|
|
|
})
|
2018-01-29 06:42:27 -05:00
|
|
|
.then(({ data }) => {
|
|
|
|
callback(data);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
});
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2021-01-28 10:09:06 -05:00
|
|
|
groupLabels(namespace, options = {}) {
|
2019-09-23 17:06:29 -04:00
|
|
|
const url = Api.buildUrl(Api.groupLabelsPath).replace(':namespace_path', namespace);
|
2021-01-28 10:09:06 -05:00
|
|
|
return axios.get(url, options).then(({ data }) => data);
|
2019-09-23 17:06:29 -04:00
|
|
|
},
|
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
// Return namespaces list. Filtered by query
|
2017-05-19 17:22:46 -04:00
|
|
|
namespaces(query, callback) {
|
|
|
|
const url = Api.buildUrl(Api.namespacesPath);
|
2018-03-23 06:45:43 -04:00
|
|
|
return axios
|
|
|
|
.get(url, {
|
|
|
|
params: {
|
|
|
|
search: query,
|
2019-11-22 13:06:00 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
2018-03-23 06:45:43 -04:00
|
|
|
},
|
|
|
|
})
|
2018-01-25 11:40:31 -05:00
|
|
|
.then(({ data }) => callback(data));
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getProjects` method in `~/rest_api` instead.
|
|
|
|
*/
|
2020-03-17 05:09:20 -04:00
|
|
|
projects(query, options, callback = () => {}) {
|
2017-05-19 17:22:46 -04:00
|
|
|
const url = Api.buildUrl(Api.projectsPath);
|
2017-08-22 11:10:49 -04:00
|
|
|
const defaults = {
|
|
|
|
search: query,
|
2019-11-22 13:06:00 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
2017-09-04 11:41:55 -04:00
|
|
|
simple: true,
|
2017-08-22 11:10:49 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (gon.current_user_id) {
|
|
|
|
defaults.membership = true;
|
|
|
|
}
|
|
|
|
|
2018-03-23 06:45:43 -04:00
|
|
|
return axios
|
|
|
|
.get(url, {
|
|
|
|
params: Object.assign(defaults, options),
|
|
|
|
})
|
2019-11-12 13:06:57 -05:00
|
|
|
.then(({ data, headers }) => {
|
2018-01-29 06:42:27 -05:00
|
|
|
callback(data);
|
2019-11-12 13:06:57 -05:00
|
|
|
return { data, headers };
|
2018-01-29 06:42:27 -05:00
|
|
|
});
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2019-08-14 05:55:40 -04:00
|
|
|
projectUsers(projectPath, query = '', options = {}) {
|
|
|
|
const url = Api.buildUrl(this.projectUsersPath).replace(':id', encodeURIComponent(projectPath));
|
|
|
|
|
|
|
|
return axios
|
|
|
|
.get(url, {
|
|
|
|
params: {
|
|
|
|
search: query,
|
2019-11-22 13:06:00 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
2019-08-14 05:55:40 -04:00
|
|
|
...options,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => data);
|
|
|
|
},
|
|
|
|
|
2021-01-08 10:10:26 -05:00
|
|
|
addProjectMembersByUserId(id, data) {
|
2020-11-13 04:09:30 -05:00
|
|
|
const url = Api.buildUrl(this.projectMembersPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, data);
|
|
|
|
},
|
|
|
|
|
2021-01-08 10:10:26 -05:00
|
|
|
inviteProjectMembersByEmail(id, data) {
|
|
|
|
const url = Api.buildUrl(this.projectInvitationsPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, data);
|
|
|
|
},
|
|
|
|
|
2017-12-21 10:05:47 -05:00
|
|
|
// Return single project
|
|
|
|
project(projectPath) {
|
2018-03-25 14:16:20 -04:00
|
|
|
const url = Api.buildUrl(Api.projectPath).replace(':id', encodeURIComponent(projectPath));
|
2018-03-23 06:45:43 -04:00
|
|
|
|
|
|
|
return axios.get(url);
|
2019-06-19 06:21:48 -04:00
|
|
|
},
|
|
|
|
|
2019-12-19 07:07:35 -05:00
|
|
|
// Update a single project
|
|
|
|
updateProject(projectPath, data) {
|
|
|
|
const url = Api.buildUrl(Api.projectPath).replace(':id', encodeURIComponent(projectPath));
|
|
|
|
return axios.put(url, data);
|
|
|
|
},
|
|
|
|
|
2019-06-19 06:21:48 -04:00
|
|
|
/**
|
|
|
|
* Get all projects for a forked relationship to a specified project
|
|
|
|
* @param {string} projectPath - Path or ID of a project
|
|
|
|
* @param {Object} params - Get request parameters
|
|
|
|
* @returns {Promise} - Request promise
|
|
|
|
*/
|
|
|
|
projectForks(projectPath, params) {
|
|
|
|
const url = Api.buildUrl(Api.forkedProjectsPath).replace(
|
|
|
|
':id',
|
|
|
|
encodeURIComponent(projectPath),
|
|
|
|
);
|
|
|
|
|
|
|
|
return axios.get(url, { params });
|
2018-03-23 06:45:43 -04:00
|
|
|
},
|
|
|
|
|
2019-03-01 11:33:18 -05:00
|
|
|
/**
|
2021-04-08 11:09:06 -04:00
|
|
|
* Get all merge requests for a project, eventually filtering based on
|
2019-03-01 11:33:18 -05:00
|
|
|
* supplied parameters
|
|
|
|
* @param projectPath
|
|
|
|
* @param params
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
projectMergeRequests(projectPath, params = {}) {
|
|
|
|
const url = Api.buildUrl(Api.projectMergeRequestsPath).replace(
|
|
|
|
':id',
|
|
|
|
encodeURIComponent(projectPath),
|
|
|
|
);
|
|
|
|
|
|
|
|
return axios.get(url, { params });
|
|
|
|
},
|
|
|
|
|
2020-04-14 05:09:34 -04:00
|
|
|
createProjectMergeRequest(projectPath, options) {
|
|
|
|
const url = Api.buildUrl(Api.projectMergeRequestsPath).replace(
|
|
|
|
':id',
|
|
|
|
encodeURIComponent(projectPath),
|
|
|
|
);
|
|
|
|
|
|
|
|
return axios.post(url, options);
|
|
|
|
},
|
|
|
|
|
2021-04-08 11:09:06 -04:00
|
|
|
// Return merge request for project
|
2018-11-28 10:09:38 -05:00
|
|
|
projectMergeRequest(projectPath, mergeRequestId, params = {}) {
|
|
|
|
const url = Api.buildUrl(Api.projectMergeRequestPath)
|
2018-03-23 06:45:43 -04:00
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':mrid', mergeRequestId);
|
|
|
|
|
2018-07-03 04:09:20 -04:00
|
|
|
return axios.get(url, { params });
|
2018-03-23 06:45:43 -04:00
|
|
|
},
|
|
|
|
|
2018-11-28 10:09:38 -05:00
|
|
|
projectMergeRequestChanges(projectPath, mergeRequestId) {
|
|
|
|
const url = Api.buildUrl(Api.projectMergeRequestChangesPath)
|
2018-03-23 06:45:43 -04:00
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':mrid', mergeRequestId);
|
2017-12-21 10:05:47 -05:00
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2018-11-28 10:09:38 -05:00
|
|
|
projectMergeRequestVersions(projectPath, mergeRequestId) {
|
|
|
|
const url = Api.buildUrl(Api.projectMergeRequestVersionsPath)
|
2018-03-25 08:02:09 -04:00
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':mrid', mergeRequestId);
|
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2018-12-05 02:22:00 -05:00
|
|
|
projectRunners(projectPath, config = {}) {
|
|
|
|
const url = Api.buildUrl(Api.projectRunnersPath).replace(
|
|
|
|
':id',
|
|
|
|
encodeURIComponent(projectPath),
|
|
|
|
);
|
|
|
|
|
|
|
|
return axios.get(url, config);
|
|
|
|
},
|
|
|
|
|
2020-02-14 04:08:43 -05:00
|
|
|
projectProtectedBranches(id, query = '') {
|
|
|
|
const url = Api.buildUrl(Api.projectProtectedBranchesPath).replace(
|
|
|
|
':id',
|
|
|
|
encodeURIComponent(id),
|
|
|
|
);
|
|
|
|
|
|
|
|
return axios
|
|
|
|
.get(url, {
|
|
|
|
params: {
|
|
|
|
search: query,
|
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => data);
|
|
|
|
},
|
|
|
|
|
2020-05-07 17:09:26 -04:00
|
|
|
projectSearch(id, options = {}) {
|
|
|
|
const url = Api.buildUrl(Api.projectSearchPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.get(url, {
|
|
|
|
params: {
|
|
|
|
search: options.search,
|
|
|
|
scope: options.scope,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-02-19 16:11:07 -05:00
|
|
|
projectShareWithGroup(id, options = {}) {
|
|
|
|
const url = Api.buildUrl(Api.projectSharePath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, {
|
|
|
|
expires_at: options.expires_at,
|
|
|
|
group_access: options.group_access,
|
|
|
|
group_id: options.group_id,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-08-21 11:10:03 -04:00
|
|
|
projectMilestones(id, params = {}) {
|
2020-05-07 17:09:26 -04:00
|
|
|
const url = Api.buildUrl(Api.projectMilestonesPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
2020-08-21 11:10:03 -04:00
|
|
|
return axios.get(url, {
|
|
|
|
params,
|
|
|
|
});
|
2020-05-07 17:09:26 -04:00
|
|
|
},
|
|
|
|
|
2020-10-19 05:08:58 -04:00
|
|
|
addProjectIssueAsTodo(projectId, issueIid) {
|
|
|
|
const url = Api.buildUrl(Api.projectIssuePath)
|
|
|
|
.replace(':id', encodeURIComponent(projectId))
|
|
|
|
.replace(':issue_iid', encodeURIComponent(issueIid));
|
|
|
|
|
|
|
|
return axios.post(`${url}/todo`);
|
|
|
|
},
|
|
|
|
|
2018-11-28 10:09:38 -05:00
|
|
|
mergeRequests(params = {}) {
|
|
|
|
const url = Api.buildUrl(Api.mergeRequestsPath);
|
|
|
|
|
|
|
|
return axios.get(url, { params });
|
|
|
|
},
|
|
|
|
|
2017-05-19 17:22:46 -04:00
|
|
|
newLabel(namespacePath, projectPath, data, callback) {
|
2017-09-06 10:17:06 -04:00
|
|
|
let url;
|
2021-03-26 08:09:15 -04:00
|
|
|
let payload;
|
2017-09-06 10:17:06 -04:00
|
|
|
|
|
|
|
if (projectPath) {
|
|
|
|
url = Api.buildUrl(Api.projectLabelsPath)
|
|
|
|
.replace(':namespace_path', namespacePath)
|
|
|
|
.replace(':project_path', projectPath);
|
2021-03-26 08:09:15 -04:00
|
|
|
payload = {
|
|
|
|
label: data,
|
|
|
|
};
|
2017-09-06 10:17:06 -04:00
|
|
|
} else {
|
2018-03-25 14:16:20 -04:00
|
|
|
url = Api.buildUrl(Api.groupLabelsPath).replace(':namespace_path', namespacePath);
|
2021-03-26 08:09:15 -04:00
|
|
|
|
|
|
|
// groupLabelsPath uses public API which accepts
|
|
|
|
// `name` and `color` props.
|
|
|
|
payload = {
|
|
|
|
name: data.title,
|
|
|
|
color: data.color,
|
|
|
|
};
|
2017-09-06 10:17:06 -04:00
|
|
|
}
|
|
|
|
|
2018-03-23 06:45:43 -04:00
|
|
|
return axios
|
|
|
|
.post(url, {
|
2021-03-26 08:09:15 -04:00
|
|
|
...payload,
|
2018-03-23 06:45:43 -04:00
|
|
|
})
|
2020-12-23 16:10:24 -05:00
|
|
|
.then((res) => callback(res.data))
|
|
|
|
.catch((e) => callback(e.response.data));
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
// Return group projects list. Filtered by query
|
2018-07-02 04:04:43 -04:00
|
|
|
groupProjects(groupId, query, options, callback) {
|
2018-03-23 06:45:43 -04:00
|
|
|
const url = Api.buildUrl(Api.groupProjectsPath).replace(':id', groupId);
|
2018-07-02 04:04:43 -04:00
|
|
|
const defaults = {
|
|
|
|
search: query,
|
2019-11-22 13:06:00 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
2018-07-02 04:04:43 -04:00
|
|
|
};
|
2018-03-23 06:45:43 -04:00
|
|
|
return axios
|
|
|
|
.get(url, {
|
2020-05-07 17:09:26 -04:00
|
|
|
params: { ...defaults, ...options },
|
2018-03-23 06:45:43 -04:00
|
|
|
})
|
2020-12-23 04:10:13 -05:00
|
|
|
.then(({ data }) => (callback ? callback(data) : data))
|
2020-12-15 07:10:17 -05:00
|
|
|
.catch(() => {
|
2021-06-07 05:10:26 -04:00
|
|
|
createFlash({
|
|
|
|
message: __('Something went wrong while fetching projects'),
|
|
|
|
});
|
2020-12-23 04:10:13 -05:00
|
|
|
if (callback) {
|
|
|
|
callback();
|
|
|
|
}
|
2020-12-15 07:10:17 -05:00
|
|
|
});
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2021-02-19 16:11:07 -05:00
|
|
|
groupShareWithGroup(id, options = {}) {
|
|
|
|
const url = Api.buildUrl(Api.groupSharePath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, {
|
|
|
|
expires_at: options.expires_at,
|
|
|
|
group_access: options.group_access,
|
|
|
|
group_id: options.group_id,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-07-09 02:09:37 -04:00
|
|
|
commit(id, sha, params = {}) {
|
|
|
|
const url = Api.buildUrl(this.commitPath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':sha', encodeURIComponent(sha));
|
|
|
|
|
|
|
|
return axios.get(url, { params });
|
|
|
|
},
|
|
|
|
|
2017-08-17 14:05:09 -04:00
|
|
|
commitMultiple(id, data) {
|
2020-10-14 08:08:58 -04:00
|
|
|
// see https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
|
2020-07-09 02:09:37 -04:00
|
|
|
const url = Api.buildUrl(Api.commitsPath).replace(':id', encodeURIComponent(id));
|
2018-01-25 11:40:31 -05:00
|
|
|
return axios.post(url, JSON.stringify(data), {
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8',
|
|
|
|
},
|
2017-08-09 09:24:48 -04:00
|
|
|
});
|
2017-10-12 17:04:17 -04:00
|
|
|
},
|
|
|
|
|
2021-01-28 07:09:54 -05:00
|
|
|
applySuggestion(id, message = '') {
|
2018-12-13 14:17:19 -05:00
|
|
|
const url = Api.buildUrl(Api.applySuggestionPath).replace(':id', encodeURIComponent(id));
|
2021-03-02 07:10:52 -05:00
|
|
|
const params = { commit_message: message };
|
2018-12-13 14:17:19 -05:00
|
|
|
|
2021-01-28 07:09:54 -05:00
|
|
|
return axios.put(url, params);
|
2018-12-13 14:17:19 -05:00
|
|
|
},
|
|
|
|
|
2021-09-28 08:11:10 -04:00
|
|
|
applySuggestionBatch(ids, message) {
|
2020-06-08 20:08:47 -04:00
|
|
|
const url = Api.buildUrl(Api.applySuggestionBatchPath);
|
|
|
|
|
2021-09-28 08:11:10 -04:00
|
|
|
return axios.put(url, { ids, commit_message: message });
|
2020-06-08 20:08:47 -04:00
|
|
|
},
|
|
|
|
|
2018-05-25 06:08:53 -04:00
|
|
|
commitPipelines(projectId, sha) {
|
|
|
|
const encodedProjectId = projectId
|
|
|
|
.split('/')
|
2020-12-23 16:10:24 -05:00
|
|
|
.map((fragment) => encodeURIComponent(fragment))
|
2018-05-25 06:08:53 -04:00
|
|
|
.join('/');
|
|
|
|
|
|
|
|
const url = Api.buildUrl(Api.commitPipelinesPath)
|
|
|
|
.replace(':project_id', encodedProjectId)
|
|
|
|
.replace(':sha', encodeURIComponent(sha));
|
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2017-10-12 17:04:17 -04:00
|
|
|
branchSingle(id, branch) {
|
|
|
|
const url = Api.buildUrl(Api.branchSinglePath)
|
2017-12-21 10:05:47 -05:00
|
|
|
.replace(':id', encodeURIComponent(id))
|
2018-03-23 06:45:43 -04:00
|
|
|
.replace(':branch', encodeURIComponent(branch));
|
2017-10-12 17:04:17 -04:00
|
|
|
|
2018-01-25 11:40:31 -05:00
|
|
|
return axios.get(url);
|
2017-07-25 09:18:45 -04:00
|
|
|
},
|
|
|
|
|
2018-10-02 19:00:38 -04:00
|
|
|
projectTemplate(id, type, key, options, callback) {
|
|
|
|
const url = Api.buildUrl(this.projectTemplatePath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':type', type)
|
|
|
|
.replace(':key', encodeURIComponent(key));
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
return axios.get(url, { params: options }).then((res) => {
|
2018-10-02 19:00:38 -04:00
|
|
|
if (callback) callback(res.data);
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2018-10-02 19:00:38 -04:00
|
|
|
return res;
|
|
|
|
});
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2018-10-02 19:00:38 -04:00
|
|
|
projectTemplates(id, type, params = {}, callback) {
|
|
|
|
const url = Api.buildUrl(this.projectTemplatesPath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':type', type);
|
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
return axios.get(url, { params }).then((res) => {
|
2018-10-02 19:00:38 -04:00
|
|
|
if (callback) callback(res.data);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
});
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
|
|
|
issueTemplate(namespacePath, projectPath, key, type, callback) {
|
2020-11-10 04:08:45 -05:00
|
|
|
const url = this.buildIssueTemplateUrl(
|
|
|
|
Api.issuableTemplatePath,
|
|
|
|
type,
|
|
|
|
projectPath,
|
|
|
|
namespacePath,
|
|
|
|
).replace(':key', encodeURIComponent(key));
|
2018-03-23 06:45:43 -04:00
|
|
|
return axios
|
|
|
|
.get(url)
|
2018-01-25 11:40:31 -05:00
|
|
|
.then(({ data }) => callback(null, data))
|
|
|
|
.catch(callback);
|
2017-03-11 02:30:44 -05:00
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
|
2020-11-10 04:08:45 -05:00
|
|
|
issueTemplates(namespacePath, projectPath, type, callback) {
|
|
|
|
const url = this.buildIssueTemplateUrl(
|
|
|
|
Api.issuableTemplatesPath,
|
|
|
|
type,
|
|
|
|
projectPath,
|
|
|
|
namespacePath,
|
|
|
|
);
|
|
|
|
return axios
|
|
|
|
.get(url)
|
|
|
|
.then(({ data }) => callback(null, data))
|
|
|
|
.catch(callback);
|
|
|
|
},
|
|
|
|
|
|
|
|
buildIssueTemplateUrl(path, type, projectPath, namespacePath) {
|
|
|
|
return Api.buildUrl(path)
|
|
|
|
.replace(':type', type)
|
|
|
|
.replace(':project_path', projectPath)
|
|
|
|
.replace(':namespace_path', namespacePath);
|
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getUsers` method in `~/rest_api` instead.
|
|
|
|
*/
|
2017-05-19 17:22:46 -04:00
|
|
|
users(query, options) {
|
|
|
|
const url = Api.buildUrl(this.usersPath);
|
2018-01-25 11:40:31 -05:00
|
|
|
return axios.get(url, {
|
2020-05-07 17:09:26 -04:00
|
|
|
params: {
|
|
|
|
search: query,
|
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
...options,
|
|
|
|
},
|
2017-05-19 17:22:46 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getUser` method in `~/rest_api` instead.
|
|
|
|
*/
|
2018-12-07 22:12:23 -05:00
|
|
|
user(id, options) {
|
|
|
|
const url = Api.buildUrl(this.userPath).replace(':id', encodeURIComponent(id));
|
|
|
|
return axios.get(url, {
|
|
|
|
params: options,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getUserCounts` method in `~/rest_api` instead.
|
|
|
|
*/
|
2019-07-09 04:44:19 -04:00
|
|
|
userCounts() {
|
|
|
|
const url = Api.buildUrl(this.userCountsPath);
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getUserStatus` method in `~/rest_api` instead.
|
|
|
|
*/
|
2018-12-07 22:12:23 -05:00
|
|
|
userStatus(id, options) {
|
|
|
|
const url = Api.buildUrl(this.userStatusPath).replace(':id', encodeURIComponent(id));
|
|
|
|
return axios.get(url, {
|
|
|
|
params: options,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `getUserProjects` method in `~/rest_api` instead.
|
|
|
|
*/
|
2019-11-04 04:06:21 -05:00
|
|
|
userProjects(userId, query, options, callback) {
|
|
|
|
const url = Api.buildUrl(Api.userProjectsPath).replace(':id', userId);
|
|
|
|
const defaults = {
|
|
|
|
search: query,
|
2019-11-22 13:06:00 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
2019-11-04 04:06:21 -05:00
|
|
|
};
|
|
|
|
return axios
|
|
|
|
.get(url, {
|
2020-05-07 17:09:26 -04:00
|
|
|
params: { ...defaults, ...options },
|
2019-11-04 04:06:21 -05:00
|
|
|
})
|
|
|
|
.then(({ data }) => callback(data))
|
2021-06-07 05:10:26 -04:00
|
|
|
.catch(() =>
|
|
|
|
createFlash({
|
|
|
|
message: __('Something went wrong while fetching projects'),
|
|
|
|
}),
|
|
|
|
);
|
2019-11-04 04:06:21 -05:00
|
|
|
},
|
|
|
|
|
2018-08-07 11:15:56 -04:00
|
|
|
branches(id, query = '', options = {}) {
|
|
|
|
const url = Api.buildUrl(this.createBranchPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.get(url, {
|
|
|
|
params: {
|
|
|
|
search: query,
|
2019-11-22 13:06:00 -05:00
|
|
|
per_page: DEFAULT_PER_PAGE,
|
2018-08-07 11:15:56 -04:00
|
|
|
...options,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-06-14 13:03:17 -04:00
|
|
|
createBranch(id, { ref, branch }) {
|
|
|
|
const url = Api.buildUrl(this.createBranchPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, {
|
|
|
|
ref,
|
|
|
|
branch,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-01-14 10:10:46 -05:00
|
|
|
/**
|
|
|
|
* @deprecated This method will be removed soon. Use the
|
|
|
|
* `updateUserStatus` method in `~/rest_api` instead.
|
|
|
|
*/
|
2020-11-17 10:09:28 -05:00
|
|
|
postUserStatus({ emoji, message, availability }) {
|
2018-12-07 22:12:23 -05:00
|
|
|
const url = Api.buildUrl(this.userPostStatusPath);
|
2018-10-04 04:19:51 -04:00
|
|
|
|
|
|
|
return axios.put(url, {
|
|
|
|
emoji,
|
|
|
|
message,
|
2020-11-17 10:09:28 -05:00
|
|
|
availability,
|
2018-10-04 04:19:51 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-09-11 05:06:33 -04:00
|
|
|
postMergeRequestPipeline(id, { mergeRequestId }) {
|
|
|
|
const url = Api.buildUrl(this.mergeRequestsPipeline)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':merge_request_iid', mergeRequestId);
|
|
|
|
|
|
|
|
return axios.post(url);
|
|
|
|
},
|
|
|
|
|
2019-11-22 13:06:00 -05:00
|
|
|
releases(id, options = {}) {
|
2018-12-20 04:31:32 -05:00
|
|
|
const url = Api.buildUrl(this.releasesPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
2019-11-22 13:06:00 -05:00
|
|
|
return axios.get(url, {
|
|
|
|
params: {
|
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
...options,
|
|
|
|
},
|
|
|
|
});
|
2018-12-20 04:31:32 -05:00
|
|
|
},
|
|
|
|
|
2019-10-16 14:08:01 -04:00
|
|
|
release(projectPath, tagName) {
|
|
|
|
const url = Api.buildUrl(this.releasePath)
|
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':tag_name', encodeURIComponent(tagName));
|
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2020-07-22 05:09:38 -04:00
|
|
|
createRelease(projectPath, release) {
|
|
|
|
const url = Api.buildUrl(this.releasesPath).replace(':id', encodeURIComponent(projectPath));
|
|
|
|
|
|
|
|
return axios.post(url, release);
|
|
|
|
},
|
|
|
|
|
2019-10-16 14:08:01 -04:00
|
|
|
updateRelease(projectPath, tagName, release) {
|
|
|
|
const url = Api.buildUrl(this.releasePath)
|
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':tag_name', encodeURIComponent(tagName));
|
|
|
|
|
|
|
|
return axios.put(url, release);
|
|
|
|
},
|
|
|
|
|
2020-04-01 08:08:00 -04:00
|
|
|
createReleaseLink(projectPath, tagName, link) {
|
|
|
|
const url = Api.buildUrl(this.releaseLinksPath)
|
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':tag_name', encodeURIComponent(tagName));
|
|
|
|
|
|
|
|
return axios.post(url, link);
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteReleaseLink(projectPath, tagName, linkId) {
|
|
|
|
const url = Api.buildUrl(this.releaseLinkPath)
|
|
|
|
.replace(':id', encodeURIComponent(projectPath))
|
|
|
|
.replace(':tag_name', encodeURIComponent(tagName))
|
|
|
|
.replace(':link_id', encodeURIComponent(linkId));
|
|
|
|
|
|
|
|
return axios.delete(url);
|
|
|
|
},
|
|
|
|
|
2019-09-08 23:38:42 -04:00
|
|
|
adminStatistics() {
|
|
|
|
const url = Api.buildUrl(this.adminStatisticsPath);
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2020-01-22 10:08:48 -05:00
|
|
|
pipelineSingle(id, pipelineId) {
|
|
|
|
const url = Api.buildUrl(this.pipelineSinglePath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':pipeline_id', encodeURIComponent(pipelineId));
|
|
|
|
|
|
|
|
return axios.get(url);
|
2020-10-12 17:08:56 -04:00
|
|
|
},
|
|
|
|
|
2020-11-05 07:09:05 -05:00
|
|
|
pipelineJobs(projectId, pipelineId, params) {
|
2020-10-12 17:08:56 -04:00
|
|
|
const url = Api.buildUrl(this.pipelineJobsPath)
|
|
|
|
.replace(':id', encodeURIComponent(projectId))
|
|
|
|
.replace(':pipeline_id', encodeURIComponent(pipelineId));
|
|
|
|
|
2020-11-05 07:09:05 -05:00
|
|
|
return axios.get(url, { params });
|
2020-01-22 10:08:48 -05:00
|
|
|
},
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
// Return all pipelines for a project or filter by query params
|
|
|
|
pipelines(id, options = {}) {
|
|
|
|
const url = Api.buildUrl(this.pipelinesPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.get(url, {
|
|
|
|
params: options,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-07-20 17:09:23 -04:00
|
|
|
createPipeline(id, data) {
|
|
|
|
const url = Api.buildUrl(this.createPipelinePath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, data, {
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-02-18 13:09:07 -05:00
|
|
|
environments(id) {
|
|
|
|
const url = Api.buildUrl(this.environmentsPath).replace(':id', encodeURIComponent(id));
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
2020-08-04 14:09:49 -04:00
|
|
|
createContextCommits(id, mergeRequestIid, data) {
|
|
|
|
const url = Api.buildUrl(this.contextCommitsPath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':merge_request_iid', mergeRequestIid);
|
|
|
|
|
|
|
|
return axios.post(url, data);
|
|
|
|
},
|
|
|
|
|
|
|
|
allContextCommits(id, mergeRequestIid) {
|
|
|
|
const url = Api.buildUrl(this.contextCommitsPath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':merge_request_iid', mergeRequestIid);
|
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
|
|
|
removeContextCommits(id, mergeRequestIid, data) {
|
|
|
|
const url = Api.buildUrl(this.contextCommitsPath)
|
|
|
|
.replace(':id', id)
|
|
|
|
.replace(':merge_request_iid', mergeRequestIid);
|
|
|
|
|
|
|
|
return axios.delete(url, { data });
|
|
|
|
},
|
|
|
|
|
2021-04-14 20:09:12 -04:00
|
|
|
getRawFile(id, path, params = {}) {
|
2020-04-06 11:10:04 -04:00
|
|
|
const url = Api.buildUrl(this.rawFilePath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':path', encodeURIComponent(path));
|
|
|
|
|
|
|
|
return axios.get(url, { params });
|
|
|
|
},
|
|
|
|
|
2020-06-02 17:08:00 -04:00
|
|
|
updateIssue(project, issue, data = {}) {
|
|
|
|
const url = Api.buildUrl(Api.issuePath)
|
|
|
|
.replace(':id', encodeURIComponent(project))
|
|
|
|
.replace(':issue_iid', encodeURIComponent(issue));
|
|
|
|
|
|
|
|
return axios.put(url, data);
|
|
|
|
},
|
|
|
|
|
|
|
|
updateMergeRequest(project, mergeRequest, data = {}) {
|
|
|
|
const url = Api.buildUrl(Api.projectMergeRequestPath)
|
|
|
|
.replace(':id', encodeURIComponent(project))
|
|
|
|
.replace(':mrid', encodeURIComponent(mergeRequest));
|
|
|
|
|
|
|
|
return axios.put(url, data);
|
|
|
|
},
|
|
|
|
|
2020-06-11 05:08:16 -04:00
|
|
|
tags(id, query = '', options = {}) {
|
|
|
|
const url = Api.buildUrl(this.tagsPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.get(url, {
|
|
|
|
params: {
|
|
|
|
search: query,
|
|
|
|
per_page: DEFAULT_PER_PAGE,
|
|
|
|
...options,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-07-17 14:09:20 -04:00
|
|
|
freezePeriods(id) {
|
|
|
|
const url = Api.buildUrl(this.freezePeriodsPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
|
|
|
createFreezePeriod(id, freezePeriod = {}) {
|
|
|
|
const url = Api.buildUrl(this.freezePeriodsPath).replace(':id', encodeURIComponent(id));
|
|
|
|
|
|
|
|
return axios.post(url, freezePeriod);
|
|
|
|
},
|
|
|
|
|
2021-03-16 17:11:53 -04:00
|
|
|
updateFreezePeriod(id, freezePeriod = {}) {
|
|
|
|
const url = Api.buildUrl(this.freezePeriodPath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':freeze_period_id', encodeURIComponent(freezePeriod.id));
|
|
|
|
|
|
|
|
return axios.put(url, freezePeriod);
|
|
|
|
},
|
|
|
|
|
2021-08-31 05:08:57 -04:00
|
|
|
deleteFreezePeriod(id, freezePeriodId) {
|
|
|
|
const url = Api.buildUrl(this.freezePeriodPath)
|
|
|
|
.replace(':id', encodeURIComponent(id))
|
|
|
|
.replace(':freeze_period_id', encodeURIComponent(freezePeriodId));
|
|
|
|
|
|
|
|
return axios.delete(url);
|
|
|
|
},
|
|
|
|
|
2020-12-04 13:09:55 -05:00
|
|
|
trackRedisCounterEvent(event) {
|
|
|
|
if (!gon.features?.usageDataApi) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-06-29 08:08:48 -04:00
|
|
|
const url = Api.buildUrl(this.serviceDataIncrementCounterPath);
|
2020-12-04 13:09:55 -05:00
|
|
|
const headers = {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
};
|
|
|
|
|
|
|
|
return axios.post(url, { event }, { headers });
|
|
|
|
},
|
|
|
|
|
2020-09-24 08:09:37 -04:00
|
|
|
trackRedisHllUserEvent(event) {
|
2021-05-27 08:10:56 -04:00
|
|
|
if (!gon.current_user_id || !gon.features?.usageDataApi) {
|
2020-09-24 08:09:37 -04:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-06-29 08:08:48 -04:00
|
|
|
const url = Api.buildUrl(this.serviceDataIncrementUniqueUsersPath);
|
2020-09-24 08:09:37 -04:00
|
|
|
const headers = {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
};
|
|
|
|
|
|
|
|
return axios.post(url, { event }, { headers });
|
|
|
|
},
|
|
|
|
|
2017-05-19 17:22:46 -04:00
|
|
|
buildUrl(url) {
|
2019-04-24 13:30:46 -04:00
|
|
|
return joinPaths(gon.relative_url_root || '', url.replace(':version', gon.api_version));
|
2017-05-19 17:22:46 -04:00
|
|
|
},
|
2020-10-01 17:08:36 -04:00
|
|
|
|
|
|
|
fetchFeatureFlagUserLists(id, page) {
|
|
|
|
const url = Api.buildUrl(this.featureFlagUserLists).replace(':id', id);
|
|
|
|
|
|
|
|
return axios.get(url, { params: { page } });
|
|
|
|
},
|
|
|
|
|
2020-11-03 04:09:07 -05:00
|
|
|
searchFeatureFlagUserLists(id, search) {
|
|
|
|
const url = Api.buildUrl(this.featureFlagUserLists).replace(':id', id);
|
|
|
|
|
|
|
|
return axios.get(url, { params: { search } });
|
|
|
|
},
|
|
|
|
|
2020-10-01 17:08:36 -04:00
|
|
|
createFeatureFlagUserList(id, list) {
|
|
|
|
const url = Api.buildUrl(this.featureFlagUserLists).replace(':id', id);
|
|
|
|
|
|
|
|
return axios.post(url, list);
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchFeatureFlagUserList(id, listIid) {
|
|
|
|
const url = Api.buildUrl(this.featureFlagUserList)
|
|
|
|
.replace(':id', id)
|
|
|
|
.replace(':list_iid', listIid);
|
|
|
|
|
|
|
|
return axios.get(url);
|
|
|
|
},
|
|
|
|
|
|
|
|
updateFeatureFlagUserList(id, list) {
|
|
|
|
const url = Api.buildUrl(this.featureFlagUserList)
|
|
|
|
.replace(':id', id)
|
|
|
|
.replace(':list_iid', list.iid);
|
|
|
|
|
|
|
|
return axios.put(url, list);
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteFeatureFlagUserList(id, listIid) {
|
|
|
|
const url = Api.buildUrl(this.featureFlagUserList)
|
|
|
|
.replace(':id', id)
|
|
|
|
.replace(':list_iid', listIid);
|
|
|
|
|
|
|
|
return axios.delete(url);
|
|
|
|
},
|
2020-10-14 14:08:47 -04:00
|
|
|
|
2021-11-23 01:12:53 -05:00
|
|
|
deployKeys(params = {}) {
|
|
|
|
const url = Api.buildUrl(this.deployKeysPath);
|
|
|
|
|
|
|
|
return axios.get(url, { params: { per_page: DEFAULT_PER_PAGE, ...params } });
|
|
|
|
},
|
|
|
|
|
2021-01-29 16:09:34 -05:00
|
|
|
async updateNotificationSettings(projectId, groupId, data = {}) {
|
|
|
|
let url = Api.buildUrl(this.notificationSettingsPath);
|
|
|
|
|
|
|
|
if (projectId) {
|
|
|
|
url = Api.buildUrl(this.projectNotificationSettingsPath).replace(':id', projectId);
|
|
|
|
} else if (groupId) {
|
|
|
|
url = Api.buildUrl(this.groupNotificationSettingsPath).replace(':id', groupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
const result = await axios.put(url, data);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
|
|
|
async getNotificationSettings(projectId, groupId) {
|
|
|
|
let url = Api.buildUrl(this.notificationSettingsPath);
|
|
|
|
|
|
|
|
if (projectId) {
|
|
|
|
url = Api.buildUrl(this.projectNotificationSettingsPath).replace(':id', projectId);
|
|
|
|
} else if (groupId) {
|
|
|
|
url = Api.buildUrl(this.groupNotificationSettingsPath).replace(':id', groupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
const result = await axios.get(url);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
},
|
2017-03-11 02:30:44 -05:00
|
|
|
};
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-05-19 17:22:46 -04:00
|
|
|
export default Api;
|