Class: SupportOps::GitLab::Notes
- Defined in:
- lib/support_ops_gitlab/gitlab/notes.rb
Overview
Get single issue note => docs.gitlab.com/api/notes/#get-single-issue-note
Get single snippet note => docs.gitlab.com/api/notes/#get-single-snippet-note
Get single merge request note => docs.gitlab.com/api/notes/#get-single-merge-request-note
Get single epic note => docs.gitlab.com/api/notes/#get-single-epic-note
Get single wiki page note (projects) => docs.gitlab.com/api/notes/#get-single-wiki-page-note
Get single wiki page note (groups) => docs.gitlab.com/api/notes/#get-single-wiki-page-note-1
Create/update for notes other than Issue and MergeRequest
Document save!
Document delete!
Defines the class Notes within the module SupportOps::GitLab.
Instance Attribute Summary collapse
-
#author ⇒ Hash
Information about the author of a note.
-
#body ⇒ String
The content of a note.
-
#confidential ⇒ Boolean
If the note is confidential or not.
-
#created_at ⇒ String
The timestamp of when the note was created.
-
#id ⇒ Integer
The ID of the note.
-
#imported ⇒ Boolean
If the note was imported or not.
-
#imported_from ⇒ String
Where the note was imported from.
-
#internal ⇒ Boolean
If the note is internal or not.
-
#merge_request_diff_head_sha ⇒ String
The SHA of the head commit, which ensures the merge request wasn’t updated after the API request was sent.
-
#noteable_id ⇒ Integer
The ID of the item the note is attached to.
-
#noteable_iid ⇒ Integer
The IID of the item the note is attached to.
-
#noteable_type ⇒ String
The type of item the note is attached to.
-
#project_id ⇒ Integer
The project ID the note is within.
-
#resolvable ⇒ Boolean
If the note is resolvable or not.
-
#system ⇒ Boolean
If the note is from the system or not.
-
#updated_at ⇒ String
The timestamp of when the note was last updated.
Class Method Summary collapse
- .base_url(type, type_id, project_id = nil, group_id = nil) ⇒ Object
-
.list(key: value) ⇒ Array
Lists notes (comments).
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
#author ⇒ Hash
Information about the author of a note
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def @author end |
#body ⇒ String
The content of a note
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def body @body end |
#confidential ⇒ Boolean
If the note is confidential or not
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def confidential @confidential end |
#created_at ⇒ String
The timestamp of when the note was created
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def created_at @created_at end |
#id ⇒ Integer
The ID of the note
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def id @id end |
#imported ⇒ Boolean
If the note was imported or not
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def imported @imported end |
#imported_from ⇒ String
Where the note was imported from
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def imported_from @imported_from end |
#internal ⇒ Boolean
If the note is internal or not
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def internal @internal end |
#merge_request_diff_head_sha ⇒ String
The SHA of the head commit, which ensures the merge request wasn’t updated after the API request was sent
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def merge_request_diff_head_sha @merge_request_diff_head_sha end |
#noteable_id ⇒ Integer
The ID of the item the note is attached to
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def noteable_id @noteable_id end |
#noteable_iid ⇒ Integer
The IID of the item the note is attached to
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def noteable_iid @noteable_iid end |
#noteable_type ⇒ String
The type of item the note is attached to
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def noteable_type @noteable_type end |
#project_id ⇒ Integer
The project ID the note is within
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def project_id @project_id end |
#resolvable ⇒ Boolean
If the note is resolvable or not
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def resolvable @resolvable end |
#system ⇒ Boolean
If the note is from the system or not
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def system @system end |
#updated_at ⇒ String
The timestamp of when the note was last updated
37 38 39 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 37 def updated_at @updated_at end |
Class Method Details
.base_url(type, type_id, project_id = nil, group_id = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 48 def self.base_url(type, type_id, project_id = nil, group_id = nil) return "projects/#{project_id}/issues/#{type_id}/notes" if type == 'Issue' return "projects/#{project_id}/snippets/#{type_id}/notes" if type == 'Snippet' return "projects/#{project_id}/merge_requests/#{type_id}/notes" if type == 'MergeRequest' return "groups/#{group_id}/epics/#{type_id}/notes" if type == 'Epic' return "groups/#{group_id}/epics/#{type_id}/notes" if type == 'Epic' if type == 'WikiPage::Meta' return "projects/#{project_id}/wiki_pages/#{type_id}/notes" if group_id.nil? return "groups/#{project_id}/wiki_pages/#{type_id}/notes" if project_id.nil? end raise "Unable to determine based on type of '#{type}'" end |
.list(key: value) ⇒ Array
Lists notes (comments)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/support_ops_gitlab/gitlab/notes.rb', line 106 def self.list(**args) args[:type] = nil unless args[:type_id] args[:group_id] = nil unless args[:type_id] args[:project_id] = nil unless args[:type_id] args[:type_id] = nil unless args[:type_id] args[:limit] = 0 unless args[:limit] raise 'You must provide a type' if args[:type].nil? raise 'You must provide a type_id' if args[:type_id].nil? raise 'You must provide a project_id' if ['Issue', 'Snippet', 'MergeRequest', 'WikiPage::Meta'].include?(args[:type]) && args[:project_id].nil? raise 'You must provide a group_id' if ['Epic', 'WikiPage::Meta'].include?(args[:type]) && args[:group_id].nil? url = base_url(args[:type], args[:type_id], args[:project_id], args[:group_id]) array = [] page = 1 loop do response = client.connection.get("#{url}?page=#{page}&per_page=100") body = Oj.load(response.body) array += body.map { |n| Notes.new(n) } break if args[:limit].to_i.positive? && array.count >= args[:limit].to_i break if body.count < 100 end return array if args[:limit].to_i.zero? array.first(args[:limit].to_i) end |