Module: BacklogKit::Client::Project

Included in:
BacklogKit::Client
Defined in:
lib/backlog_kit/client/project.rb

Overview

Methods for the Project API

Instance Method Summary collapse

Instance Method Details

#add_category(project_id_or_key, name) ⇒ BacklogKit::Response

Add a category to a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • name (String)

    Category name

Returns:



196
197
198
# File 'lib/backlog_kit/client/project.rb', line 196

def add_category(project_id_or_key, name)
  post("projects/#{project_id_or_key}/categories", name: name)
end

#add_issue_type(project_id_or_key, name, color) ⇒ BacklogKit::Response

Add an issue type to a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • name (String)

    Issue type name

  • color (String)

    Background color of the issue type

Returns:



159
160
161
# File 'lib/backlog_kit/client/project.rb', line 159

def add_issue_type(project_id_or_key, name, color)
  post("projects/#{project_id_or_key}/issueTypes", name: name, color: color)
end

#add_project_admin_auth(project_id_or_key, user_id) ⇒ BacklogKit::Response

Add Project Administrator role to a user

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • user_id (Integer, String)

    User id

Returns:



132
133
134
# File 'lib/backlog_kit/client/project.rb', line 132

def add_project_admin_auth(project_id_or_key, user_id)
  post("projects/#{project_id_or_key}/administrators", user_id: user_id)
end

#add_project_team(project_id_or_key, team_id) ⇒ BacklogKit::Response

Add a team to a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • team_id (Integer, String)

    Team id

Returns:



80
81
82
# File 'lib/backlog_kit/client/project.rb', line 80

def add_project_team(project_id_or_key, team_id)
  post("projects/#{project_id_or_key}/teams", team_id: team_id)
end

#add_project_user(project_id_or_key, user_id) ⇒ BacklogKit::Response

Add a user to a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • user_id (Integer, String)

    User id

Returns:



106
107
108
# File 'lib/backlog_kit/client/project.rb', line 106

def add_project_user(project_id_or_key, user_id)
  post("projects/#{project_id_or_key}/users", user_id: user_id)
end

#add_pull_request_comment(project_id_or_key, repository_id_or_name, pull_request_number, params = {}) ⇒ BacklogKit::Response

Add a comment to a pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



409
410
411
# File 'lib/backlog_kit/client/project.rb', line 409

def add_pull_request_comment(project_id_or_key, repository_id_or_name, pull_request_number, params = {})
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/comments", params)
end

#add_version(project_id_or_key, name, params = {}) ⇒ BacklogKit::Response

Add a version to a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • name (String)

    Version name

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



233
234
235
236
# File 'lib/backlog_kit/client/project.rb', line 233

def add_version(project_id_or_key, name, params = {})
  params[:name] = name
  post("projects/#{project_id_or_key}/versions", params)
end

#add_webhook(project_id_or_key, name, hook_url, params = {}) ⇒ BacklogKit::Response

Add a webhook to a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • name (String)

    Webhook name

  • hook_url (String)

    Webhook URL

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



308
309
310
311
312
# File 'lib/backlog_kit/client/project.rb', line 308

def add_webhook(project_id_or_key, name, hook_url, params = {})
  params[:name] = name
  params[:hook_url] = hook_url
  post("projects/#{project_id_or_key}/webhooks", params)
end

#create_project(key, name, params = {}) ⇒ BacklogKit::Response

Create a new project

Parameters:

  • key (String)

    Project key

  • name (String)

    Project name

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



27
28
29
30
31
# File 'lib/backlog_kit/client/project.rb', line 27

def create_project(key, name, params = {})
  params[:key] = key
  params[:name] = name
  post('projects', params)
end

#create_pull_request(project_id_or_key, repository_id_or_name, params = {}) ⇒ BacklogKit::Response

Create a new pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



367
368
369
# File 'lib/backlog_kit/client/project.rb', line 367

def create_pull_request(project_id_or_key, repository_id_or_name, params = {})
  post("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests", params)
end

#delete_project(project_id_or_key) ⇒ BacklogKit::Response

Delete a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



46
47
48
# File 'lib/backlog_kit/client/project.rb', line 46

def delete_project(project_id_or_key)
  delete("projects/#{project_id_or_key}")
end

#download_project_icon(project_id_or_key) ⇒ BacklogKit::Response

Download a project icon image

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



54
55
56
# File 'lib/backlog_kit/client/project.rb', line 54

