2013-03-20 15:55:25 -04:00
|
|
|
@Api =
|
2016-05-13 11:57:03 -04:00
|
|
|
groupsPath: "/api/:version/groups.json"
|
|
|
|
groupPath: "/api/:version/groups/:id.json"
|
|
|
|
namespacesPath: "/api/:version/namespaces.json"
|
|
|
|
groupProjectsPath: "/api/:version/groups/:id/projects.json"
|
|
|
|
projectsPath: "/api/:version/projects.json"
|
|
|
|
labelsPath: "/api/:version/projects/:id/labels"
|
|
|
|
licensePath: "/api/:version/licenses/:key"
|
|
|
|
gitignorePath: "/api/:version/gitignores/:key"
|
2016-06-16 09:33:11 -04:00
|
|
|
gitlabCiYmlPath: "/api/:version/gitlab_ci_ymls/:key"
|
2013-03-20 15:55:25 -04:00
|
|
|
|
2014-12-30 04:32:24 -05:00
|
|
|
group: (group_id, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.groupPath)
|
2014-12-30 04:32:24 -05:00
|
|
|
url = url.replace(':id', group_id)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
dataType: "json"
|
|
|
|
).done (group) ->
|
|
|
|
callback(group)
|
|
|
|
|
|
|
|
# Return groups list. Filtered by query
|
|
|
|
# Only active groups retrieved
|
|
|
|
groups: (query, skip_ldap, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.groupsPath)
|
2014-12-30 04:32:24 -05:00
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (groups) ->
|
|
|
|
callback(groups)
|
|
|
|
|
2013-11-15 08:25:09 -05:00
|
|
|
# Return namespaces list. Filtered by query
|
|
|
|
namespaces: (query, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.namespacesPath)
|
2013-11-15 08:25:09 -05:00
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (namespaces) ->
|
|
|
|
callback(namespaces)
|
|
|
|
|
2015-12-07 11:12:04 -05:00
|
|
|
# Return projects list. Filtered by query
|
2016-02-03 17:27:00 -05:00
|
|
|
projects: (query, order, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.projectsPath)
|
2015-12-07 11:12:04 -05:00
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
2016-02-03 17:27:00 -05:00
|
|
|
order_by: order
|
2015-12-07 11:12:04 -05:00
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (projects) ->
|
|
|
|
callback(projects)
|
|
|
|
|
2016-03-08 06:23:54 -05:00
|
|
|
newLabel: (project_id, data, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.labelsPath)
|
2016-03-08 06:23:54 -05:00
|
|
|
url = url.replace(':id', project_id)
|
|
|
|
|
|
|
|
data.private_token = gon.api_token
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
type: "POST"
|
|
|
|
data: data
|
|
|
|
dataType: "json"
|
|
|
|
).done (label) ->
|
|
|
|
callback(label)
|
2016-03-22 10:56:00 -04:00
|
|
|
.error (message) ->
|
|
|
|
callback(message.responseJSON)
|
2016-03-08 06:23:54 -05:00
|
|
|
|
2015-12-07 11:12:04 -05:00
|
|
|
# Return group projects list. Filtered by query
|
|
|
|
groupProjects: (group_id, query, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.groupProjectsPath)
|
2015-12-07 11:12:04 -05:00
|
|
|
url = url.replace(':id', group_id)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (projects) ->
|
|
|
|
callback(projects)
|
|
|
|
|
2016-04-11 09:49:25 -04:00
|
|
|
# Return text for a specific license
|
|
|
|
licenseText: (key, data, callback) ->
|
2016-05-13 11:57:03 -04:00
|
|
|
url = Api.buildUrl(Api.licensePath).replace(':key', key)
|
2016-03-01 07:36:50 -05:00
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
2016-04-11 09:49:25 -04:00
|
|
|
data: data
|
|
|
|
).done (license) ->
|
|
|
|
callback(license)
|
2016-03-01 07:36:50 -05:00
|
|
|
|
2016-05-13 11:57:03 -04:00
|
|
|
gitignoreText: (key, callback) ->
|
|
|
|
url = Api.buildUrl(Api.gitignorePath).replace(':key', key)
|
2016-05-06 11:13:16 -04:00
|
|
|
|
|
|
|
$.get url, (gitignore) ->
|
|
|
|
callback(gitignore)
|
|
|
|
|
2016-06-16 09:33:11 -04:00
|
|
|
gitlabCiYml: (key, callback) ->
|
|
|
|
url = Api.buildUrl(Api.gitlabCiYmlPath).replace(':key', key)
|
2016-06-16 03:06:30 -04:00
|
|
|
|
|
|
|
$.get url, (file) ->
|
|
|
|
callback(file)
|
|
|
|
|
2013-03-20 15:55:25 -04:00
|
|
|
buildUrl: (url) ->
|
2013-06-12 23:44:25 -04:00
|
|
|
url = gon.relative_url_root + url if gon.relative_url_root?
|
2013-03-20 15:55:25 -04:00
|
|
|
return url.replace(':version', gon.api_version)
|