module Gitlab::Client::ProjectBadges

Defines methods related to project badges. @see docs.gitlab.com/ee/api/project_badges.html

Public Instance Methods

add_project_badge(project, options = {}) click to toggle source

Adds a badge to a project.

@example

Gitlab.add_project_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })

@param [Integer, String] project The ID or name of a project. @param [Hash] options A customizable set of options. @option options [String] :link_url(required) URL of the badge link @option options [String] :image_url(required) URL of the badge image @return [Gitlab::ObjectifiedHash] Information about the added project badge.

# File lib/gitlab/client/project_badges.rb, line 40
def add_project_badge(project, options = {})
  post("/projects/#{url_encode project}/badges", body: options)
end
edit_project_badge(project, badge_id, options = {}) click to toggle source

Updates a badge of a project..

@example

Gitlab.edit_project_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })

@param [Integer, String] project The ID or name of a project. @param [Integer] badge_id The badge ID. @param [Hash] options A customizable set of options. @option options [String] :link_url(optional) URL of the badge link @option options [String] :image_url(optional) URL of the badge image @return [Gitlab::ObjectifiedHash] Information about the updated project badge.

# File lib/gitlab/client/project_badges.rb, line 55
def edit_project_badge(project, badge_id, options = {})
  put("/projects/#{url_encode project}/badges/#{badge_id}", body: options)
end
preview_project_badge(project, link_url, image_url) click to toggle source

Preview a badge from a project.

@example

Gitlab.preview_project_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1')

@param [Integer, String] project The ID or name of a project. @param [String] :link_url URL of the badge link @param [String] :image_url URL of the badge image @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.

# File lib/gitlab/client/project_badges.rb, line 80
def preview_project_badge(project, link_url, image_url)
  query = { link_url: link_url, image_url: image_url }
  get("/projects/#{url_encode project}/badges/render", query: query)
end
project_badge(project, badge_id) click to toggle source

Gets a badge of a project.

@example

Gitlab.project_badge(5, 42)

@param [Integer, String] project The ID or name of a project. @param [Integer] badge_id The badge ID. @return [Gitlab::ObjectifiedHash] Information about the requested badge

# File lib/gitlab/client/project_badges.rb, line 26
def project_badge(project, badge_id)
  get("/projects/#{url_encode project}/badges/#{badge_id}")
end
project_badges(project) click to toggle source

Gets a list of a projects badges and its group badges.

@example

Gitlab.project_badges(5)

@param [Integer, String] project The ID or name of a project. @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a project

# File lib/gitlab/client/project_badges.rb, line 14
def project_badges(project)
  get("/projects/#{url_encode project}/badges")
end
remove_project_badge(project, badge_id) click to toggle source

Removes a badge from a project. Only projects badges will be removed by using this endpoint.

@example

Gitlab.remove_project_badge(5, 42)

@param [Integer, String] project The ID or name of a project. @param [Integer] badge_id The badge ID. @return [nil] This API call returns an empty response body.

# File lib/gitlab/client/project_badges.rb, line 67
def remove_project_badge(project, badge_id)
  delete("/projects/#{url_encode project}/badges/#{badge_id}")
end