Gitlab Management
Gitlab Management is a Gitlab API wrapper for make your life easier.
We working on live demo, give us little more time!
Installation
Gitlab Management is available as an npm package.
// With npm
npm install @sigeo/gitlab-management
// With yarn
yarn add @sigeo/gitlab-management
Usage
Here is a quick example to get you started, it's all you need:
import React, { PureComponent } from 'react';
import ReactDOM from 'react-dom';
import GitlabManagement from '@sigeo/gitlab-management';
class App extends PureComponent {
componentDidMount () {
const gitlabProjectId = ...;
const gitlabReporter = ...;
const gitlabInstance = new GitlabManagement(gitlabProjectId, gitlabReporter);
gitlabInstance.openIssue({
title: 'Issue example',
description: "It's an example",
labels: 'Example'
});
}
...
}
ReactDOM.render(<App />, document.querySelector('#app'));
Before use it
The library work only if you have set a Gitlab project id and a Gitlab private token on it. You can do it in two ways:
- Constructor way: you can pass 2 arguments in the class constructor (like example on top):
- Project id as first argument
- Private key as second argument
- With ad hoc methods:
- You can use setProjectId private method for set the Gitlab project id
- You can use setPrivateToken private method for set the Gitlab private token
Methods
Gitlab Management have a lot of method for wrapper Gitlab API:
Property | Arguments number | Arguments Type | Return type | Description |
---|
setProjectId | 1 | string | void | Set Gitlab project id |
getProjectId | 0 | | string | Return Gitlab project id |
setPrivateToken | 1 | string | void | Set Gitlab private token |
getPrivateToken | 0 | | string | Return Gitlab private token |
setHeaders | 1 | object | void | An key-value map for set headers in API calls |
getHeaders | 0 | | object | Return headers |
getProjects | 1 | IGetProjectsProps interface | Promise | Get gitlab projects |
getMembers | 1 | IGetMembersProps interface | Promise | Get all projects members |
openIssue | 1 | INewIssueProps interface | Promise | Open a new issue |
getIssues | 1 | IGetIssuesProps interface | Promise | Get issues |
closeIssue | 1 | IDeleteIssueProps interface | Promise | Close an issue |
Interfaces
We use interfaces for many arguments methods. This is the list:
INewIssueProps
Used in openIssue
method:
export interface INewIssueProps {
iid?: number | string;
title: string;
description?: string;
confidential?: boolean;
assignee_ids?: number[];
milestone_id?: number;
labels?: string;
created_at?: string;
due_date?: string;
weight?: number;
discussion_to_resolve?: string;
merge_request_to_resolve_discussions_of?: number;
}
IGetIssuesProps
Used in getIssues
method:
export interface IGetIssuesProps {
iids?: number[];
state?: string;
with_labels_details?: boolean;
milestone?: string;
author_username?: string;
weight?: number;
order_by?: string;
sort?: string;
search?: string;
created_after?: string;
created_before?: string;
updated_after?: string;
updated_before?: string;
confidential?: string;
my_reaction_emoji?: string;
assignee_username?: string[];
assignee_id?: number;
scope?: string;
author_id?: number;
labels?: string;
}
IGetProjectsProps
Used in getProjects
method:
export interface IGetProjectsProps {
archived?: boolean;
visibility?: string;
sort?: string;
search?: string;
owned?: boolean;
membership?: boolean;
starred?: boolean;
statistics?: boolean;
with_custom_attributes?: boolean;
with_issues_enabled?: boolean;
with_merge_requests_enabled?: boolean;
with_programming_language?: string;
wiki_checksum_failed?: boolean;
repository_checksum_failed?: boolean;
min_access_level?: number;
simple?: boolean;
order_by?: string;
}
IGetMembersProps
Used in getMembers
method:
export interface IGetMembersProps {
query?: string;
}
IDeleteIssueProps
Used in closeIssue
method:
export interface IDeleteIssueProps {
issue_iid: number;
}
Security
This package can create an important vulnerability if you use it front-end side because it's simple to see the private token using for it.
We recommend to use this package only back-end side with Node JS.
License
Copyright © 2019 Sigeo S.R.L
Licensed under a GPL3+ license: http://www.gnu.org/licenses/gpl-3.0.txt