UNPKG

2.41 kBMarkdownView Raw
1# plugin-enterprise-rest.js
2
3> Octokit plugin for GitHub Enterprise REST APIs
4
5[![@latest](https://img.shields.io/npm/v/@octokit/plugin-enterprise-rest.svg)](https://www.npmjs.com/package/@octokit/plugin-enterprise-rest)
6![Build Status](https://github.com/octokit/plugin-enterprise-rest.js/workflows/Test/badge.svg)
7[![Greenkeeper badge](https://badges.greenkeeper.io/octokit/plugin-enterprise-rest.js.svg)](https://greenkeeper.io/)
8
9`@octokit/rest` does not include methods for Enterprise Administration as they are not usable against https://api.github.com. This plugin adds these endpoints based on the GitHub Enterprise version you need.
10
11## Usage
12
13```js
14const Octokit = require("@octokit/rest").plugin(
15 require("@octokit/plugin-enterprise-rest/ghe-2.18")
16);
17const octokit = new Octokit({
18 baseUrl: "https://github.acme-inc.com/api/v3"
19});
20
21octokit.enterpriseAdmin.promoteOrdinaryUserToSiteAdministrator({
22 username: "octocat"
23});
24```
25
26There can be differences in REST API between `api.github.com` and the different GitHub Enterprise versions. Some of the endpoint methods from `@octokit/rest` might not work. For these cases you can load the endpoint methods for all scopes for a certain GitHub Enterprise version, not only the `.enterprise` scope. This will override existing endpoint methods.
27
28```js
29const Octokit = require("@octokit/rest").plugin(
30 require("@octokit/plugin-enterprise-rest/ghe-2.18/all")
31);
32const octokit = new Octokit({
33 baseUrl: "https://github.acme-inc.com/api/v3"
34});
35
36octokit.issues.addLabels({
37 owner,
38 repo,
39 number,
40 labels: ["foo", "bar"]
41});
42// now sends `["foo", "bar"]` in the request body, instead of `{"labels": ["foo", "bar"]}`
43```
44
45## API docs
46
47See the `README.md` files in the `ghe-*` folders for a list of available endpoint methods for the respective GitHub Enterprise version.
48
49## How it works
50
51The route definitions for the currently supported GitHub Enterprise versions are build automatically from [`@octokit/routes`](https://github.com/octokit/routes). Each time there is a new `@octokit/routes` release, [Greenkeeper](https://greenkeeper.io/) will send a pull request which updates the dependency in `package.json` and `package-lock.json`. That kicks of a build on Travis CI where the `greenkeeper-routes-update` script is run. If there is a change, the script updates the `*.json` definition files in the pull request.
52
53## LICENSE
54
55[MIT](LICENSE)