2014-09-02 18:07:02 +05:30
|
|
|
@Api =
|
2016-06-02 11:05:42 +05:30
|
|
|
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-22 15:30:34 +05:30
|
|
|
gitlabCiYmlPath: "/api/:version/gitlab_ci_ymls/:key"
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
group: (group_id, callback) ->
|
2016-06-02 11:05:42 +05:30
|
|
|
url = Api.buildUrl(Api.groupPath)
|
2015-04-26 12:48:37 +05:30
|
|
|
url = url.replace(':id', group_id)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
dataType: "json"
|
2015-04-26 12:48:37 +05:30
|
|
|
).done (group) ->
|
|
|
|
callback(group)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
# Return groups list. Filtered by query
|
|
|
|
# Only active groups retrieved
|
|
|
|
groups: (query, skip_ldap, callback) ->
|
2016-06-02 11:05:42 +05:30
|
|
|
url = Api.buildUrl(Api.groupsPath)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
2015-04-26 12:48:37 +05:30
|
|
|
).done (groups) ->
|
|
|
|
callback(groups)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
# Return namespaces list. Filtered by query
|
|
|
|
namespaces: (query, callback) ->
|
2016-06-02 11:05:42 +05:30
|
|
|
url = Api.buildUrl(Api.namespacesPath)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (namespaces) ->
|
|
|
|
callback(namespaces)
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
# Return projects list. Filtered by query
|
2016-04-02 18:10:28 +05:30
|
|
|
projects: (query, order, callback) ->
|
2016-06-02 11:05:42 +05:30
|
|
|
url = Api.buildUrl(Api.projectsPath)
|
2015-12-23 02:04:40 +05:30
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
2016-04-02 18:10:28 +05:30
|
|
|
order_by: order
|
2015-12-23 02:04:40 +05:30
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (projects) ->
|
|
|
|
callback(projects)
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
newLabel: (project_id, data, callback) ->
|
|
|
|
url = Api.buildUrl(Api.labelsPath)
|
|
|
|
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)
|
|
|
|
.error (message) ->
|
|
|
|
callback(message.responseJSON)
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
# Return group projects list. Filtered by query
|
|
|
|
groupProjects: (group_id, query, callback) ->
|
2016-06-02 11:05:42 +05:30
|
|
|
url = Api.buildUrl(Api.groupProjectsPath)
|
2015-12-23 02:04:40 +05:30
|
|
|
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-06-02 11:05:42 +05:30
|
|
|
# Return text for a specific license
|
|
|
|
licenseText: (key, data, callback) ->
|
|
|
|
url = Api.buildUrl(Api.licensePath).replace(':key', key)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data: data
|
|
|
|
).done (license) ->
|
|
|
|
callback(license)
|
|
|
|
|
|
|
|
gitignoreText: (key, callback) ->
|
|
|
|
url = Api.buildUrl(Api.gitignorePath).replace(':key', key)
|
|
|
|
|
|
|
|
$.get url, (gitignore) ->
|
|
|
|
callback(gitignore)
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
gitlabCiYml: (key, callback) ->
|
|
|
|
url = Api.buildUrl(Api.gitlabCiYmlPath).replace(':key', key)
|
|
|
|
|
|
|
|
$.get url, (file) ->
|
|
|
|
callback(file)
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
buildUrl: (url) ->
|
|
|
|
url = gon.relative_url_root + url if gon.relative_url_root?
|
|
|
|
return url.replace(':version', gon.api_version)
|