File: project_release_links.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (76 lines) | stat: -rw-r--r-- 3,500 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# frozen_string_literal: true

class Gitlab::Client
  # Defines methods related to project release links.
  # @see https://docs.gitlab.com/ce/api/releases/links.html
  module ProjectReleaseLinks
    # Get assets as links from a Release.
    #
    # @example
    #   Gitlab.project_release_links(5, 'v0.3')
    #
    # @param [Integer, String] project The ID or name of a project.
    # @param [String] tag_name The tag associated with the Release.
    # @return [Array<Gitlab::ObjectifiedHash>] List of assets as links from a Release.
    def project_release_links(project, tag_name)
      get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links")
    end

    # Get an asset as link from a Release.
    #
    # @example
    #   Gitlab.project_release_link(5, 'v0.3', 1)
    #
    # @param [Integer, String] project The ID or name of a project.
    # @param [String] tag_name The tag associated with the Release.
    # @param [Integer] link_id The id of the link.
    # @return [Gitlab::ObjectifiedHash] Information about the release link
    def project_release_link(project, tag_name, link_id)
      get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
    end

    # Create an asset as a link from a Release.
    #
    # @example
    #   Gitlab.create_project_release_link(5, 'v0.1', { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
    #
    # @param [Integer, String] project The ID or name of a project.
    # @param [String] tag_name The tag associated with the Release.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :name(required)  The name of the link.
    # @option options [String] :url(required)  The URL of the link.
    # @return [Gitlab::ObjectifiedHash] Information about the created release link.
    def create_project_release_link(project, tag_name, options = {})
      post("/projects/#{url_encode project}/releases/#{tag_name}/assets/links", body: options)
    end

    # Update an asset as a link from a Release. You have to specify at least one of name or url
    #
    # @example
    #   Gitlab.update_project_release_link(5, 'v0.3', 1, { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
    #
    # @param [Integer, String] project The ID or name of a project.
    # @param [String] tag_name  The tag where the release will be created from.
    # @param [Integer] link_id The id of the link.
    # @param [Hash] options A customizable set of options.
    # @option options [String] :name(optional)  The name of the link.
    # @option options [String] :url(optional)  The URL of the link.
    # @return [Gitlab::ObjectifiedHash] Information about the updated release link.
    def update_project_release_link(project, tag_name, link_id, options = {})
      put("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}", body: options)
    end

    # Delete an asset as a link from a Release.
    #
    # @example
    #   Gitlab.delete_project_release_link(5, 'v0.3', 1)
    #
    # @param [Integer, String] project The ID or name of a project.
    # @param [String] tag_name  The tag where the release will be created from.
    # @param [Integer] link_id The id of the link.
    # @return [Gitlab::ObjectifiedHash] Information about the deleted release link.
    def delete_project_release_link(project, tag_name, link_id)
      delete("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
    end
  end
end