Class: SupportOps::GitLab::ProjectWebhooks

Inherits:
Base
  • Object
show all
Defined in:
lib/support_ops_gitlab/gitlab/project_webhooks.rb

Overview

TODO:
TODO:

Document save!

TODO:

Document delete!

TODO:

Document events

Defines the class ProjectWebhooks within the module SupportOps::GitLab.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #delete!, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #notes, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #save!, #ssh_keys, #status, #store_original_attributes, #subscribe!, #support_pin, to_hash, #tokens, #unban!, #unblock!, #unsubscribe!, #webhooks

Constructor Details

This class inherits a constructor from SupportOps::GitLab::Base

Instance Attribute Details

#alert_statusString

Returns the current value of alert_status.

Returns:

  • (String)

    the current value of alert_status



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def alert_status
  @alert_status
end

#branch_filter_strategyString

Filter push events by branch; possible values are wildcard (default), regex, and all_branches

Returns:

  • (String)

    the current value of branch_filter_strategy



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def branch_filter_strategy
  @branch_filter_strategy
end

#confidential_issues_eventsBoolean

Returns the current value of confidential_issues_events.

Returns:

  • (Boolean)

    the current value of confidential_issues_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def confidential_issues_events
  @confidential_issues_events
end

#confidential_note_eventsBoolean

Returns the current value of confidential_note_events.

Returns:

  • (Boolean)

    the current value of confidential_note_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def confidential_note_events
  @confidential_note_events
end

#created_atString

Returns the current value of created_at.

Returns:

  • (String)

    the current value of created_at



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def created_at
  @created_at
end

#custom_headersArray

Returns the current value of custom_headers.

Returns:

  • (Array)

    the current value of custom_headers



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def custom_headers
  @custom_headers
end

#custom_webhook_templateString

Returns the current value of custom_webhook_template.

Returns:

  • (String)

    the current value of custom_webhook_template



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def custom_webhook_template
  @custom_webhook_template
end

#deployment_eventsBoolean

Returns the current value of deployment_events.

Returns:

  • (Boolean)

    the current value of deployment_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def deployment_events
  @deployment_events
end

#descriptionString

Returns the current value of description.

Returns:

  • (String)

    the current value of description



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def description
  @description
end

#disabled_untilString

Returns the current value of disabled_until.

Returns:

  • (String)

    the current value of disabled_until



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def disabled_until
  @disabled_until
end

#enable_ssl_verificationBoolean

Returns the current value of enable_ssl_verification.

Returns:

  • (Boolean)

    the current value of enable_ssl_verification



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def enable_ssl_verification
  @enable_ssl_verification
end

#feature_flag_eventsBoolean

Returns the current value of feature_flag_events.

Returns:

  • (Boolean)

    the current value of feature_flag_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def feature_flag_events
  @feature_flag_events
end

#idInteger

Returns the current value of id.

Returns:

  • (Integer)

    the current value of id



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def id
  @id
end

#issues_eventsBoolean

Returns the current value of issues_events.

Returns:

  • (Boolean)

    the current value of issues_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def issues_events
  @issues_events
end

#job_eventsBoolean

Returns the current value of job_events.

Returns:

  • (Boolean)

    the current value of job_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def job_events
  @job_events
end

#merge_requests_eventsBoolean

Returns the current value of merge_requests_events.

Returns:

  • (Boolean)

    the current value of merge_requests_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def merge_requests_events
  @merge_requests_events
end

#nameString

Returns the current value of name.

Returns:

  • (String)

    the current value of name



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def name
  @name
end

#note_eventsBoolean

Returns the current value of note_events.

Returns:

  • (Boolean)

    the current value of note_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def note_events
  @note_events
end

#pipeline_eventsBoolean

Returns the current value of pipeline_events.

Returns:

  • (Boolean)

    the current value of pipeline_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def pipeline_events
  @pipeline_events
end

#project_idInteger

Returns the current value of project_id.

Returns:

  • (Integer)

    the current value of project_id



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def project_id
  @project_id