def download_project_icon(project_id_or_key)
  get("projects/#{project_id_or_key}/image")
end

#download_pull_request_attachment(project_id_or_key, repository_id_or_name, pull_request_number, attachment_id) ⇒ BacklogKit::Response

Download an attachment file on pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

  • attachment_id (Integer, String)

    Attachment file id

Returns:



442
443
444
# File 'lib/backlog_kit/client/project.rb', line 442

def download_pull_request_attachment(project_id_or_key, repository_id_or_name, pull_request_number, attachment_id)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/attachments/#{attachment_id}")
end

#download_shared_file(project_id_or_key, file_id) ⇒ BacklogKit::Response

Download a shared file

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • file_id (Integer, String)

    Shared file id

Returns:



272
273
274
# File 'lib/backlog_kit/client/project.rb', line 272

def download_shared_file(project_id_or_key, file_id)
  get("projects/#{project_id_or_key}/files/#{file_id}")
end

#get_categories(project_id_or_key) ⇒ BacklogKit::Response

Get list of categories

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



187
188
189
# File 'lib/backlog_kit/client/project.rb', line 187

def get_categories(project_id_or_key)
  get("projects/#{project_id_or_key}/categories")
end

#get_issue_types(project_id_or_key) ⇒ BacklogKit::Response

Get list of issue types

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



149
150
151
# File 'lib/backlog_kit/client/project.rb', line 149

def get_issue_types(project_id_or_key)
  get("projects/#{project_id_or_key}/issueTypes")
end

#get_project(project_id_or_key) ⇒ BacklogKit::Response

Get a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



17
18
19
# File 'lib/backlog_kit/client/project.rb', line 17

def get_project(project_id_or_key)
  get("projects/#{project_id_or_key}")
end

#get_project_activities(project_id_or_key, params = {}) ⇒ BacklogKit::Response

Get list of project activities

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



63
64
65
# File 'lib/backlog_kit/client/project.rb', line 63

def get_project_activities(project_id_or_key, params = {})
  get("projects/#{project_id_or_key}/activities", params)
end

#get_project_administrators(project_id_or_key) ⇒ BacklogKit::Response

Get list of users who has Project Administrator role

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



123
124
125
# File 'lib/backlog_kit/client/project.rb', line 123

def get_project_administrators(project_id_or_key)
  get("projects/#{project_id_or_key}/administrators")
end

#get_project_disk_usage(project_id_or_key) ⇒ BacklogKit::Response

Get disk usage

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



280
281
282
# File 'lib/backlog_kit/client/project.rb', line 280

def get_project_disk_usage(project_id_or_key)
  get("projects/#{project_id_or_key}/diskUsage")
end

#get_project_teams(project_id_or_key) ⇒ BacklogKit::Response

Get list of project teams

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



71
72
73
# File 'lib/backlog_kit/client/project.rb', line 71

def get_project_teams(project_id_or_key)
  get("projects/#{project_id_or_key}/teams")
end

#get_project_users(project_id_or_key) ⇒ BacklogKit::Response

Get list of project members

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



97
98
99
# File 'lib/backlog_kit/client/project.rb', line 97

def get_project_users(project_id_or_key)
  get("projects/#{project_id_or_key}/users")
end

#get_projects(params = {}) ⇒ BacklogKit::Response

Get list of projects

Parameters:

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



9
10
11
# File 'lib/backlog_kit/client/project.rb', line 9

def get_projects(params = {})
  get('projects', params)
end

#get_pull_request(project_id_or_key, repository_id_or_name, pull_request_number) ⇒ BacklogKit::Response

Get a pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

Returns:



357
358
359
# File 'lib/backlog_kit/client/project.rb', line 357

def get_pull_request(project_id_or_key, repository_id_or_name, pull_request_number)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}")
end

#get_pull_request_attachments(project_id_or_key, repository_id_or_name, pull_request_number) ⇒ BacklogKit::Response

Get list of attachment files on pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

Returns:



431
432
433
# File 'lib/backlog_kit/client/project.rb', line 431

def get_pull_request_attachments(project_id_or_key, repository_id_or_name, pull_request_number)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/attachments")
end

#get_pull_request_comment_count(project_id_or_key, repository_id_or_name, pull_request_number) ⇒ BacklogKit::Response

Get number of comments in pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

Returns:



398
399
400
# File 'lib/backlog_kit/client/project.rb', line 398

def get_pull_request_comment_count(project_id_or_key, repository_id_or_name, pull_request_number)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/comments/count")
end

