Gitlab - List Project Issues
@sergio
code:
data:privatelast updated:2 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 250,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
gitlab_list_project_issues
Get a list of a project’s issues.
auth
(auths.gitlab)
params
Id

The ID or URL-encoded path of the project owned by the authenticated user

string ·params.id
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
}
136
var queryString = "";

var growQueryString = function(param_name,param_value,current_query_string){
  var new_query_string = '';

  if (current_query_string.indexOf('?') > -1){
    new_query_string = current_query_string+"&"+param_name+"="+param_value;
  } else {
    new_query_string = "?"+param_name+"="+param_value;
  }
  return new_query_string;
};

var growQueryString2 = function(param_name,param_value,current_query_string){
  var new_query_string = '';

  if (current_query_string.indexOf('?') > -1){
    new_query_string = current_query_string+"&&"+param_name+"="+param_value;
  } else {
    new_query_string = "?"+param_name+"="+param_value;
  }
  return new_query_string;
};

if(params.iids){
  var iids = JSON.parse(params.iids)
  for(var i=0; i<iids.length; i++){    
    queryString = growQueryString2("iids[]",iids[i],queryString);
  }  
} 

if(params.state){
  queryString = growQueryString("state",params.state,queryString);
} 

if(params.labels){
  queryString = growQueryString("labels",params.labels,queryString);
} 

if(params.with_labels_details){
  queryString = growQueryString("with_labels_details",params.with_labels_details,queryString);
} 

if(params.milestone){
  queryString = growQueryString("milestone",params.milestone,queryString);
} 

if(params.scope){
  queryString = growQueryString("scope",params.scope,queryString);
} 

if(params.author_id){
  queryString = growQueryString("author_id",params.author_id,queryString);
} 

if(params.author_username){
  queryString = growQueryString("author_username",params.author_username,queryString);
} 

if(params.assignee_id){
  queryString = growQueryString("assignee_id",params.assignee_id,queryString);
} 

if(params.assignee_username){
  try{
    //Gitlab Community Edition uses a single element array
    var assignee_username_array =  JSON.parse(params.assignee_username);
    queryString = growQueryString("assignee_username",assignee_username_array[0],queryString);
  }catch(err){
    //Gitlab Enterprise uses plain string
    queryString = growQueryString("assignee_username",params.assignee_username,queryString);
  }
} 

if(params.my_reaction_emoji){
  queryString = growQueryString("my_reaction_emoji",params.my_reaction_emoji,queryString);
} 

if(params.weight ){
  queryString = growQueryString("weight",params.weight,queryString);
} 

if(params.order_by){
  queryString = growQueryString("order_by",params.order_by,queryString);
} 

if(params.sort){
  queryString = growQueryString("sort",params.sort,queryString);
} 

if(params.search){
  queryString = growQueryString("search",params.search,queryString);
} 

if(params.search_in){
  queryString = growQueryString("in",params.search_in,queryString);
} 

if(params.created_after){
  queryString = growQueryString("created_after",params.created_after,queryString);
} 

if(params.created_before){
  queryString = growQueryString("created_before",params.created_before,queryString);
}

if(params.updated_after){
  queryString = growQueryString("updated_after",params.updated_after,queryString);
} 

if(params.updated_before){
  queryString = growQueryString("updated_before",params.updated_before,queryString);
} 

if(params.confidential){
  queryString = growQueryString("confidential",params.confidential,queryString);
} 

if(params.not){
  queryString = growQueryString("not",params.not,queryString);
} 

const request = require("request");
const request_promise = require("request-promise");
try{
  this.resp = await request_promise({      
      uri: `https://gitlab.com/api/v4/projects/${params.id}/issues${queryString}`,
      headers: {
      Authorization:  `Bearer ${auths.gitlab.oauth_access_token}`
  }
  });  
}catch(err){
  this.err = err;
}
var queryString = "";

var growQueryString = function(param_name,param_value,current_query_string){
  var new_query_string = '';

  if (current_query_string.indexOf('?') > -1){
    new_query_string = current_query_string+"&"+param_name+"="+param_value;
  } else {
    new_query_string = "?"+param_name+"="+param_value;
  }
  return new_query_string;
};

var growQueryString2 = function(param_name,param_value,current_query_string){
  var new_query_string = '';

  if (current_query_string.indexOf('?') > -1){
    new_query_string = current_query_string+"&&"+param_name+"="+param_value;
  } else {
    new_query_string = "?"+param_name+"="+param_value;
  }
  return new_query_string;
};

if(params.iids){
  var iids = JSON.parse(params.iids)
  for(var i=0; i<iids.length; i++){    
    queryString = growQueryString2("iids[]",iids[i],queryString);
  }  
} 

if(params.state){
  queryString = growQueryString("state",params.state,queryString);
} 

if(params.labels){
  queryString = growQueryString("labels",params.labels,queryString);
} 

if(params.with_labels_details){
  queryString = growQueryString("with_labels_details",params.with_labels_details,queryString);
} 

if(params.milestone){
  queryString = growQueryString("milestone",params.milestone,queryString);
} 

if(params.scope){
  queryString = growQueryString("scope",params.scope,queryString);
} 

if(params.author_id){
  queryString = growQueryString("author_id",params.author_id,queryString);
} 

if(params.author_username){
  queryString = growQueryString("author_username",params.author_username,queryString);
} 

if(params.assignee_id){
  queryString = growQueryString("assignee_id",params.assignee_id,queryString);
} 

if(params.assignee_username){
  try{
    //Gitlab Community Edition uses a single element array
    var assignee_username_array =  JSON.parse(params.assignee_username);
    queryString = growQueryString("assignee_username",assignee_username_array[0],queryString);
  }catch(err){
    //Gitlab Enterprise uses plain string
    queryString = growQueryString("assignee_username",params.assignee_username,queryString);
  }
} 

if(params.my_reaction_emoji){
  queryString = growQueryString("my_reaction_emoji",params.my_reaction_emoji,queryString);
} 

if(params.weight ){
  queryString = growQueryString("weight",params.weight,queryString);
} 

if(params.order_by){
  queryString = growQueryString("order_by",params.order_by,queryString);
} 

if(params.sort){
  queryString = growQueryString("sort",params.sort,queryString);
} 

if(params.search){
  queryString = growQueryString("search",params.search,queryString);
} 

if(params.search_in){
  queryString = growQueryString("in",params.search_in,queryString);
} 

if(params.created_after){
  queryString = growQueryString("created_after",params.created_after,queryString);
} 

if(params.created_before){
  queryString = growQueryString("created_before",params.created_before,queryString);
}

if(params.updated_after){
  queryString = growQueryString("updated_after",params.updated_after,queryString);
} 

if(params.updated_before){
  queryString = growQueryString("updated_before",params.updated_before,queryString);
} 

if(params.confidential){
  queryString = growQueryString("confidential",params.confidential,queryString);
} 

if(params.not){
  queryString = growQueryString("not",params.not,queryString);
} 

const request = require("request");
const request_promise = require("request-promise");
try{
  this.resp = await request_promise({      
      uri: `https://gitlab.com/api/v4/projects/${params.id}/issues${queryString}`,
      headers: {
      Authorization:  `Bearer ${auths.gitlab.oauth_access_token}`
  }
  });  
}catch(err){
  this.err = err;
}