Class: SupportOps::GitLab::Badges
- Defined in:
- lib/support_ops_gitlab/gitlab/badges.rb
Overview
Get a badge of a project > docs.gitlab.com/api/project_badges/#get-a-badge-of-a-project
Get a badge of a group > docs.gitlab.com/api/group_badges/#get-a-badge-of-a-group
Preview a badge from a project > docs.gitlab.com/api/project_badges/#preview-a-badge-from-a-project
Preview a badge from a group > docs.gitlab.com/api/group_badges/#preview-a-badge-from-a-group
Defines the class Badges within the module SupportOps::GitLab.
Instance Attribute Summary collapse
-
#group_id ⇒ Integer
The ID of the group the badge is in.
-
#id ⇒ Integer
The ID of the badge.
-
#image_url ⇒ String
URL of the badge image.
-
#kind ⇒ String
The type of badge it is (project or group).
-
#link_url ⇒ String
URL of the badge link.
-
#name ⇒ String
Name of the badge.
-
#project_id ⇒ Integer
The ID of the project the badge is in.
-
#rendered_image_url ⇒ String
The URL of the rendered badge image.
-
#rendered_link_url ⇒ String
The URL of the rendered badge link.
Class Method Summary collapse
-
.list(**args) ⇒ Array
List all badges.
Instance Method Summary collapse
-
#delete! ⇒ Boolean
Deletes a badge.
-
#save! ⇒ Object
Creates/updates a badge.
Methods inherited from Base
#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #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!, #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
#group_id ⇒ Integer
The ID of the group the badge is in
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def group_id @group_id end |
#id ⇒ Integer
The ID of the badge
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def id @id end |
#image_url ⇒ String
URL of the badge image
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def image_url @image_url end |
#kind ⇒ String
The type of badge it is (project or group)
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def kind @kind end |
#link_url ⇒ String
URL of the badge link
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def link_url @link_url end |
#name ⇒ String
Name of the badge
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def name @name end |
#project_id ⇒ Integer
The ID of the project the badge is in
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def project_id @project_id end |
#rendered_image_url ⇒ String
The URL of the rendered badge image
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def rendered_image_url @rendered_image_url end |
#rendered_link_url ⇒ String
The URL of the rendered badge link
25 26 27 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 25 def rendered_link_url @rendered_link_url end |
Class Method Details
.list(**args) ⇒ Array
List all badges
overload list(key: value)
@param group_id [Integer semi-optional] The ID of the group to get
badges from
@param name [String optional] Name of the badges to return
(case-sensitive)
@param project_id [Integer semi-optional] The ID of the project to get
badges from
#see
https://docs.gitlab.com/api/group_badges/#list-all-badges-of-a-group
GitLab API > Groups > Badges > List all badges of a group
#see
https://docs.gitlab.com/api/project_badges/#list-all-badges-of-a-project
GitLab API > Project > Badges > List all badges of a project
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 142 def self.list(**args) args[:group_id] = nil unless args[:group_id] args[:project_id] = nil unless args[:project_id] args[:name] = nil unless args[:name] params = '' params += "name=#{args[:name]}&" unless args[:name].nil? url = if args[:group_id].nil? && !args[:project_id].nil? "projects/#{args[:project_id]}/badges" elsif !args[:group_id].nil? && args[:project_id].nil? "groups/#{args[:group_id]}/badges" else raise 'You have to provide a group_id or a project_id (and you cannot provide both)' end array = [] page = 1 loop do response = client.connection.get("#{url}?#{params}&page=#{page}&per_page=100") body = Oj.load(response.body) array += body.map do |b| if args[:group_id].nil? && !args[:project_id].nil? b['project_id'] = args[:project_id] elsif !args[:group_id].nil? && args[:project_id].nil? b['group_id'] = args[:group_id] else raise 'You have to provide a group_id or a project_id (and you cannot provide both)' end Badges.new(b) end break if body.count < 100 page += 1 end array end |
Instance Method Details
#delete! ⇒ Boolean
This is inherited from SupportOps::GitLab::Base#delete!
Deletes a badge
24 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 24 def delete!; end |
#save! ⇒ Object
This is inherited from SupportOps::GitLab::Base#save!
Creates/updates a badge
53 |
# File 'lib/support_ops_gitlab/gitlab/badges.rb', line 53 def save!; end |