end

#push_eventsBoolean

Returns the current value of push_events.

Returns:

  • (Boolean)

    the current value of push_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def push_events
  @push_events
end

#push_events_branch_filterString

Returns the current value of push_events_branch_filter.

Returns:

  • (String)

    the current value of push_events_branch_filter



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def push_events_branch_filter
  @push_events_branch_filter
end

#releases_eventsBoolean

Returns the current value of releases_events.

Returns:

  • (Boolean)

    the current value of releases_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def releases_events
  @releases_events
end

#repository_update_eventsBoolean

Returns the current value of repository_update_events.

Returns:

  • (Boolean)

    the current value of repository_update_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def repository_update_events
  @repository_update_events
end

#resource_access_token_eventsBoolean

Returns the current value of resource_access_token_events.

Returns:

  • (Boolean)

    the current value of resource_access_token_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def resource_access_token_events
  @resource_access_token_events
end

#tag_push_eventsBoolean

Returns the current value of tag_push_events.

Returns:

  • (Boolean)

    the current value of tag_push_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def tag_push_events
  @tag_push_events
end

#tokenString

Secret token to validate received payloads; the token isn’t returned in the response (creates/updates only)

Returns:

  • (String)

    the current value of token



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def token
  @token
end

#urlString

Returns the current value of url.

Returns:

  • (String)

    the current value of url



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def url
  @url
end

#url_variablesArray

Returns the current value of url_variables.

Returns:

  • (Array)

    the current value of url_variables



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def url_variables
  @url_variables
end

#wiki_page_eventsBoolean

Returns the current value of wiki_page_events.

Returns:

  • (Boolean)

    the current value of wiki_page_events



46
47
48
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 46

def wiki_page_events
  @wiki_page_events
end

Class Method Details

.get(object) ⇒ Object

Get a project webhook

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.com/api/v4'
  config.token = 'abc123'
end

webhook = SupportOps::GitLab::ProjectWebhooks.get(id: 123, project_id: 456)
pp webhook.name
# => "Awesome project webhook"

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



122
123
124
125
126
127
128
129
130
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 122

def self.get(object)
  if object.is_a? ProjectWebhooks
    ProjectWebhooks.new(id: id, project_id: project_id).find
  elsif object.is_a? Hash
    ProjectWebhooks.new({ id: object[:id], project_id: object[:project_id] }).find
  else
    raise 'You need an id and a project_id attribute'
  end
end

.get!(object) ⇒ Object

Get a project webhook

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.com/api/v4'
  config.token = 'abc123'
end

webhook = SupportOps::GitLab::ProjectWebhooks.get!(id: 123, project_id: 456)
pp webhook.name
# => "Awesome project webhook"

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



152
153
154
155
156
157
158
159
160
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 152

def self.get!(object)
  if object.is_a? ProjectWebhooks
    ProjectWebhooks.new(id: id, project_id: project_id).find!
  elsif object.is_a? Hash
    ProjectWebhooks.new({ id: object[:id], project_id: object[:project_id] }).find!
  else
    raise 'You need an id and a project_id attribute'
  end
end

.list(key: value) ⇒ Array

List webhooks for a project

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.example.com/api/v4'
  config.token = 'abc123'
end

webhooks = SupportOps::GitLab::ProjectWebhooks.list(project_id: 123)
pp webhooks.count
# => 11
pp webhooks.last.name
# => "Aweomse Project Webhook"

Parameters:

  • project_id (Integer required)

    The project ID to look in

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/support_ops_gitlab/gitlab/project_webhooks.rb', line 86

def self.list(**args)
  args[:project_id] = nil unless args[:project_id]
  raise 'You have to provide a project_id' if args[:project_id].nil?
  array = []
  page = 1
  loop do
    response = client.connection.get("projects/#{args[:args[:project_id]]}/hooks?per_page=100&page=#{page}")
    body = Oj.load(response.body)
    array += body.map { |w| ProjectWebhooks(w) }
    break if body.count < 100

    page += 1
  end
  array
end