#get_pull_request_comments(project_id_or_key, repository_id_or_name, pull_request_number) ⇒ BacklogKit::Response

Get list of comments in pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

Returns:



388
389
390
# File 'lib/backlog_kit/client/project.rb', line 388

def get_pull_request_comments(project_id_or_key, repository_id_or_name, pull_request_number)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/comments")
end

#get_pull_request_count(project_id_or_key, repository_id_or_name) ⇒ BacklogKit::Response

Get number of pull requests

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

Returns:



347
348
349
# File 'lib/backlog_kit/client/project.rb', line 347

def get_pull_request_count(project_id_or_key, repository_id_or_name)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/count")
end

#get_pull_requests(project_id_or_key, repository_id_or_name) ⇒ BacklogKit::Response

Get list of pull requests

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

Returns:



338
339
340
# File 'lib/backlog_kit/client/project.rb', line 338

def get_pull_requests(project_id_or_key, repository_id_or_name)
  get("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests")
end

#get_shared_files(project_id_or_key, directory_path = '', params = {}) ⇒ BacklogKit::Response

Get list of shared files

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • directory_path (String) (defaults to: '')

    Directory path

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



263
264
265
# File 'lib/backlog_kit/client/project.rb', line 263

def get_shared_files(project_id_or_key, directory_path = '', params = {})
  get("projects/#{project_id_or_key}/files/metadata/#{directory_path}", params)
end

#get_versions(project_id_or_key) ⇒ BacklogKit::Response

Get list of versions

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



223
224
225
# File 'lib/backlog_kit/client/project.rb', line 223

def get_versions(project_id_or_key)
  get("projects/#{project_id_or_key}/versions")
end

#get_webhook(project_id_or_key, webhook_id) ⇒ BacklogKit::Response

Get a webhook

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • webhook_id (Integer, String)

    Webhook id

Returns:



297
298
299
# File 'lib/backlog_kit/client/project.rb', line 297

def get_webhook(project_id_or_key, webhook_id)
  get("projects/#{project_id_or_key}/webhooks/#{webhook_id}")
end

#get_webhooks(project_id_or_key) ⇒ BacklogKit::Response

Get list of webhooks

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

Returns:



288
289
290
# File 'lib/backlog_kit/client/project.rb', line 288

def get_webhooks(project_id_or_key)
  get("projects/#{project_id_or_key}/webhooks")
end

#remove_category(project_id_or_key, category_id) ⇒ BacklogKit::Response

Remove a category from project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • category_id (Integer, String)

    Category id

Returns:



215
216
217
# File 'lib/backlog_kit/client/project.rb', line 215

def remove_category(project_id_or_key, category_id)
  delete("projects/#{project_id_or_key}/categories/#{category_id}")
end

#remove_issue_type(project_id_or_key, type_id, substitute_type_id) ⇒ BacklogKit::Response

Remove an issue type from project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • type_id (Integer, String)

    Issue type id

  • substitute_type_id (Integer, String)

    Issue type id to change linked issue

Returns:



179
180
181
# File 'lib/backlog_kit/client/project.rb', line 179

def remove_issue_type(project_id_or_key, type_id, substitute_type_id)
  delete("projects/#{project_id_or_key}/issueTypes/#{type_id}", substitute_issue_type_id: substitute_type_id)
end

#remove_project_admin_auth(project_id_or_key, user_id) ⇒ BacklogKit::Response

Remove Project Administrator role from user

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • user_id (Integer, String)

    User id

Returns:



141
142
143
# File 'lib/backlog_kit/client/project.rb', line 141

def remove_project_admin_auth(project_id_or_key, user_id)
  delete("projects/#{project_id_or_key}/administrators", user_id: user_id)
end

#remove_project_team(project_id_or_key, team_id) ⇒ BacklogKit::Response

Remove a team from project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • team_id (Integer, String)

    Team id

Returns:



89
90
91
# File 'lib/backlog_kit/client/project.rb', line 89

def remove_project_team(project_id_or_key, team_id)
  delete("projects/#{project_id_or_key}/teams", team_id: team_id)
end

#remove_project_user(project_id_or_key, user_id) ⇒ BacklogKit::Response

Remove a user from project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • user_id (Integer, String)

    User id

Returns:



115
116
117
# File 'lib/backlog_kit/client/project.rb', line 115

def remove_project_user(project_id_or_key, user_id)
  delete("projects/#{project_id_or_key}/users", user_id: user_id)
