2019-10-16 17:53:15 -07:00
|
|
|
|
import {
|
|
|
|
|
IExecuteFunctions,
|
|
|
|
|
} from 'n8n-core';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
IDataObject,
|
|
|
|
|
INodeExecutionData,
|
|
|
|
|
INodeType,
|
2020-10-01 05:01:39 -07:00
|
|
|
|
INodeTypeDescription,
|
2021-04-16 09:33:36 -07:00
|
|
|
|
NodeOperationError,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
gitlabApiRequest,
|
2021-04-15 15:27:12 -07:00
|
|
|
|
gitlabApiRequestAllItems,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
} from './GenericFunctions';
|
|
|
|
|
|
|
|
|
|
export class Gitlab implements INodeType {
|
|
|
|
|
description: INodeTypeDescription = {
|
2020-07-24 03:56:41 -07:00
|
|
|
|
displayName: 'GitLab',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
name: 'gitlab',
|
2021-03-25 09:10:02 -07:00
|
|
|
|
icon: 'file:gitlab.svg',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
group: ['input'],
|
|
|
|
|
version: 1,
|
2019-10-24 23:15:36 -07:00
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
2021-07-03 05:40:16 -07:00
|
|
|
|
description: 'Retrieve data from GitLab API',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
defaults: {
|
|
|
|
|
name: 'Gitlab',
|
|
|
|
|
},
|
|
|
|
|
inputs: ['main'],
|
|
|
|
|
outputs: ['main'],
|
|
|
|
|
credentials: [
|
|
|
|
|
{
|
|
|
|
|
name: 'gitlabApi',
|
|
|
|
|
required: true,
|
2020-06-16 06:50:17 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
authentication: [
|
|
|
|
|
'accessToken',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'gitlabOAuth2Api',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
authentication: [
|
|
|
|
|
'oAuth2',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
],
|
|
|
|
|
properties: [
|
2020-06-16 06:50:17 -07:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Authentication',
|
|
|
|
|
name: 'authentication',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Access Token',
|
|
|
|
|
value: 'accessToken',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'OAuth2',
|
|
|
|
|
value: 'oAuth2',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'accessToken',
|
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Resource',
|
|
|
|
|
name: 'resource',
|
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
|
noDataExpression: true,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Issue',
|
|
|
|
|
value: 'issue',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Repository',
|
|
|
|
|
value: 'repository',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Release',
|
|
|
|
|
value: 'release',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'User',
|
|
|
|
|
value: 'user',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'issue',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// operations
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Operation',
|
|
|
|
|
name: 'operation',
|
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
|
noDataExpression: true,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Create',
|
|
|
|
|
value: 'create',
|
|
|
|
|
description: 'Create a new issue',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Create Comment',
|
|
|
|
|
value: 'createComment',
|
|
|
|
|
description: 'Create a new comment on an issue',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Edit',
|
|
|
|
|
value: 'edit',
|
|
|
|
|
description: 'Edit an issue',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Get',
|
|
|
|
|
value: 'get',
|
2020-07-24 03:56:41 -07:00
|
|
|
|
description: 'Get the data of a single issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Lock',
|
|
|
|
|
value: 'lock',
|
|
|
|
|
description: 'Lock an issue',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'create',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Operation',
|
|
|
|
|
name: 'operation',
|
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
|
noDataExpression: true,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
resource: [
|
|
|
|
|
'repository',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Get',
|
|
|
|
|
value: 'get',
|
|
|
|
|
description: 'Get the data of a single repository',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Get Issues',
|
|
|
|
|
value: 'getIssues',
|
|
|
|
|
description: 'Returns issues of a repository',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'getIssues',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Operation',
|
|
|
|
|
name: 'operation',
|
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
|
noDataExpression: true,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
resource: [
|
|
|
|
|
'user',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Get Repositories',
|
|
|
|
|
value: 'getRepositories',
|
|
|
|
|
description: 'Returns the repositories of a user',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'getRepositories',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Operation',
|
|
|
|
|
name: 'operation',
|
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
|
noDataExpression: true,
|
2019-10-16 17:53:15 -07:00
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Create',
|
|
|
|
|
value: 'create',
|
2020-07-24 03:56:41 -07:00
|
|
|
|
description: 'Create a new release',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
2021-04-15 15:27:12 -07:00
|
|
|
|
{
|
|
|
|
|
name: 'Delete',
|
|
|
|
|
value: 'delete',
|
|
|
|
|
description: 'Delete a new release',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Get',
|
|
|
|
|
value: 'get',
|
|
|
|
|
description: 'Get a new release',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Get All',
|
|
|
|
|
value: 'getAll',
|
|
|
|
|
description: 'Get all releases',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Update',
|
|
|
|
|
value: 'update',
|
|
|
|
|
description: 'Update a new release',
|
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
],
|
|
|
|
|
default: 'create',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// shared
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Project Owner',
|
|
|
|
|
name: 'owner',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
placeholder: 'n8n-io',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'User, group or namespace of the project',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Project Name',
|
|
|
|
|
name: 'repository',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
hide: {
|
|
|
|
|
resource: [
|
|
|
|
|
'user',
|
|
|
|
|
],
|
|
|
|
|
operation: [
|
|
|
|
|
'getRepositories',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
placeholder: 'n8n',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The name of the project',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// issue
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// issue:create
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Title',
|
|
|
|
|
name: 'title',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The title of the issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Body',
|
2019-11-10 01:17:56 -08:00
|
|
|
|
name: 'body',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
type: 'string',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
rows: 5,
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The body of the issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
2019-11-10 01:17:56 -08:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Due Date',
|
|
|
|
|
name: 'due_date',
|
|
|
|
|
type: 'dateTime',
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Due Date for issue',
|
2019-11-10 01:17:56 -08:00
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Labels',
|
|
|
|
|
name: 'labels',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValues: true,
|
|
|
|
|
multipleValueButtonText: 'Add Label',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: { 'label': '' },
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Label',
|
|
|
|
|
name: 'label',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Label to add to issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Assignees',
|
|
|
|
|
name: 'assignee_ids',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValues: true,
|
|
|
|
|
multipleValueButtonText: 'Add Assignee',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: { 'assignee': '' },
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Assignee',
|
|
|
|
|
name: 'assignee',
|
|
|
|
|
type: 'number',
|
|
|
|
|
default: 0,
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'User ID to assign issue to',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2019-11-10 01:17:56 -08:00
|
|
|
|
|
|
|
|
|
|
2019-10-16 17:53:15 -07:00
|
|
|
|
// ----------------------------------
|
|
|
|
|
// issue:createComment
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Issue Number',
|
|
|
|
|
name: 'issueNumber',
|
|
|
|
|
type: 'number',
|
|
|
|
|
default: 0,
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'createComment',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The number of the issue on which to create the comment on',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Body',
|
|
|
|
|
name: 'body',
|
|
|
|
|
type: 'string',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
rows: 5,
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'createComment',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The body of the comment',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// issue:edit
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Issue Number',
|
|
|
|
|
name: 'issueNumber',
|
|
|
|
|
type: 'number',
|
|
|
|
|
default: 0,
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'edit',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The number of the issue edit',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Edit Fields',
|
|
|
|
|
name: 'editFields',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValueButtonText: 'Add Field',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'edit',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: {},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Title',
|
|
|
|
|
name: 'title',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The title of the issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Body',
|
2019-11-08 06:13:48 -08:00
|
|
|
|
name: 'description',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
type: 'string',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
rows: 5,
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The body of the issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'State',
|
|
|
|
|
name: 'state',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Closed',
|
|
|
|
|
value: 'closed',
|
|
|
|
|
description: 'Set the state to "closed"',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Open',
|
|
|
|
|
value: 'open',
|
|
|
|
|
description: 'Set the state to "open"',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'open',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The state to set',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Labels',
|
|
|
|
|
name: 'labels',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValues: true,
|
|
|
|
|
multipleValueButtonText: 'Add Label',
|
|
|
|
|
},
|
|
|
|
|
default: { 'label': '' },
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Label',
|
|
|
|
|
name: 'label',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Label to add to issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Assignees',
|
|
|
|
|
name: 'assignee_ids',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValues: true,
|
|
|
|
|
multipleValueButtonText: 'Add Assignee',
|
|
|
|
|
},
|
|
|
|
|
default: { 'assignee': '' },
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Assignees',
|
|
|
|
|
name: 'assignee',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'User to assign issue too',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2019-11-08 03:41:47 -08:00
|
|
|
|
{
|
|
|
|
|
displayName: 'Due Date',
|
|
|
|
|
name: 'due_date',
|
2019-11-10 01:17:56 -08:00
|
|
|
|
type: 'dateTime',
|
2019-11-08 03:41:47 -08:00
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Due Date for issue',
|
2019-11-08 03:41:47 -08:00
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// issue:get
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Issue Number',
|
|
|
|
|
name: 'issueNumber',
|
|
|
|
|
type: 'number',
|
|
|
|
|
default: 0,
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'get',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The number of the issue get data of',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// issue:lock
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Issue Number',
|
|
|
|
|
name: 'issueNumber',
|
|
|
|
|
type: 'number',
|
|
|
|
|
default: 0,
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'lock',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The number of the issue to lock',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Lock Reason',
|
|
|
|
|
name: 'lockReason',
|
|
|
|
|
type: 'options',
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'lock',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'issue',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Off-Topic',
|
|
|
|
|
value: 'off-topic',
|
|
|
|
|
description: 'The issue is Off-Topic',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Too Heated',
|
|
|
|
|
value: 'too heated',
|
|
|
|
|
description: 'The discussion is too heated',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Resolved',
|
|
|
|
|
value: 'resolved',
|
|
|
|
|
description: 'The issue got resolved',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Spam',
|
|
|
|
|
value: 'spam',
|
|
|
|
|
description: 'The issue is spam',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'resolved',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The reason to lock the issue',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// release
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// release:create
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Tag',
|
|
|
|
|
name: 'releaseTag',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The tag of the release',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
|
name: 'additionalFields',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValueButtonText: 'Add Field',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'create',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: {},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Name',
|
|
|
|
|
name: 'name',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The name of the release',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Description',
|
|
|
|
|
name: 'description',
|
|
|
|
|
type: 'string',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
rows: 5,
|
|
|
|
|
},
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The description of the release',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Ref',
|
|
|
|
|
name: 'ref',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
description: 'If Tag doesn’t exist, the release will be created from Ref. It can be a commit SHA, another tag name, or a branch name.',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
2021-04-15 15:27:12 -07:00
|
|
|
|
// ----------------------------------
|
|
|
|
|
// release:get/delete
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Project ID',
|
|
|
|
|
name: 'projectId',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'delete',
|
|
|
|
|
'get',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The ID or URL-encoded path of the project',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Tag Name',
|
|
|
|
|
name: 'tag_name',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'delete',
|
|
|
|
|
'get',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The Git tag the release is associated with',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-04-15 15:27:12 -07:00
|
|
|
|
// ----------------------------------
|
|
|
|
|
// release:getAll
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Project ID',
|
|
|
|
|
name: 'projectId',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'getAll',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The ID or URL-encoded path of the project',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Return All',
|
|
|
|
|
name: 'returnAll',
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
operation: [
|
|
|
|
|
'getAll',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: false,
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Whether to return all results or only up to a given limit',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Limit',
|
|
|
|
|
name: 'limit',
|
|
|
|
|
type: 'number',
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
operation: [
|
|
|
|
|
'getAll',
|
|
|
|
|
],
|
|
|
|
|
returnAll: [
|
|
|
|
|
false,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
typeOptions: {
|
|
|
|
|
minValue: 1,
|
|
|
|
|
maxValue: 100,
|
|
|
|
|
},
|
|
|
|
|
default: 20,
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Max number of results to return',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
|
name: 'additionalFields',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValueButtonText: 'Add Field',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'getAll',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: {},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
2022-06-03 10:23:49 -07:00
|
|
|
|
displayName: 'Order By',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
name: 'order_by',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Created At',
|
|
|
|
|
value: 'created_at',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Released At',
|
|
|
|
|
value: 'released_at',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'released_at',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The field to use as order',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Sort',
|
|
|
|
|
name: 'sort',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ASC',
|
|
|
|
|
value: 'asc',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'DESC',
|
|
|
|
|
value: 'desc',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'desc',
|
|
|
|
|
description: 'The direction of the order. .',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-04-15 15:27:12 -07:00
|
|
|
|
// ----------------------------------
|
|
|
|
|
// release:update
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Project ID',
|
|
|
|
|
name: 'projectId',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'update',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The ID or URL-encoded path of the project',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Tag Name',
|
|
|
|
|
name: 'tag_name',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
required: true,
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'update',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The Git tag the release is associated with',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
|
name: 'additionalFields',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValueButtonText: 'Add Field',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
|
|
|
|
'update',
|
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'release',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: {},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Name',
|
|
|
|
|
name: 'name',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The release name',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Description',
|
|
|
|
|
name: 'description',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
description: 'The description of the release. You can use Markdown.',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Milestones',
|
|
|
|
|
name: 'milestones',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The title of each milestone to associate with the release (provide a titles list spearated with comma)',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Released At',
|
|
|
|
|
name: 'released_at',
|
|
|
|
|
type: 'dateTime',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The date when the release is/was ready',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2019-10-16 17:53:15 -07:00
|
|
|
|
// ----------------------------------
|
|
|
|
|
// repository
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// repository:getIssues
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Filters',
|
|
|
|
|
name: 'getRepositoryIssuesFilters',
|
|
|
|
|
type: 'collection',
|
|
|
|
|
typeOptions: {
|
|
|
|
|
multipleValueButtonText: 'Add Filter',
|
|
|
|
|
},
|
|
|
|
|
displayOptions: {
|
|
|
|
|
show: {
|
|
|
|
|
operation: [
|
2020-10-22 06:46:03 -07:00
|
|
|
|
'getIssues',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
],
|
|
|
|
|
resource: [
|
|
|
|
|
'repository',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
default: {},
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Assignee',
|
|
|
|
|
name: 'assignee_username',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Return only issues which are assigned to a specific user',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Creator',
|
|
|
|
|
name: 'author_username',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Return only issues which were created by a specific user',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Labels',
|
|
|
|
|
name: 'labels',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
description: 'Return only issues with the given labels. Multiple lables can be separated by comma.',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Updated After',
|
|
|
|
|
name: 'updated_after',
|
|
|
|
|
type: 'dateTime',
|
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Return only issues updated at or after this time',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'State',
|
|
|
|
|
name: 'state',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'All',
|
|
|
|
|
value: '',
|
|
|
|
|
description: 'Returns issues with any state',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Closed',
|
|
|
|
|
value: 'closed',
|
|
|
|
|
description: 'Return issues with "closed" state',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Open',
|
|
|
|
|
value: 'opened',
|
|
|
|
|
description: 'Return issues with "open" state',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'opened',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The state to filter by',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Sort',
|
|
|
|
|
name: 'order_by',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Created At',
|
|
|
|
|
value: 'created_at',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Sort by created date',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Updated At',
|
|
|
|
|
value: 'updated_at',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Sort by updated date',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Priority',
|
|
|
|
|
value: 'priority',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'Sort by priority',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
],
|
2019-10-24 23:15:36 -07:00
|
|
|
|
default: 'created_at',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The order the issues should be returned in',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
displayName: 'Direction',
|
|
|
|
|
name: 'sort',
|
|
|
|
|
type: 'options',
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Ascending',
|
|
|
|
|
value: 'asc',
|
|
|
|
|
description: 'Sort in ascending order',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Descending',
|
|
|
|
|
value: 'desc',
|
|
|
|
|
description: 'Sort in descending order',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
default: 'desc',
|
2022-05-06 14:01:25 -07:00
|
|
|
|
description: 'The sort order',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
|
const items = this.getInputData();
|
|
|
|
|
const returnData: IDataObject[] = [];
|
|
|
|
|
|
2020-06-16 06:50:17 -07:00
|
|
|
|
let credentials;
|
|
|
|
|
|
|
|
|
|
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2020-06-16 06:50:17 -07:00
|
|
|
|
try {
|
|
|
|
|
if (authenticationMethod === 'accessToken') {
|
2021-08-20 09:57:30 -07:00
|
|
|
|
credentials = await this.getCredentials('gitlabApi');
|
2020-06-16 06:50:17 -07:00
|
|
|
|
} else {
|
2021-08-20 09:57:30 -07:00
|
|
|
|
credentials = await this.getCredentials('gitlabOAuth2Api');
|
2020-06-16 06:50:17 -07:00
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (this.continueOnFail()) {
|
|
|
|
|
return [this.helpers.returnJsonArray([{ error: error.message }])];
|
|
|
|
|
}
|
2021-04-16 09:33:36 -07:00
|
|
|
|
throw new NodeOperationError(this.getNode(), error);
|
2019-10-16 17:53:15 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Operations which overwrite the returned data
|
|
|
|
|
const overwriteDataOperations = [
|
|
|
|
|
'issue:create',
|
|
|
|
|
'issue:createComment',
|
|
|
|
|
'issue:edit',
|
|
|
|
|
'issue:get',
|
|
|
|
|
'release:create',
|
2021-04-15 15:27:12 -07:00
|
|
|
|
'release:delete',
|
|
|
|
|
'release:get',
|
|
|
|
|
'release:update',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
'repository:get',
|
|
|
|
|
];
|
|
|
|
|
// Operations which overwrite the returned data and return arrays
|
|
|
|
|
// and has so to be merged with the data of other items
|
|
|
|
|
const overwriteDataOperationsArray = [
|
2021-04-15 15:27:12 -07:00
|
|
|
|
'release:getAll',
|
2019-10-16 17:53:15 -07:00
|
|
|
|
'repository:getIssues',
|
|
|
|
|
'user:getRepositories',
|
|
|
|
|
];
|
|
|
|
|
|
2021-04-15 15:27:12 -07:00
|
|
|
|
let responseData;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
// For Post
|
|
|
|
|
let body: IDataObject;
|
|
|
|
|
// For Query string
|
|
|
|
|
let qs: IDataObject;
|
|
|
|
|
|
|
|
|
|
let requestMethod: string;
|
|
|
|
|
let endpoint: string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
let returnAll = false;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
|
|
|
|
const operation = this.getNodeParameter('operation', 0) as string;
|
|
|
|
|
const resource = this.getNodeParameter('resource', 0) as string;
|
|
|
|
|
const fullOperation = `${resource}:${operation}`;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
2021-07-19 23:58:54 -07:00
|
|
|
|
try {
|
|
|
|
|
// Reset all values
|
|
|
|
|
requestMethod = 'GET';
|
|
|
|
|
endpoint = '';
|
|
|
|
|
body = {};
|
|
|
|
|
qs = {};
|
|
|
|
|
|
|
|
|
|
// Request the parameters which almost all operations need
|
|
|
|
|
let owner = this.getNodeParameter('owner', i) as string;
|
|
|
|
|
|
|
|
|
|
// Replace all slashes to work with subgroups
|
|
|
|
|
owner = owner.replace(new RegExp(/\//g), '%2F');
|
|
|
|
|
|
|
|
|
|
let repository = '';
|
|
|
|
|
if (fullOperation !== 'user:getRepositories') {
|
|
|
|
|
repository = this.getNodeParameter('repository', i) as string;
|
|
|
|
|
}
|
2019-12-13 09:43:01 -08:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const baseEndpoint = `/projects/${owner}%2F${repository}`;
|
2019-12-13 09:43:01 -08:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (resource === 'issue') {
|
|
|
|
|
if (operation === 'create') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// create
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'POST';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body.title = this.getNodeParameter('title', i) as string;
|
|
|
|
|
body.description = this.getNodeParameter('body', i) as string;
|
|
|
|
|
body.due_date = this.getNodeParameter('due_date', i) as string;
|
|
|
|
|
const labels = this.getNodeParameter('labels', i) as IDataObject[];
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const assigneeIds = this.getNodeParameter('assignee_ids', i) as IDataObject[];
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body.labels = labels.map((data) => data['label']).join(',');
|
|
|
|
|
body.assignee_ids = assigneeIds.map((data) => data['assignee']);
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/issues`;
|
|
|
|
|
} else if (operation === 'createComment') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// createComment
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
requestMethod = 'POST';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const issueNumber = this.getNodeParameter('issueNumber', i) as string;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body.body = this.getNodeParameter('body', i) as string;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/issues/${issueNumber}/notes`;
|
|
|
|
|
} else if (operation === 'edit') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// edit
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'PUT';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const issueNumber = this.getNodeParameter('issueNumber', i) as string;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body = this.getNodeParameter('editFields', i, {}) as IDataObject;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (body.labels !== undefined) {
|
|
|
|
|
body.labels = (body.labels as IDataObject[]).map((data) => data['label']).join(',');
|
|
|
|
|
}
|
|
|
|
|
if (body.assignee_ids !== undefined) {
|
|
|
|
|
body.assignee_ids = (body.assignee_ids as IDataObject[]).map((data) => data['assignee']);
|
|
|
|
|
}
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/issues/${issueNumber}`;
|
|
|
|
|
} else if (operation === 'get') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// get
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'GET';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const issueNumber = this.getNodeParameter('issueNumber', i) as string;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/issues/${issueNumber}`;
|
|
|
|
|
} else if (operation === 'lock') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// lock
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'PUT';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const issueNumber = this.getNodeParameter('issueNumber', i) as string;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body.discussion_locked = true;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/issues/${issueNumber}`;
|
|
|
|
|
}
|
|
|
|
|
} else if (resource === 'release') {
|
|
|
|
|
if (operation === 'create') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// create
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'POST';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body.tag_name = this.getNodeParameter('releaseTag', i) as string;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/releases`;
|
|
|
|
|
}
|
|
|
|
|
if (operation === 'delete') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// delete
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'DELETE';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const id = this.getNodeParameter('projectId', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const tagName = this.getNodeParameter('tag_name', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `/projects/${id}/releases/${tagName}`;
|
|
|
|
|
}
|
|
|
|
|
if (operation === 'get') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// get
|
|
|
|
|
// ----------------------------------
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'GET';
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const id = this.getNodeParameter('projectId', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const tagName = this.getNodeParameter('tag_name', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `/projects/${id}/releases/${tagName}`;
|
|
|
|
|
}
|
|
|
|
|
if (operation === 'getAll') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// getAll
|
|
|
|
|
// ----------------------------------
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'GET';
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const id = this.getNodeParameter('projectId', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
qs = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
2021-04-15 15:27:49 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (returnAll === false) {
|
|
|
|
|
qs.per_page = this.getNodeParameter('limit', 0) as number;
|
|
|
|
|
}
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `/projects/${id}/releases`;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (operation === 'update') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// update
|
|
|
|
|
// ----------------------------------
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'PUT';
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const id = this.getNodeParameter('projectId', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
const tagName = this.getNodeParameter('tag_name', i) as string;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
body = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
|
|
|
|
|
if(body.milestones){
|
|
|
|
|
body.milestones = (body.milestones as string).split(',');
|
|
|
|
|
}
|
2021-04-15 15:27:12 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `/projects/${id}/releases/${tagName}`;
|
2021-04-15 15:27:12 -07:00
|
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
|
} else if (resource === 'repository') {
|
|
|
|
|
if (operation === 'get') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// get
|
|
|
|
|
// ----------------------------------
|
2021-04-15 15:27:49 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'GET';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}`;
|
|
|
|
|
} else if (operation === 'getIssues') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// getIssues
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'GET';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
qs = this.getNodeParameter('getRepositoryIssuesFilters', i) as IDataObject;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `${baseEndpoint}/issues`;
|
|
|
|
|
}
|
|
|
|
|
} else if (resource === 'user') {
|
|
|
|
|
if (operation === 'getRepositories') {
|
|
|
|
|
// ----------------------------------
|
|
|
|
|
// getRepositories
|
|
|
|
|
// ----------------------------------
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
requestMethod = 'GET';
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
endpoint = `/users/${owner}/projects`;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
|
2019-10-16 17:53:15 -07:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (returnAll === true) {
|
|
|
|
|
responseData = await gitlabApiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
|
|
|
|
} else {
|
|
|
|
|
responseData = await gitlabApiRequest.call(this, requestMethod, endpoint, body, qs);
|
|
|
|
|
}
|
2019-10-16 17:53:15 -07:00
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
|
if (overwriteDataOperations.includes(fullOperation)) {
|
|
|
|
|
returnData.push(responseData);
|
|
|
|
|
} else if (overwriteDataOperationsArray.includes(fullOperation)) {
|
|
|
|
|
returnData.push.apply(returnData, responseData);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
if (this.continueOnFail()) {
|
|
|
|
|
if (overwriteDataOperations.includes(fullOperation) || overwriteDataOperationsArray.includes(fullOperation)) {
|
|
|
|
|
returnData.push({ error: error.message });
|
|
|
|
|
} else {
|
|
|
|
|
items[i].json = { error: error.message };
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
throw error;
|
2019-10-16 17:53:15 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (overwriteDataOperations.includes(fullOperation) || overwriteDataOperationsArray.includes(fullOperation)) {
|
|
|
|
|
// Return data gets replaced
|
|
|
|
|
return [this.helpers.returnJsonArray(returnData)];
|
|
|
|
|
} else {
|
|
|
|
|
// For all other ones simply return the unchanged items
|
|
|
|
|
return this.prepareOutputData(items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|