Class: SupportOps::GitLab::Events
- Defined in:
- lib/support_ops_gitlab/gitlab/events.rb
Overview
Document attribute definitions
List all events > docs.gitlab.com/api/events/#list-all-events
Defines the class Events within the module SupportOps::GitLab.
Instance Attribute Summary collapse
-
#action_name ⇒ String
The current value of action_name.
-
#author ⇒ Hash
The current value of author.
-
#author_id ⇒ Integer
The current value of author_id.
-
#author_username ⇒ String
The current value of author_username.
-
#created_at ⇒ String
The current value of created_at.
-
#id ⇒ Integer
The current value of id.
-
#imported ⇒ Boolean
The current value of imported.
-
#imported_from ⇒ String
The current value of imported_from.
-
#project_id ⇒ Integer
The current value of project_id.
-
#target_id ⇒ Integer
The current value of target_id.
-
#target_iid ⇒ Integer
The current value of target_iid.
-
#target_title ⇒ String
The current value of target_title.
-
#target_type ⇒ String
The current value of target_type.
-
#title ⇒ String
The current value of title.
Class Method Summary collapse
-
.list(key: value) ⇒ Array
List all visible events for a project.
-
.list(key: value) ⇒ Array
Get contribution events for a user.
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
#action_name ⇒ String
Returns the current value of action_name.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def action_name @action_name end |
#author ⇒ Hash
Returns the current value of author.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def @author end |
#author_id ⇒ Integer
Returns the current value of author_id.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def @author_id end |
#author_username ⇒ String
Returns the current value of author_username.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def @author_username end |
#created_at ⇒ String
Returns the current value of created_at.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def created_at @created_at end |
#id ⇒ Integer
Returns the current value of id.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def id @id end |
#imported ⇒ Boolean
Returns the current value of imported.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def imported @imported end |
#imported_from ⇒ String
Returns the current value of imported_from.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def imported_from @imported_from end |
#project_id ⇒ Integer
Returns the current value of project_id.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def project_id @project_id end |
#target_id ⇒ Integer
Returns the current value of target_id.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def target_id @target_id end |
#target_iid ⇒ Integer
Returns the current value of target_iid.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def target_iid @target_iid end |
#target_title ⇒ String
Returns the current value of target_title.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def target_title @target_title end |
#target_type ⇒ String
Returns the current value of target_type.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def target_type @target_type end |
#title ⇒ String
Returns the current value of title.
28 29 30 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 28 def title @title end |
Class Method Details
.list(key: value) ⇒ Array
List all visible events for a project
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 140 def self.list_project(**args) raise 'You have to provide a project_id' if args[:project_id].nil? args[:action] = nil unless args[:action] args[:after] = nil unless args[:after] args[:before] = nil unless args[:before] args[:sort] = nil unless args[:sort] args[:target_type] = nil unless args[:target_type] params = '' params += "action=#{args[:action]}&" unless args[:action].nil? params += "after=#{args[:after]}&" unless args[:after].nil? params += "before=#{args[:before]}&" unless args[:before].nil? params += "sort=#{args[:sort]}&" unless args[:sort].nil? params += "target_type=#{args[:target_type]}&" unless args[:target_type].nil? array = [] page = 1 loop do response = client.connection.get("projects/#{args[:project_id]}/events?#{params}&page=#{page}&per_page=100") body = Oj.load(response.body) array += body.map { |e| Events.new(e) } break if body.count < 100 page += 1 end array end |
.list(key: value) ⇒ Array
Get contribution events for a user
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 |
# File 'lib/support_ops_gitlab/gitlab/events.rb', line 76 def self.list_user(**args) raise 'You have to provide a user_id' if args[:user_id].nil? args[:action] = nil unless args[:action] args[:after] = nil unless args[:after] args[:before] = nil unless args[:before] args[:sort] = nil unless args[:sort] args[:target_type] = nil unless args[:target_type] params = '' params += "action=#{args[:action]}&" unless args[:action].nil? params += "after=#{args[:after]}&" unless args[:after].nil? params += "before=#{args[:before]}&" unless args[:before].nil? params += "sort=#{args[:sort]}&" unless args[:sort].nil? params += "target_type=#{args[:target_type]}&" unless args[:target_type].nil? array = [] page = 1 loop do response = client.connection.get("users/#{args[:user_id]}/events?#{params}&page=#{page}&per_page=100") body = Oj.load(response.body) array += body.map { |e| Events.new(e) } break if body.count < 100 page += 1 end array end |