Skip to content

Commit

Permalink
Adding more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Jul 6, 2017
1 parent b39ef76 commit 7a90dbb
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Changelog
[1.0.9]() (2017-07-06)
------------------
- Fixing broken Notes API reference
- Finished the Projects documentation
- Added Project triggers, members and hooks docs

[1.0.8](https://github.com/jdalrymple/node-gitlab-api/commit/491a707624ba9f58818014eacfeb7182b8ecf800) (2017-06-30)
------------------
Expand Down
63 changes: 60 additions & 3 deletions docs/project-hooks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
## Project Members
## Project Hooks

* [List all hooks](#list-all-hooks)
* [Get a hook](#get-a-hook)
* [Create a hook](#create-a-hook)
* [Edit a hook](#edit-a-hook)
* [Add a hook](#add-a-hook-to-a-project)
* [Edit a hook](#edit-a-hook)
* [Remove a hook](#remove-a-hook)

### List all hooks

Get a list of project hooks.

```javascript
// From a project ID
let hooks = GitlabAPI.projects.hooks.list(projectId);
```
Parameters: [List all project hooks](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#list-project-hooks)

### Get a hook

Get a specific hook for a project.

```javascript
// From a project ID
let hook = GitlabAPI.projects.hooks.show(projectId, hookId);
```
Parameters: [Get project hook](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#get-project-hook)

### Add a hook to a project

Adds a hook to a specified project.

```javascript
// From a project ID
let hook = GitlabAPI.projects.hooks.add(projectId, {
// params
});
```
Parameters: [Add a hook](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#add-project-hook)

### Edit a hook

Edits a hook for a specified project.

```javascript
// From a project ID
let hook = GitlabAPI.projects.hooks.edit(projectId, hookId, {
// params
});
```
Parameters: [Edit a hook](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#edit-project-hook)

### Remove a hook

Remove a hook from a project.

```javascript
// From a project ID
GitlabAPI.projects.hooks.remove(projectId, hookId);
```
Parameters: [Remove a hook](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#delete-project-hook)


14 changes: 6 additions & 8 deletions docs/project-triggers.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## Project Triggers

* [List all triggers](#list-all-triggers)
* [Get a trigger](#get-a-triggers)
* [Create a trigger](#create-a-triggers)
* [Edit a trigger](#edit-a-triggers)
* [Remove a trigger](#edit-a-triggers)
* [Get a trigger](#get-a-trigger)
* [Add a trigger](#add-a-trigger)
* [Edit a trigger](#edit-a-trigger)
* [Remove a trigger](#edit-a-trigger)

### List all project triggers

Expand All @@ -26,13 +26,13 @@ let trigger = GitlabAPI.projects.triggers.show(projectId, triggerId);
```
Parameters: [Get trigger details](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/pipeline_triggers.md#get-trigger-details)

### Create a trigger
### Add a trigger

Create a trigger for a project.

```javascript
// From a project ID
let trigger = GitlabAPI.projects.triggers.create(projectId, {
let trigger = GitlabAPI.projects.triggers.add(projectId, {
// params
});
```
Expand All @@ -59,5 +59,3 @@ Remove a trigger from a project.
let trigger = GitlabAPI.projects.triggers.remove(projectId, triggerId);
```
Parameters: [Remove a trigger](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/pipeline_triggers.md#remove-a-project-trigger)


2 changes: 1 addition & 1 deletion docs/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* [Star a project](#star-a-project)
* [Unstar a project](#unstar-a-project)
* [Project search](#project-search)
* [Project Repository](https://github.com/jdalrymple/node-gitlab-api/blob/master/docs/project-repository.md)
* [Project Members](https://github.com/jdalrymple/node-gitlab-api/blob/master/docs/project-members.md)
* [Project Triggers](https://github.com/jdalrymple/node-gitlab-api/blob/master/docs/project-triggers.md)
* [Project Hooks](https://github.com/jdalrymple/node-gitlab-api/blob/master/docs/project-hooks.md)
* [Project Repository](https://github.com/jdalrymple/node-gitlab-api/blob/master/docs/project-repository.md)

## Projects

Expand Down
3 changes: 2 additions & 1 deletion src/API.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Request = require('request-promise');
const { Groups, Projects, Issues, Users, Labels } = require('./Models');
const { Groups, Projects, Issues, Runners, Users, Labels } = require('./Models');

class API {
constructor({ url = 'https://gitlab.com', token, oauthToken }) {
Expand All @@ -19,6 +19,7 @@ class API {
this.issues = new Issues(this);
this.users = new Users(this);
this.labels = new Labels(this);
this.runners = new Runners(this);
}

get(endpoint, options) {
Expand Down
14 changes: 5 additions & 9 deletions src/Models/ProjectTriggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,25 @@ class ProjectTriggers extends BaseModel {
super(...args);
}

createTrigger(projectId, options = {}) {
add(projectId, options = {}) {
return this.post(`projects/${Utils.parse(projectId)}/triggers`, options);
}

editTrigger(projectId, triggerId, options = {}) {
edit(projectId, triggerId, options = {}) {
return this.put(`projects/${Utils.parse(projectId)}/triggers/${Utils.parse(triggerId)}`, options);
}

listTriggers(projectId) {
list(projectId) {
return this.get(`projects/${Utils.parse(projectId)}/triggers`);
}

removeTrigger(projectId, triggerId) {
remove(projectId, triggerId) {
return this.delete(`projects/${Utils.parse(projectId)}/triggers/${Utils.parse(triggerId)}`);
}

showTrigger(projectId, triggerId) {
show(projectId, triggerId) {
return this.get(`projects/${Utils.parse(projectId)}/triggers/${Utils.parse(triggerId)}`);
}

triggerBuild(options = {}) {
return this.post(`projects/${Utils.parse(options.projectId)}/trigger/pipeline`, options);
}
}

module.exports = ProjectTriggers;

0 comments on commit 7a90dbb

Please sign in to comment.