Class: Readiness::GitLab::ProjectWebhooks
- Inherits:
-
Client
- Object
- Client
- Readiness::GitLab::ProjectWebhooks
show all
- Defined in:
- lib/support_readiness/gitlab/project_webhooks.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
-
.create!(client, hook) ⇒ Object
Creates a project webhook within GitLab.
-
.delete!(client, hook) ⇒ Boolean
Deletes a project webhook within GitLab.
-
.events(client, hook, status = false) ⇒ Array
Lists project webhook events.
-
.find(client, project, hook_id) ⇒ Hash
Locates a project webhook within GitLab.
-
.find!(client, project, hook_id) ⇒ Hash
Locates a project webhook within GitLab.
-
.list(client, project) ⇒ Array
Lists webhooks for a project.
-
.update!(client, hook) ⇒ Object
Updates a project webhook within GitLab.
Instance Method Summary
collapse
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Constructor Details
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
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 30
def initialize(object = {})
@alert_status = object['alert_status']
@branch_filter_strategy = object['branch_filter_strategy']
@confidential_issues_events = object['confidential_issues_events']
@confidential_note_events = object['confidential_note_events']
@created_at = object['created_at']
@custom_headers = object['custom_headers']
@custom_webhook_template = object['custom_webhook_template']
@deployment_events = object['deployment_events']
@description = object['description']
@disabled_until = object['disabled_until']
@enable_ssl_verification = object['enable_ssl_verification']
@feature_flag_events = object['feature_flag_events']
@id = object['id']
@issues_events = object['issues_events']
@job_events = object['job_events']
@merge_requests_events = object['merge_requests_events']
@name = object['name']
@note_events = object['note_events']
@pipeline_events = object['pipeline_events']
@project_id = object['project_id']
@push_events = object['push_events']
@push_events_branch_filter = object['push_events_branch_filter']
@releases_events = object['releases_events']
@repository_update_events = object['repository_update_events']
@resource_access_token_events = object['resource_access_token_events']
@tag_push_events = object['tag_push_events']
@token = object['token']
@url = object['url']
@url_variables = object['url_variables']
@wiki_page_events = object['wiki_page_events']
end
|
Instance Attribute Details
#alert_status ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def alert_status
@alert_status
end
|
#branch_filter_strategy ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def branch_filter_strategy
@branch_filter_strategy
end
|
#confidential_issues_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def confidential_issues_events
@confidential_issues_events
end
|
#confidential_note_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def confidential_note_events
@confidential_note_events
end
|
#created_at ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def created_at
@created_at
end
|
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def
@custom_headers
end
|
#custom_webhook_template ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def custom_webhook_template
@custom_webhook_template
end
|
#deployment_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def deployment_events
@deployment_events
end
|
#description ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def description
@description
end
|
#disabled_until ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def disabled_until
@disabled_until
end
|
#enable_ssl_verification ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def enable_ssl_verification
@enable_ssl_verification
end
|
#feature_flag_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def feature_flag_events
@feature_flag_events
end
|
#id ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def id
@id
end
|
#issues_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def issues_events
@issues_events
end
|
#job_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def job_events
@job_events
end
|
#merge_requests_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def merge_requests_events
@merge_requests_events
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def name
@name
end
|
#note_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def note_events
@note_events
end
|
#pipeline_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def pipeline_events
@pipeline_events
end
|
#project_id ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def project_id
@project_id
end
|
#push_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def push_events
@push_events
end
|
#push_events_branch_filter ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def push_events_branch_filter
@push_events_branch_filter
end
|
#releases_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def releases_events
@releases_events
end
|
#repository_update_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def repository_update_events
@repository_update_events
end
|
#resource_access_token_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def resource_access_token_events
@resource_access_token_events
end
|
#tag_push_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def tag_push_events
@tag_push_events
end
|
#token ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def token
@token
end
|
#url ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def url
@url
end
|
#url_variables ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def url_variables
@url_variables
end
|
#wiki_page_events ⇒ Object
19
20
21
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 19
def wiki_page_events
@wiki_page_events
end
|
Class Method Details
.create!(client, hook) ⇒ Object
Creates a project webhook within GitLab. This will exit on error
216
217
218
219
220
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 216
def self.create!(client, hook)
response = client.connection.post "projects/#{hook.project_id}/hooks", to_clean_json(hook)
handle_request_error(1, 'GitLab', response.status, { action: 'Create webhook', id: hook.project_id }) unless response.status == 200
ProjectWebhooks.new(Oj.load(response.body))
end
|
.delete!(client, hook) ⇒ Boolean
Deletes a project webhook within GitLab. This will exit on error
268
269
270
271
272
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 268
def self.delete!(client, hook)
response = client.connection.delete "projects/#{hook.project_id}/hooks/#{hook.id}"
handle_request_error(1, 'GitLab', response.status, { action: 'Delete webhook', id: "#{hook.project_id}##{hook.id}" }) unless response.status == 2204
true
end
|
.events(client, hook, status = false) ⇒ Array
Lists project webhook events. Does not stop until it ends or the page limit is hit. This method can take a long time to run depending on the parameters used.
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 169
def self.events(client, hook, status = false)
root_url = if status
"projects/#{hook.project_id}/hooks/#{hood.id}/events?status=#{status}"
else
"projects/#{hook.project_id}/hooks/#{hood.id}/events?"
end
array = []
page = 1
loop do
response = client.connection.get "#{root_url}&per_page=100&page=#{page}"
handle_request_error(0, 'GitLab', response.status) unless response.status == 200
body = Oj.load(response.body)
array += body
break if body.count < 100
page += 1
end
array
end
|
.find(client, project, hook_id) ⇒ Hash
Locates a project webhook within GitLab. This will not exit on error (except Authentication errors)
107
108
109
110
111
112
113
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 107
def self.find(client, project, hook_id)
response = client.connection.get ""
handle_request_error(0, 'GitLab', response.status, { action: 'get', id: hook_id }) unless response.status == 200
return ProjectWebhooks.new(Oj.load(response.body)) if response.status == 200
Oj.load(response.body)
end
|
.find!(client, project, hook_id) ⇒ Hash
Locates a project webhook within GitLab. This will exit on error
132
133
134
135
136
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 132
def self.find!(client, project, hook_id)
response = client.connection.get ""
handle_request_error(1, 'GitLab', response.status, { action: 'Find webhook', id: "#{project.id}##{hook_id}" }) unless response.status == 200
ProjectWebhooks.new(Oj.load(response.body))
end
|
.list(client, project) ⇒ Array
Lists webhooks for a project.
81
82
83
84
85
86
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 81
def self.list(client, project)
response = client.connection.get "projects/#{project.id}/hooks"
handle_request_error(0, 'GitLab', response.status) unless response.status == 200
body = Oj.load(response.body)
body.map { |p| ProjectWebhooks.new(p) }
end
|
.update!(client, hook) ⇒ Object
Updates a project webhook within GitLab. This will exit on error
243
244
245
246
247
|
# File 'lib/support_readiness/gitlab/project_webhooks.rb', line 243
def self.update!(client, hook)
response = client.connection.put "project/#{hook.project_id}/hooks/#{hook.id}", to_clean_json(hook)
handle_request_error(1, 'GitLab', response.status, { action: 'Update webhook', id: "#{hook.project_id}##{hook.id}" }) unless response.status == 200
ProjectWebhooks.new(Oj.load(response.body))
end
|