summaryrefslogtreecommitdiff
path: root/scripts/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 21:13:05 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 21:13:05 +0000
commit58acbd41a1ee5aa51777f2ef88ce03bd698530c7 (patch)
tree3dc36a5296cf53123f494a49892cbb8267d31907 /scripts/api
parentad1e76fb4d1392c890c8b5e218a256a416d5a50b (diff)
downloadgitlab-ce-58acbd41a1ee5aa51777f2ef88ce03bd698530c7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/api')
-rw-r--r--scripts/api/update_issue.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/api/update_issue.rb b/scripts/api/update_issue.rb
new file mode 100644
index 00000000000..ce296ebc358
--- /dev/null
+++ b/scripts/api/update_issue.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'gitlab'
+require_relative 'default_options'
+
+class UpdateIssue
+ def initialize(options)
+ @project = options.fetch(:project)
+
+ # Force the token to be a string so that if api_token is nil, it's set to '',
+ # allowing unauthenticated requests (for forks).
+ api_token = options.delete(:api_token).to_s
+
+ warn "No API token given." if api_token.empty?
+
+ @client = Gitlab.client(
+ endpoint: options.delete(:endpoint) || API::DEFAULT_OPTIONS[:endpoint],
+ private_token: api_token
+ )
+ end
+
+ def execute(issue_iid, issue_data)
+ client.edit_issue(project, issue_iid, issue_data)
+ end
+
+ private
+
+ attr_reader :project, :client
+end