summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/api.js')
-rw-r--r--app/assets/javascripts/api.js99
1 files changed, 98 insertions, 1 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js
index dbc7ff67d9d..63b75cdb734 100644
--- a/app/assets/javascripts/api.js
+++ b/app/assets/javascripts/api.js
@@ -30,6 +30,7 @@ const Api = {
projectProtectedBranchesPath: '/api/:version/projects/:id/protected_branches',
projectSearchPath: '/api/:version/projects/:id/search',
projectMilestonesPath: '/api/:version/projects/:id/milestones',
+ projectIssuePath: '/api/:version/projects/:id/issues/:issue_iid',
mergeRequestsPath: '/api/:version/merge_requests',
groupLabelsPath: '/groups/:namespace_path/-/labels',
issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key',
@@ -54,6 +55,7 @@ const Api = {
releaseLinkPath: '/api/:version/projects/:id/releases/:tag_name/assets/links/:link_id',
mergeRequestsPipeline: '/api/:version/projects/:id/merge_requests/:merge_request_iid/pipelines',
adminStatisticsPath: '/api/:version/application/statistics',
+ pipelineJobsPath: '/api/:version/projects/:id/pipelines/:pipeline_id/jobs',
pipelineSinglePath: '/api/:version/projects/:id/pipelines/:pipeline_id',
pipelinesPath: '/api/:version/projects/:id/pipelines/',
createPipelinePath: '/api/:version/projects/:id/pipeline',
@@ -64,6 +66,10 @@ const Api = {
issuePath: '/api/:version/projects/:id/issues/:issue_iid',
tagsPath: '/api/:version/projects/:id/repository/tags',
freezePeriodsPath: '/api/:version/projects/:id/freeze_periods',
+ usageDataIncrementUniqueUsersPath: '/api/:version/usage_data/increment_unique_users',
+ featureFlagUserLists: '/api/:version/projects/:id/feature_flags_user_lists',
+ featureFlagUserList: '/api/:version/projects/:id/feature_flags_user_lists/:list_iid',
+ billableGroupMembersPath: '/api/:version/groups/:id/billable_members',
group(groupId, callback = () => {}) {
const url = Api.buildUrl(Api.groupPath).replace(':id', groupId);
@@ -111,6 +117,12 @@ const Api = {
});
},
+ inviteGroupMember(id, data) {
+ const url = Api.buildUrl(this.groupMembersPath).replace(':id', encodeURIComponent(id));
+
+ return axios.post(url, data);
+ },
+
groupMilestones(id, options) {
const url = Api.buildUrl(this.groupMilestonesPath).replace(':id', encodeURIComponent(id));
@@ -317,6 +329,14 @@ const Api = {
});
},
+ addProjectIssueAsTodo(projectId, issueIid) {
+ const url = Api.buildUrl(Api.projectIssuePath)
+ .replace(':id', encodeURIComponent(projectId))
+ .replace(':issue_iid', encodeURIComponent(issueIid));
+
+ return axios.post(`${url}/todo`);
+ },
+
mergeRequests(params = {}) {
const url = Api.buildUrl(Api.mergeRequestsPath);
@@ -366,7 +386,7 @@ const Api = {
},
commitMultiple(id, data) {
- // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
+ // see https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
const url = Api.buildUrl(Api.commitsPath).replace(':id', encodeURIComponent(id));
return axios.post(url, JSON.stringify(data), {
headers: {
@@ -590,6 +610,14 @@ const Api = {
return axios.get(url);
},
+ pipelineJobs(projectId, pipelineId) {
+ const url = Api.buildUrl(this.pipelineJobsPath)
+ .replace(':id', encodeURIComponent(projectId))
+ .replace(':pipeline_id', encodeURIComponent(pipelineId));
+
+ return axios.get(url);
+ },
+
// Return all pipelines for a project or filter by query params
pipelines(id, options = {}) {
const url = Api.buildUrl(this.pipelinesPath).replace(':id', encodeURIComponent(id));
@@ -686,9 +714,78 @@ const Api = {
return axios.post(url, freezePeriod);
},
+ trackRedisHllUserEvent(event) {
+ if (!gon.features?.usageDataApi) {
+ return null;
+ }
+
+ const url = Api.buildUrl(this.usageDataIncrementUniqueUsersPath);
+ const headers = {
+ 'Content-Type': 'application/json',
+ };
+
+ return axios.post(url, { event }, { headers });
+ },
+
buildUrl(url) {
return joinPaths(gon.relative_url_root || '', url.replace(':version', gon.api_version));
},
+
+ fetchFeatureFlagUserLists(id, page) {
+ const url = Api.buildUrl(this.featureFlagUserLists).replace(':id', id);
+
+ return axios.get(url, { params: { page } });
+ },
+
+ 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);
+ },
+
+ fetchBillableGroupMembersList(namespaceId, options = {}, callback = () => {}) {
+ const url = Api.buildUrl(this.billableGroupMembersPath).replace(':id', namespaceId);
+ const defaults = {
+ per_page: DEFAULT_PER_PAGE,
+ page: 1,
+ };
+
+ return axios
+ .get(url, {
+ params: {
+ ...defaults,
+ ...options,
+ },
+ })
+ .then(({ data, headers }) => {
+ callback(data);
+ return { data, headers };
+ });
+ },
};
export default Api;