forked from github-tools/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganization.js
More file actions
49 lines (43 loc) · 1.71 KB
/
Organization.js
File metadata and controls
49 lines (43 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @file
* @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
* @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
* Github.js is freely distributable.
*/
import Requestable from './Requestable';
/**
* Organization encapsulates the functionality to create repositories in organizations
*/
class Organization extends Requestable {
/**
* Create a new Organization
* @param {string} organization - the name of the organization
* @param {Requestable.auth} [auth] - information required to authenticate to Github
* @param {string} [apiBase=https://api.github.com] - the base Github API URL
*/
constructor(organization, auth, apiBase) {
super(auth, apiBase);
this.__name = organization;
}
/**
* Create a repository in an organization
* @see https://developer.github.com/v3/repos/#create
* @param {Object} options - the repository definition
* @param {Requestable.callback} [cb] - will receive the created repository
* @return {Promise} - the promise for the http request
*/
createRepo(options, cb) {
this._request('POST', `/orgs/${this.__name}/repos`, options, cb);
}
/**
* List the repositories in an organization
* @see https://developer.github.com/v3/repos/#list-organization-repositories
* @param {Requestable.callback} [cb] - will receive the list of repositories
* @return {Promise} - the promise for the http request
*/
getRepos(cb) {
let requestOptions = this._getOptionsWithDefaults({direction: 'desc'});
return this._requestAllPages(`/orgs/${this.__name}/repos`, requestOptions, cb);
}
}
module.exports = Organization;