mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add get/getAll/update/delete:Release to Gitlab node (#1629)
This commit is contained in:
@@ -18,7 +18,7 @@ import { OptionsWithUri } from 'request';
|
||||
* @param {object} body
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const options : OptionsWithUri = {
|
||||
method,
|
||||
headers: {},
|
||||
@@ -28,6 +28,9 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (Object.keys(option).length !== 0) {
|
||||
Object.assign(options, option);
|
||||
}
|
||||
if (query === undefined) {
|
||||
delete options.qs;
|
||||
}
|
||||
@@ -71,3 +74,22 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function gitlabApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
|
||||
query.per_page = 100;
|
||||
query.page = 1;
|
||||
|
||||
do {
|
||||
responseData = await gitlabApiRequest.call(this, method, endpoint, body, query, { resolveWithFullResponse: true });
|
||||
query.page++;
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
} while (
|
||||
responseData.headers.link && responseData.headers.link.includes('next')
|
||||
);
|
||||
return returnData;
|
||||
}
|
||||
Reference in New Issue
Block a user