2013-03-20 15:55:25 -04:00
|
|
|
@Api =
|
2014-12-30 04:32:24 -05:00
|
|
|
groups_path: "/api/:version/groups.json"
|
|
|
|
group_path: "/api/:version/groups/:id.json"
|
2013-11-15 08:25:09 -05:00
|
|
|
namespaces_path: "/api/:version/namespaces.json"
|
2013-03-20 15:55:25 -04:00
|
|
|
|
2014-12-30 04:32:24 -05:00
|
|
|
group: (group_id, callback) ->
|
|
|
|
url = Api.buildUrl(Api.group_path)
|
|
|
|
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) ->
|
|
|
|
url = Api.buildUrl(Api.groups_path)
|
|
|
|
|
|
|
|
$.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) ->
|
|
|
|
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)
|
|
|
|
|
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)
|