end

#remove_pull_request_attachment(project_id_or_key, repository_id_or_name, pull_request_number, attachment_id) ⇒ BacklogKit::Response

Remove an attachment file from pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

  • attachment_id (Integer, String)

    Attachment file id

Returns:



453
454
455
# File 'lib/backlog_kit/client/project.rb', line 453

def remove_pull_request_attachment(project_id_or_key, repository_id_or_name, pull_request_number, attachment_id)
  delete("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/attachments/#{attachment_id}")
end

#remove_version(project_id_or_key, version_id) ⇒ BacklogKit::Response

Remove a version from project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • version_id (Integer, String)

    Version id

Returns:



253
254
255
# File 'lib/backlog_kit/client/project.rb', line 253

def remove_version(project_id_or_key, version_id)
  delete("projects/#{project_id_or_key}/versions/#{version_id}")
end

#remove_webhook(project_id_or_key, webhook_id) ⇒ BacklogKit::Response

Remove a webhook from project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • webhook_id (Integer, String)

    Webhook id

Returns:



329
330
331
# File 'lib/backlog_kit/client/project.rb', line 329

def remove_webhook(project_id_or_key, webhook_id)
  delete("projects/#{project_id_or_key}/webhooks/#{webhook_id}")
end

#update_category(project_id_or_key, category_id, name) ⇒ BacklogKit::Response

Update a category

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • category_id (Integer, String)

    Category id

  • name (String)

    Category name

Returns:



206
207
208
# File 'lib/backlog_kit/client/project.rb', line 206

def update_category(project_id_or_key, category_id, name)
  patch("projects/#{project_id_or_key}/categories/#{category_id}", name: name)
end

#update_issue_type(project_id_or_key, type_id, params = {}) ⇒ BacklogKit::Response

Update an issue type

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • type_id (Integer, String)

    Issue type id

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



169
170
171
# File 'lib/backlog_kit/client/project.rb', line 169

def update_issue_type(project_id_or_key, type_id, params = {})
  patch("projects/#{project_id_or_key}/issueTypes/#{type_id}", params)
end

#update_project(project_id_or_key, params = {}) ⇒ BacklogKit::Response

Update a project

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



38
39
40
# File 'lib/backlog_kit/client/project.rb', line 38

def update_project(project_id_or_key, params = {})
  patch("projects/#{project_id_or_key}", params)
end

#update_pull_request(project_id_or_key, repository_id_or_name, pull_request_number, params = {}) ⇒ BacklogKit::Response

Update a pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



378
379
380
# File 'lib/backlog_kit/client/project.rb', line 378

def update_pull_request(project_id_or_key, repository_id_or_name, pull_request_number, params = {})
  patch("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}", params)
end

#update_pull_request_comment(project_id_or_key, repository_id_or_name, pull_request_number, comment_id, content) ⇒ BacklogKit::Response

Update a comment in pull request

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • repository_id_or_name (Integer, String)

    Repository id or repository name

  • pull_request_number (Integer, String)

    Pull request number

  • comment_id (Integer, String)

    Comment id

  • content (String)

    Content of the comment

Returns:



421
422
423
# File 'lib/backlog_kit/client/project.rb', line 421

def update_pull_request_comment(project_id_or_key, repository_id_or_name, pull_request_number, comment_id, content)
  patch("projects/#{project_id_or_key}/git/repositories/#{repository_id_or_name}/pullRequests/#{pull_request_number}/comments/#{comment_id}", content: content)
end

#update_version(project_id_or_key, version_id, params = {}) ⇒ BacklogKit::Response

Update a version

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • version_id (Integer, String)

    Version id

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



244
245
246
# File 'lib/backlog_kit/client/project.rb', line 244

def update_version(project_id_or_key, version_id, params = {})
  patch("projects/#{project_id_or_key}/versions/#{version_id}", params)
end

#update_webhook(project_id_or_key, webhook_id, params = {}) ⇒ BacklogKit::Response

Update a webhook

Parameters:

  • project_id_or_key (Integer, String)

    Project id or project key

  • webhook_id (Integer, String)

    Webhook id

  • params (Hash) (defaults to: {})

    Request parameters

Returns:



320
321
322
# File 'lib/backlog_kit/client/project.rb', line 320

def update_webhook(project_id_or_key, webhook_id, params = {})
  patch("projects/#{project_id_or_key}/webhooks/#{webhook_id}", params)
end