2014-09-02 18:07:02 +05:30
|
|
|
@Api =
|
2015-04-26 12:48:37 +05:30
|
|
|
groups_path: "/api/:version/groups.json"
|
|
|
|
group_path: "/api/:version/groups/:id.json"
|
2014-09-02 18:07:02 +05:30
|
|
|
namespaces_path: "/api/:version/namespaces.json"
|
2015-12-23 02:04:40 +05:30
|
|
|
group_projects_path: "/api/:version/groups/:id/projects.json"
|
|
|
|
projects_path: "/api/:version/projects.json"
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
group: (group_id, callback) ->
|
|
|
|
url = Api.buildUrl(Api.group_path)
|
|
|
|
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) ->
|
|
|
|
url = Api.buildUrl(Api.groups_path)
|
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) ->
|
|
|
|
url = Api.buildUrl(Api.namespaces_path)
|
|
|
|
|
|
|
|
$.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
|
|
|
|
projects: (query, callback) ->
|
|
|
|
url = Api.buildUrl(Api.projects_path)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (projects) ->
|
|
|
|
callback(projects)
|
|
|
|
|
|
|
|
# Return group projects list. Filtered by query
|
|
|
|
groupProjects: (group_id, query, callback) ->
|
|
|
|
url = Api.buildUrl(Api.group_projects_path)
|
|
|
|
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)
|
|
|
|
|
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)
|