UNPKG

5 kBSource Map (JSON)View Raw
1{"version":3,"names":[],"mappings":"","sources":["Organization.js"],"sourcesContent":["/**\n * @file\n * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.\n * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.\n * Github.js is freely distributable.\n */\n\nimport Requestable from './Requestable';\n\n/**\n * Organization encapsulates the functionality to create repositories in organizations\n */\nclass Organization extends Requestable {\n /**\n * Create a new Organization\n * @param {string} organization - the name of the organization\n * @param {Requestable.auth} [auth] - information required to authenticate to Github\n * @param {string} [apiBase=https://api.github.com] - the base Github API URL\n */\n constructor(organization, auth, apiBase) {\n super(auth, apiBase);\n this.__name = organization;\n }\n\n /**\n * Create a repository in an organization\n * @see https://developer.github.com/v3/repos/#create\n * @param {Object} options - the repository definition\n * @param {Requestable.callback} [cb] - will receive the created repository\n * @return {Promise} - the promise for the http request\n */\n createRepo(options, cb) {\n return this._request('POST', `/orgs/${this.__name}/repos`, options, cb);\n }\n\n /**\n * List the repositories in an organization\n * @see https://developer.github.com/v3/repos/#list-organization-repositories\n * @param {Requestable.callback} [cb] - will receive the list of repositories\n * @return {Promise} - the promise for the http request\n */\n getRepos(cb) {\n let requestOptions = this._getOptionsWithDefaults({direction: 'desc'});\n\n return this._requestAllPages(`/orgs/${this.__name}/repos`, requestOptions, cb);\n }\n\n /**\n * Query if the user is a member or not\n * @param {string} username - the user in question\n * @param {Requestable.callback} [cb] - will receive true if the user is a member\n * @return {Promise} - the promise for the http request\n */\n isMember(username, cb) {\n return this._request204or404(`/orgs/${this.__name}/members/${username}`, null, cb);\n }\n\n /**\n * List the users who are members of the company\n * @see https://developer.github.com/v3/orgs/members/#members-list\n * @param {object} options - filtering options\n * @param {string} [options.filter=all] - can be either `2fa_disabled` or `all`\n * @param {string} [options.role=all] - can be one of: `all`, `admin`, or `member`\n * @param {Requestable.callback} [cb] - will receive the list of users\n * @return {Promise} - the promise for the http request\n */\n listMembers(options, cb) {\n return this._request('GET', `/orgs/${this.__name}/members`, options, cb);\n }\n\n /**\n * List the Teams in the Organization\n * @see https://developer.github.com/v3/orgs/teams/#list-teams\n * @param {Requestable.callback} [cb] - will receive the list of teams\n * @return {Promise} - the promise for the http request\n */\n getTeams(cb) {\n return this._requestAllPages(`/orgs/${this.__name}/teams`, undefined, cb);\n }\n\n /**\n * Create a team\n * @see https://developer.github.com/v3/orgs/teams/#create-team\n * @param {object} options - Team creation parameters\n * @param {string} options.name - The name of the team\n * @param {string} [options.description] - Team description\n * @param {string} [options.repo_names] - Repos to add the team to\n * @param {string} [options.privacy=secret] - The level of privacy the team should have. Can be either one\n * of: `secret`, or `closed`\n * @param {Requestable.callback} [cb] - will receive the created team\n * @return {Promise} - the promise for the http request\n */\n createTeam(options, cb) {\n return this._request('POST', `/orgs/${this.__name}/teams`, options, cb);\n }\n\n /**\n * Get information about all projects\n * @see https://developer.github.com/v3/projects/#list-organization-projects\n * @param {Requestable.callback} [cb] - will receive the list of projects\n * @return {Promise} - the promise for the http request\n */\n listProjects(cb) {\n return this._requestAllPages(`/orgs/${this.__name}/projects`, {AcceptHeader: 'inertia-preview'}, cb);\n }\n\n /**\n * Create a new project\n * @see https://developer.github.com/v3/repos/projects/#create-a-project\n * @param {Object} options - the description of the project\n * @param {Requestable.callback} cb - will receive the newly created project\n * @return {Promise} - the promise for the http request\n */\n createProject(options, cb) {\n options = options || {};\n options.AcceptHeader = 'inertia-preview';\n return this._request('POST', `/orgs/${this.__name}/projects`, options, cb);\n }\n}\n\nmodule.exports = Organization;\n"],"file":"Organization.js"}
\No newline at end of file