jdalrymple / gitbeaker Goto Github PK
View Code? Open in Web Editor NEW๐ฆ๐งช A comprehensive and typed Gitlab SDK for Node.js, Browsers, Deno and CLI
License: Other
๐ฆ๐งช A comprehensive and typed Gitlab SDK for Node.js, Browsers, Deno and CLI
License: Other
GitLab 10.6 will be release tomorrow (3/22/18) and includes new endpoints for merge request approvals. I just want to submit a feature request for these routes to be added. https://docs.gitlab.com/ee/api/merge_request_approvals.html
Is the version API exposed in any way?
See: https://docs.gitlab.com/ce/api/version.html
This is great for electron apps (or basically any situation where you know the code is running in a browser, because you can exploit the browser's proxy resolution and SSL certificates. It's not normally available in Node, however, so it would have to be an option.
We swapped to this package and a few of our users are complaining about failures with self-signed certificates.
Basically this would be a constructor option that switches out the core driver of the requests. We did this on the original repository with a mix of PRs and fork-fixes for its node-slumber
dependency. I totally expect to write this myself but I wanted to open the issue in advance to make sure you're amenable to such an extension to this package.
If I attempt to use the current NPM release (3.0.2, npm i --save node-gitlab-api
) with the ProjectsBundle
constructor I get the following error:
(node:55285) UnhandledPromiseRejectionWarning: TypeError: _nodeGitlabApi.ProjectsBundle is not a constructor
import { ProjectsBundle } from 'node-gitlab-api';
...
const api = new ProjectsBundle({
url: gitlabUrl,
token: gitlabToken
});
I did try the alternate gitlab
entry from npm (appears to be ahead of your releases at 3.2.0) and installing using the git tag results in node being unable to find the module (in both cases I update the import to gitlab
).
Importing Gitlab
seems fine so I'm sure I'm missing something obvious.
I'm using node 6.11.0 locally.
I'm requiring the module require(node-gitlab-api/dist/es5)
I'm getting the following error when running the app. This only occurs for versions 2.2.5 and above
Any help would be appreciated.
var _classCallCheck2 = _interopRequireDefault(require("babel-runtime/helpers/classCallCheck"));
^
TypeError: _interopRequireDefault is not a function
Is there a reason, that the merge request api doesn't get exposed?
The model directory exports it here https://github.com/jdalrymple/node-gitlab-api/blob/master/src/Models/index.js#L14
But here in the API it gets not imported https://github.com/jdalrymple/node-gitlab-api/blob/master/src/API.js#L2
And so it is not available here https://github.com/jdalrymple/node-gitlab-api/blob/master/src/API.js#L33-L37
Hi!
This endpoint is missing, can it be added?
https://docs.gitlab.com/ce/api/merge_requests.html#accept-mr
Thanks!
Greetings :),
I am having an issue with getting a project from Gitlab. It sends Nginx to different project names, which therefor errors sometimes.
Code:
let project = await GitlabAPI.projects.show('wp/ds-wp-nginx-fpm');
return project;
Nginx logs:
111.111.29.83 - - [23/Jan/2018:15:32:16 +0000] "GET /api/v4/projects/wp%2Fds-wp-nginx-fpm HTTP/1.1" 200 1917 "-" "-"
111.111.29.84 - - [23/Jan/2018:15:32:18 +0000] "GET /api/v4/projects/wp/ds-wp-nginx-fpm HTTP/1.1" 404 25 "-" "-"
111.111.29.83 - - [23/Jan/2018:15:32:21 +0000] "GET /api/v4/projects/wp%2Fds-wp-nginx-fpm HTTP/1.1" 200 1917 "-" "-"
node version 8.3.0
"node-gitlab-api": "^2.2.1"
src/Models/Projects.js
: Undefined references: ProjectTriggers, ProjectPipelines and ProjectRunners โ lines 30, 31 and 32
When trying to connect to a GitLab with basic auth, the URL accessed is incorrect
Object instantiation:
const GitlabAPI = require('node-gitlab-api')({ url: "https://username:[email protected]/", token: "TOKEN" })
The request-promise url used to access GitLab:
url: 'https://username:[email protected]/api/v4/https://gitlab.url.com/api/v4/users?active=false&blocked=false&external=false&page=2&per_page=20',
src/Models/Projects.js
: unused and non-existent imports 'ProjectBuilds' and 'Pipelines' (lines 12, 13) โ causes module to exit with error
It appears this is currently missing, but would be similar I think to project members?
This feature is not really documented by GitLab, but causes GitLab to send 429 (Too many requests), when enabled or set to low.
It specifies the time the client needs to wait with the Retry-After header in seconds.
GitLab lacks documentation about this feature, but rate-limits can be set in the Admin UI (see screenshot)
and via the settings API.
{
"throttle_authenticated_api_enabled": false,
"throttle_authenticated_api_requests_per_period": 2,
"throttle_authenticated_api_period_in_seconds": 10,
}
node-gitlab-api
should obey these limits. Wait (sleep) the specified time if HTTP 429 is received and retry the request.
The es5 version still has es6 features like async/await included. Looks like a misconfiguration of babel.
e.g. BaseModel.js
=> async function getAllPages...
I wanted to use this in an aws lambda function which supports only node 6
I've used node-gitlab-api 2.2.6 before, which was really intuitive imo (similar to python-gitlab)
Now I wanted to switch to 3.1.0 and I find the new syntax is really confusing. I really need every feature of the GitLab API in one node program. Should I now create a new instance for every bundle?
Also I cannot seem to find any documentation about the custom attributes for Users. I just found the subservice in the User bundle, which I need to initialize as another instance?
Thanks for any help
I notice that the body
and qs
parameters are being run through this method.
As an immediate fix, this should at least be documented more clearly so that no one gets stuck on it. However it seems like a very opinionated way about how the package should be used and what requests should look like. If I used a camel-case key in my qs
parameter, I would not expect an underscore to be inserted in the key; I would expect it to be used literally, at least by default.
To me it seems like a better pattern would be to naively use the options as-given, and if the programmer wants de-camelizing, they can run their own objects through hump before sending them to this package. This would also bring the package size down if hump can be removed as a dependency.
Hello. I'm trying to use search API. Here's my example:
const GitLab = require('node-gitlab-api').default;
const gitlabInstance = new GitLab({
url: 'http://gitlab.com',
token: process.env.GITLAB_TOKEN,
});
gitlabInstance.Search.all('project', 'json')
.then(console.log)
.catch(console.log);
In result i receive an error which contains
body: { error: '404 Not Found' }
The reason, I think, in the path which equals: path: '/api/v4/undefinedsearch?scope=project&search=json'
Here's the options of request i get:
options:
{ url: 'http://gitlab.com/api/v4/undefinedsearch',
headers: { 'private-token': '%my_private_token%' },
json: true,
qs: { scope: 'project', search: 'json' },
resolveWithFullResponse: true,
method: 'GET',
callback: [Function: RP$callback],
transform: undefined,
simple: true,
transform2xxOnly: false },
Versions:
Thank you :)
Hello,
I assume your package on npm is node-gitlab-api. Shouldn't be it installed like npm install node-gitlab-api instead of npm install gitlab?
Same with require('gitlab-api')
Thanks for your job and have a good day.
Hi
Can you add an options
parameter to ProjectRepository.listCommits
so I can do some date filtering please (see https://docs.gitlab.com/ee/api/commits.html)?
listCommits(projectId, options = {}) {
const pId = Utils.parse(projectId);
return this.get(`projects/${pId}/repository/commits`, options);
}
Then it can be called with:
const options = {
"ref_name": "...",
"since": "..."
};
return gitLab.projects.repository.listCommits(gitlabProject, options).then(...)
Much appreciated!
I'm trying to call const projects = await gitlab.groups.projects.all( 'cpd' );
and I'm getting http://<gitlab hostname>/api/v4/groups/NaN/projects
as the request URL because I'm passing the name as the parameter as the gitlab docs say we can but the parse
function is falling through to the parseInt()
bit. Should that be wrapped in a try/catch or something so that if the parseInt fails (or returns NaN
) we get back the original value?
Hello,
I was looking for a way to add time estimates and spent times for issues through the API. I could find methods to add time for merge requests, but not for individual issues so I guess it is not implemented. Is that right?
If so, would you need help implementing it? I guess it would take me some time though to understand how this library works, but I'd be happy to help.
The relevant documentation can be found here
https://docs.gitlab.com/ee/api/issues.html#add-spent-time-for-an-issue
Regards
Alex
Hi, there's new API for /users/:id/custom_attributes and also for groups and projects as well.
Will be great if this can be added.
Thanks.
Sorry for the noise, but could you clarify how to add a note to an issue?
I have the following:
let newIssue = await api.IssueNotes.create(
issue.project_id,
issue.id,
{ body: message.text }
);
The issue object being retrieved via:
let issues = await api.Issues.all({projectId: project.id, search: issueTitle});
var issue = null;
if(issues != null && issues.length == 1) {
issue = issues[0];
}
and looking as I would expect:
{ id: 1922,
iid: 16,
project_id: 916,
title: 'Bug: Keiran Raine - 2018-04-23',
description: 'a\nUI-Page: <http://localhost:3000/#/login>',
state: 'opened',
created_at: '2018-04-23T12:42:54.319Z',
updated_at: '2018-04-23T12:42:54.319Z',
closed_at: null,
labels: [ 'Bug' ],
milestone: null,
assignees: [],
author:
{ id: 67,
name: 'Keiran Raine',
username: 'kr2',
state: 'active',
avatar_url: 'https://.../uploads/-/system/user/avatar/67/avatar.png',
web_url: 'https://.../kr2' },
assignee: null,
user_notes_count: 0,
upvotes: 0,
downvotes: 0,
due_date: null,
confidential: false,
discussion_locked: null,
web_url: 'https://.../.../feedback/issues/16',
time_stats:
{ time_estimate: 0,
total_time_spent: 0,
human_time_estimate: null,
human_total_time_spent: null } }
v3.0.2 (npm i --save node-gitlab-api)
Thanks in advance,
When trying to retrieve all events from a project via the new Event service i came across the following difference between this package and the gitlab api:
https://docs.gitlab.com/ee/api/events.html#list-a-project-39-s-visible-events
The API states that: action and targetType are optional yet this package makes them mandatory as seen in: https://github.com/jdalrymple/node-gitlab-api/blob/4e78749edcd6022736cb8c0471df008de2fc3d19/src/services/Events.js#L27
This prevents me from using the Events service as i cant retrieve all the events.
(ps. i'm only interested in pushed events on the project, but i get an empty response when using:
{ action: 'pushed', targetType: 'project' }, that's how i found the difference between the API and the Service)
(ps2. how can i see the complete response and not only the parsed response for debugging purposes)
For some reason the following request:
const projectId = 123;
const filePath = 'package.json';
const ref = 'master';
this.api.RepositoryFiles.showRaw(projectId, filePath, ref)
Fails with:
UnhandledPromiseRejectionWarning: StatusCodeError: 404 - {"message":"404 Project Not Found"}
at new StatusCodeError (/Users/ev.haus/Git/thing/node_modules/request-promise-core/lib/errors.js:32:15)
at Request.plumbing.callback (/Users/ev.haus/Git/thing/node_modules/request-promise-core/lib/plumbing.js:104:33)
at Request.RP$callback [as _callback] (/Users/ev.haus/Git/thing/node_modules/request-promise-core/lib/plumbing.js:46:31)
at Request.self.callback (/Users/ev.haus/Git/thing/node_modules/request/request.js:186:22)
at Request.emit (events.js:180:13)
at Request.emit (domain.js:422:20)
at Request.<anonymous> (/Users/ev.haus/Git/thing/node_modules/request/request.js:1163:10)
at Request.emit (events.js:180:13)
at Request.emit (domain.js:422:20)
at IncomingMessage.<anonymous> (/Users/ev.haus/Git/naggie/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:272:13)
at IncomingMessage.emit (events.js:185:15)
at IncomingMessage.emit (domain.js:422:20)
at endReadableNT (_stream_readable.js:1106:12)
at process._tickCallback (internal/process/next_tick.js:178:19)
But if I change the code to:
const projectId = 123;
const filePath = 'package.json';
const ref = 'master';
this.api.RepositoryFiles.show(projectId, filePath, ref)
.then((response) => {
return this.api.Repositories.showBlobRaw(projectId, response.blob_id);
});
Then it works just fine.
Any idea what could be wrong?
Support the statistics=yes
parameter for the GitLab API:
https://docs.gitlab.com/ce/api/projects.html
using
const GitlabAPI = gitlab({
url: 'https://PRIVATE_GITLAB_DOMAIN.com',
token: apiToken,
});
works, but when using url: 'https://PRIVATE_GITLAB_DOMAIN.com/',
(with /
at the end) fails without a descriptive error, just a 404 Not Found
.
I would expect that both ways would work..
Thanks.
Currently creating a note for a mergeRequest is posting to
'projects/:id/merge_requests/:merge_request_iid/comment'
however, it should be:
POST /projects/:id/merge_requests/:merge_request_iid/notes
Do you provide an abstraction layer for GitLab custom attributes?
My team is trying to move from the original node-gitlab
repo to this one, primarily for v4 support. A few routes we need are still not implemented here, so we're interested in opening some pull requests.
One that is not totally straightforward is routes that sometimes take an ID and sometimes don't. For example, in UserKeys, all
requires a userID so it can make a GET to /users/${id}/keys
. But there's also a route /user/keys
(docs) to make a request for the currently-authenticated user based on their token (without having to first ask the API what the user's ID is).
I was just wondering how best we could fit things of this pattern into this project. Since it's listed in the Users documentation, on our fork of node-gitlab
we put the implementation into UserKeys
and called it the somewhat-verbose allForCurrentUser
. Does this work for you or is there something you think would fit better?
As of writing this post, there are still many API's this library does not support. I would like to eventually tackle this remaining list for full support of the gitlab API:
Hello,
I'm trying to make an api call to gitlab to protect the master branch.
In theory, the following call to the client, is supposed to protect the master branch such that developers can merge. (merge_access_level: 30). However, after the call is made the master branch is protected with (merge_access_level: 40) where developers cannot merge which is the default.
Any help is appreciated to figure this out :)
response = await client.ProtectedBranches.protect(
project.settings.id,
project.settings.protected_branch.name,
{
push_access_level: 40,
merge_access_level: 30
}
);
Here's the debug of request-promise
library:
{
url: 'https://gitlab.com/api/v4/projects/*******/protected_branches',
headers: { 'private-token': '******' },
json: true,
body: { name: 'master', push_access_level: 40, merge_access_level: 30 },
resolveWithFullResponse: false,
method: 'POST',
callback: [Function: RP$callback],
transform: undefined,
simple: true,
transform2xxOnly: false
}
Hi
(first off, thanks for sharing the code!)
I'm not able to get a repository file using the ProjectRepository.showFile
implementation against my private GitLab v9.5 setup. The modified implementation below (based on the GitLab API docs) is working for me.
Note that the page
option has to be forced to 'true' to prevent BaseModel
from attempting to read all pages (which aren't there).
showFile(projectId, ref, filePath) {
const pId = Utils.parse(projectId);
return this.get(`projects/${pId}/repository/files/${filePath}`, {"ref": ref, "page": true});
}
This would not be necessary if the package is used in node.js server side.
But I'm currently trying this in React.js app using create-react-app
. And it complains while building process, due to the usage of async/await
syntax.
Can we publish this in es5 version?
Seems like the version information is not properly exposed anymore. Is that true or am I using this feature wrong?
node-gitlab-api version: 3.2.1
runtime: node v8.11.1
const Gitlab = require('gitlab').default;
console.log(gitlab.Version);
undefined
Hey, i think i didn't communicate this properly. What i was specifically wondering is when i do a require('gitlab/dist/es5')
(as opposed to node-gitlab-api/dist/es5
) i am having issues. This forces me to stick to node-gitlab-api
of version 3.0.2. but most of the new fixes you put in place such as #82 is only available in gitlab
library.
Code:
const Gitlab = require('gitlab/dist/es5').default
const client = new Gitlab({
url: 'https://gitlab.com', // Defaults to http://gitlab.com
token: 'tG4dZ9UUwijyQKoaZZE2' // Can be created in your profile.
})
const response = await client.Projects.all({membership: true, page:1, per_page: 1});
Bug:
/Users/irally1/Desktop/test/node_modules/gitlab/dist/es5/infrastructure/XMLHttpRequester.js:18
return async function (opts) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
...
Thanks, much appreciated!
BaseModel::get
BaseModel::post
BaseModel::put
Previously, it was checking if options
is truthy, but now it's not, which in turn causes an error.
TypeError: Cannot read property 'page' of undefined
Can we assign default values for options
parameter?
I got a list of all users, by using
const users = await gitlab.users.all();
But getting custom attributes from one user, doesn't seem to work
users.forEach((currentUser) => {
console.log(currentUser.customAttributes.show());
}
TypeError: Cannot read property 'show' of undefined
Any idea, what I might be doing wrong here?
While i was looking at the package on npm today, i noticed it is actually hard to come by when you do a simple search for gitlab. I was thinking maybe using a different package name would help in this regard, something like gitlab-plus ?
Thoughts?
Wondering if there has been any consideration around more of a framework for documentation rather than just readme files? I don't necessarily have a strong opinion on what tool might make sense, just wanted to see if there were any thoughts/plans/starters for it. To me a key to a successful tool is a good set of docs. I wouldn't suggest there would need to be everything documented in the framework right from the beginning but getting something setup so it's easy to add things as folks have time/desire would be nice.
After migrating from node-gitlab-api 2.2.8
to 3.0.2
. The following code is timing out
const options = { membership: true, page: 1, per_page: 1 }
const projects = await client.Projects.all(options);
Any idea why? from analyzing the debug mode for request-promise
library it seems that the library is making retry calls even after a succesful response. It continues retry infinitely until my AWS lambda functions timeout.
Can you provide an ES module entry point with the module field in package.json?
Hey, the documentation says
const Gitlab = require('node-gitlab-api/dist/es5').default
and why not require('gitlab/dist/es5')
?
The more I use the library the more i realise the nested structure can be extremly annoying lol
I propose exporting the subclasses directly in the form:
import { Projects } from 'node-gitlab-api';
const projectsAPI = new Projects(url, token);
projectsAPI.all()
projectsAPI.show(projectId)
etc..
Would this be an improvement?
Code:
let listCommits= await GitlabAPI.projects.repository.commits.all('gg/asdf');
Can one list a specific branches commits ? Sorry for messaging you here <3
So I've been thinking about finally getting started on testing for this library but im a little unsure of how to go about doing so. Usually I would write tests to validate the logic of each of the functions but in this case, the functions are just api calls to gitlab.
Is there a way to write tests to ensure these endpoints are still supported without say, creating a dummy gitlab account for testing?
Hi folks!
I am wondering if there is a way to access/create/update the project and group level secret variables. I looked through the code and couldn't find any models which are using variables related end points (Project Level and Group Level).
Appreciate your help!
Thanks
Saurabh
This library is now available as gitlab
npm package. But the README file has outdated information about that.
Also, about the node-gitlab/node-gitlab repository, one of the following should be done:
jdalrymple/node-gitlab-api
to node-gitlab/node-gitlab
node-gitlab/node-gitlab
repository. Mark it as deprecated in its README and point to jdalrymple/node-gitlab-api
.node-gitlab/node-gitlab
and redirect it's url to jdalrymple/node-gitlab-api
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.