Module: Gitlab::Client::GroupBadges

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/group_badges.rb

Overview

Defines methods related to group badges.

Instance Method Summary collapse

Instance Method Details

#add_group_badge(group, options = {}) ⇒ Gitlab::ObjectifiedHash

Adds a badge to a group.

Examples:

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

Parameters:

  • group(required) (Integer, String)

    The ID or URL-encoded path of the group owned by the authenticated user.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :link_url(required) (String)

    URL of the badge link

  • :image_url(required) (String)

    URL of the badge image

Returns:

 43 44 45
# File 'lib/gitlab/client/group_badges.rb', line 43 def add_group_badge(group, options = {}) post("/groups/#{url_encode group}/badges", body: options) end

#edit_group_badge(group, badge_id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates a badge of a group.

Examples:

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

Parameters:

  • group(required) (Integer, String)

    The ID or URL-encoded path of the group owned by the authenticated user.

  • badge_id(required) (Integer)

    The badge ID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :link_url(optional) (String)

    URL of the badge link

  • :image_url(optional) (String)

    URL of the badge image

Returns:

 58 59 60
# File 'lib/gitlab/client/group_badges.rb', line 58 def edit_group_badge(group, badge_id, options = {}) put("/groups/#{url_encode group}/badges/#{badge_id}", body: options) end

#group_badge(group, badge_id) ⇒ Gitlab::ObjectifiedHash

Gets a badge of a group.

Examples:

Gitlab.group_badge(5, 42)

Parameters:

  • group(required) (Integer, String)

    The ID or URL-encoded path of the group owned by the authenticated user.

  • badge_id(required) (Integer)

    The badge ID.

Returns:

 29 30 31
# File 'lib/gitlab/client/group_badges.rb', line 29 def group_badge(group, badge_id) get("/groups/#{url_encode group}/badges/#{badge_id}") end

#group_badges(group, name = nil) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of a groups badges.

Examples:

Gitlab.group_badges(5) Gitlab.group_badges(5, 'Coverage')

Parameters:

  • group(required) (Integer, String)

    The ID or URL-encoded path of the group owned by the authenticated user.

  • name(optional) (String)

    Name of the badges to return (case-sensitive).

Returns:

 16 17 18 19
# File 'lib/gitlab/client/group_badges.rb', line 16 def group_badges(group, name = nil) query = { name: name } if name get("/groups/#{url_encode group}/badges", query: query) end

#preview_group_badge(group, link_url, image_url) ⇒ Gitlab::ObjectifiedHash

Preview a badge from a group.

Examples:

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

Parameters:

  • group(required) (Integer, String)

    The ID or URL-encoded path of the group owned by the authenticated user.

  • :link_url(required) (String)

    URL of the badge link

  • :image_url(required) (String)

    URL of the badge image

Returns:

  • (Gitlab::ObjectifiedHash)

    Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.

 83 84 85 86
# File 'lib/gitlab/client/group_badges.rb', line 83 def preview_group_badge(group, link_url, image_url) query = { link_url: link_url, image_url: image_url } get("/groups/#{url_encode group}/badges/render", query: query) end

#remove_group_badge(group, badge_id) ⇒ nil

Removes a badge from a group.

Examples:

Gitlab.remove_group_badge(5, 42)

Parameters:

  • group(required) (Integer, String)

    The ID or URL-encoded path of the group owned by the authenticated user.

  • badge_id(required) (Integer)

    The badge ID.

Returns:

  • (nil)

    This API call returns an empty response body.

 70 71 72
# File 'lib/gitlab/client/group_badges.rb', line 70 def remove_group_badge(group, badge_id) delete("/groups/#{url_encode group}/badges/#{badge_id}") end