File: epics.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 (73 lines) | stat: -rw-r--r-- 2,362 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
# frozen_string_literal: true

class Gitlab::Client
  # Defines methods related to Epics.
  # @see https://docs.gitlab.com/ee/api/epics.html
  module Epics
    # Gets a list of epics.
    #
    # @example
    #   Gitlab.epics(123)
    #   Gitlab.epics(123, { per_page: 40, page: 2 })
    #
    # @param  [Integer] group_id The ID of a group.
    # @param  [Hash] options A customizable set of options.
    # @option options [Integer] :page The page number.
    # @option options [Integer] :per_page The number of results per page.
    # @return [Array<Gitlab::ObjectifiedHash>]
    def epics(group_id, options = {})
      get("/groups/#{group_id}/epics", query: options)
    end

    # Gets a single epic.
    #
    # @example
    #   Gitlab.epic(123, 1)
    #
    # @param  [Integer] group_id The ID of a group.
    # @param  [Integer] epic_iid The ID of a epic.
    # @param  [Hash] options A customizable set of options.
    # @return [Gitlab::ObjectifiedHash]
    def epic(group_id, epic_iid, options = {})
      get("/groups/#{group_id}/epics/#{epic_iid}", query: options)
    end

    # Creates a new epic.
    #
    # @example
    #   Gitlab.create_epic(123, "My new epic title")
    #
    # @param  [Integer] group_id The ID of a group.
    # @param  [String] title
    # @param  [Hash] options A customizable set of options.
    # @return [Gitlab::ObjectifiedHash] Information about created epic.
    def create_epic(group_id, title, options = {})
      body = options.merge(title: title)
      post("/groups/#{group_id}/epics", body: body)
    end

    # Deletes an epic.
    #
    # @example
    #   Gitlab.delete_epic(42, 123)
    # @param  [Integer] group_id The ID of a group.
    # @param  [Integer] epic_iid The IID of an epic.
    def delete_epic(group_id, epic_iid)
      delete("/groups/#{group_id}/epics/#{epic_iid}")
    end

    # Updates an existing epic.
    #
    # @example
    #   Gitlab.edit_epic(42)
    #   Gitlab.edit_epic(42, 123, { title: 'New epic title' })
    #
    # @param  [Integer] group_id The ID.
    # @param  [Integer] epic_iid The IID of an epic.
    # @param  [Hash] options A customizable set of options
    # @return [Gitlab::ObjectifiedHash] Information about the edited epic.
    def edit_epic(group_id, epic_iid, options = {})
      put("/groups/#{group_id}/epics/#{epic_iid}", body: options)
    end
  end
end