UNPKG

7.14 kBSource Map (JSON)View Raw
1{"version":3,"names":[],"mappings":"","sources":["Team.js"],"sourcesContent":["/**\n * @file\n * @copyright 2016 Matt Smith (Development Seed)\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';\nimport debug from 'debug';\nconst log = debug('github:team');\n\n/**\n * A Team allows scoping of API requests to a particular Github Organization Team.\n */\nclass Team extends Requestable {\n /**\n * Create a Team.\n * @param {string} [teamId] - the id for the team\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(teamId, auth, apiBase) {\n super(auth, apiBase);\n this.__teamId = teamId;\n }\n\n /**\n * Get Team information\n * @see https://developer.github.com/v3/orgs/teams/#get-team\n * @param {Requestable.callback} [cb] - will receive the team\n * @return {Promise} - the promise for the http request\n */\n getTeam(cb) {\n log(`Fetching Team ${this.__teamId}`);\n return this._request('Get', `/teams/${this.__teamId}`, undefined, cb);\n }\n\n /**\n * List the Team's repositories\n * @see https://developer.github.com/v3/orgs/teams/#list-team-repos\n * @param {Requestable.callback} [cb] - will receive the list of repositories\n * @return {Promise} - the promise for the http request\n */\n listRepos(cb) {\n log(`Fetching repositories for Team ${this.__teamId}`);\n return this._requestAllPages(`/teams/${this.__teamId}/repos`, undefined, cb);\n }\n\n /**\n * Edit Team information\n * @see https://developer.github.com/v3/orgs/teams/#edit-team\n * @param {object} options - Parameters for team edit\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 updated team\n * @return {Promise} - the promise for the http request\n */\n editTeam(options, cb) {\n log(`Editing Team ${this.__teamId}`);\n return this._request('PATCH', `/teams/${this.__teamId}`, options, cb);\n }\n\n /**\n * List the users who are members of the Team\n * @see https://developer.github.com/v3/orgs/teams/#list-team-members\n * @param {object} options - Parameters for listing team users\n * @param {string} [options.role=all] - can be one of: `all`, `maintainer`, 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 log(`Getting members of Team ${this.__teamId}`);\n return this._requestAllPages(`/teams/${this.__teamId}/members`, options, cb);\n }\n\n /**\n * Get Team membership status for a user\n * @see https://developer.github.com/v3/orgs/teams/#get-team-membership\n * @param {string} username - can be one of: `all`, `maintainer`, or `member`\n * @param {Requestable.callback} [cb] - will receive the membership status of a user\n * @return {Promise} - the promise for the http request\n */\n getMembership(username, cb) {\n log(`Getting membership of user ${username} in Team ${this.__teamId}`);\n return this._request('GET', `/teams/${this.__teamId}/memberships/${username}`, undefined, cb);\n }\n\n /**\n * Add a member to the Team\n * @see https://developer.github.com/v3/orgs/teams/#add-team-membership\n * @param {string} username - can be one of: `all`, `maintainer`, or `member`\n * @param {object} options - Parameters for adding a team member\n * @param {string} [options.role=member] - The role that this user should have in the team. Can be one\n * of: `member`, or `maintainer`\n * @param {Requestable.callback} [cb] - will receive the membership status of added user\n * @return {Promise} - the promise for the http request\n */\n addMembership(username, options, cb) {\n log(`Adding user ${username} to Team ${this.__teamId}`);\n return this._request('PUT', `/teams/${this.__teamId}/memberships/${username}`, options, cb);\n }\n\n /**\n * Get repo management status for team\n * @see https://developer.github.com/v3/orgs/teams/#remove-team-membership\n * @param {string} owner - Organization name\n * @param {string} repo - Repo name\n * @param {Requestable.callback} [cb] - will receive the membership status of added user\n * @return {Promise} - the promise for the http request\n */\n isManagedRepo(owner, repo, cb) {\n log(`Getting repo management by Team ${this.__teamId} for repo ${owner}/${repo}`);\n return this._request204or404(`/teams/${this.__teamId}/repos/${owner}/${repo}`, undefined, cb);\n }\n\n /**\n * Add or Update repo management status for team\n * @see https://developer.github.com/v3/orgs/teams/#add-or-update-team-repository\n * @param {string} owner - Organization name\n * @param {string} repo - Repo name\n * @param {object} options - Parameters for adding or updating repo management for the team\n * @param {string} [options.permission] - The permission to grant the team on this repository. Can be one\n * of: `pull`, `push`, or `admin`\n * @param {Requestable.callback} [cb] - will receive the membership status of added user\n * @return {Promise} - the promise for the http request\n */\n manageRepo(owner, repo, options, cb) {\n log(`Adding or Updating repo management by Team ${this.__teamId} for repo ${owner}/${repo}`);\n return this._request204or404(`/teams/${this.__teamId}/repos/${owner}/${repo}`, options, cb, 'PUT');\n }\n\n /**\n * Remove repo management status for team\n * @see https://developer.github.com/v3/orgs/teams/#remove-team-repository\n * @param {string} owner - Organization name\n * @param {string} repo - Repo name\n * @param {Requestable.callback} [cb] - will receive the membership status of added user\n * @return {Promise} - the promise for the http request\n */\n unmanageRepo(owner, repo, cb) {\n log(`Remove repo management by Team ${this.__teamId} for repo ${owner}/${repo}`);\n return this._request204or404(`/teams/${this.__teamId}/repos/${owner}/${repo}`, undefined, cb, 'DELETE');\n }\n\n /**\n * Delete Team\n * @see https://developer.github.com/v3/orgs/teams/#delete-team\n * @param {Requestable.callback} [cb] - will receive the list of repositories\n * @return {Promise} - the promise for the http request\n */\n deleteTeam(cb) {\n log(`Deleting Team ${this.__teamId}`);\n return this._request204or404(`/teams/${this.__teamId}`, undefined, cb, 'DELETE');\n }\n}\n\nmodule.exports = Team;\n"],"file":"Team.js"}
\No newline at end of file