File: templates.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 (100 lines) | stat: -rw-r--r-- 3,001 bytes parent folder | download | duplicates (4)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# frozen_string_literal: true

class Gitlab::Client
  # Defines methods related to templates.
  # @see https://docs.gitlab.com/ce/api/templates/dockerfiles.html
  # @see https://docs.gitlab.com/ce/api/templates/gitignores.html
  # @see https://docs.gitlab.com/ce/api/templates/gitlab_ci_ymls.html
  # @see https://docs.gitlab.com/ce/api/templates/licenses.html
  module Templates
    # Get all Dockerfile templates.
    #
    # @example
    #   Gitlab.dockerfile_templates
    #
    # @return [Array<Gitlab::ObjectifiedHash>]
    def dockerfile_templates
      get('/templates/dockerfiles')
    end

    # Get a single Dockerfile template.
    #
    # @example
    #   Gitlab.dockerfile_template('Binary')
    #
    # @param  [String] key The key of the Dockerfile template
    # @return [Gitlab::ObjectifiedHash]
    def dockerfile_template(key)
      get("/templates/dockerfiles/#{key}")
    end

    # Get all gitignore templates.
    #
    # @example
    #   Gitlab.gitignore_templates
    #
    # @return [Array<Gitlab::ObjectifiedHash>]
    def gitignore_templates
      get('/templates/gitignores')
    end

    # Get a single gitignore template.
    #
    # @example
    #   Gitlab.gitignore_template('Ruby')
    #
    # @param  [String] key The key of the gitignore template
    # @return [Gitlab::ObjectifiedHash]
    def gitignore_template(key)
      get("/templates/gitignores/#{key}")
    end

    # Get all `gitlab_ci.yml` templates.
    #
    # @example
    #   Gitlab.gitlab_ci_yml_templates
    #
    # @return [Array<Gitlab::ObjectifiedHash>]
    def gitlab_ci_yml_templates
      get('/templates/gitlab_ci_ymls')
    end

    # Get a single `gitlab_ci.yml` template.
    #
    # @example
    #   Gitlab.gitlab_ci_yml_template('Ruby')
    #
    # @param  [String] key The key of the gitlab_ci_yml template
    # @return [Gitlab::ObjectifiedHash]
    def gitlab_ci_yml_template(key)
      get("/templates/gitlab_ci_ymls/#{key}")
    end

    # Get all license templates.
    #
    # @example
    #   Gitlab.license_templates
    #   Gitlab.license_templates(popular: true)
    #
    # @param  [Hash] options A customizable set of options.
    # @option options [Boolean] popular(optional) If passed, returns only popular licenses.
    # @return [Array<Gitlab::ObjectifiedHash>]
    def license_templates(options = {})
      get('/templates/licenses', query: options)
    end

    # Get a single license template. You can pass parameters to replace the license placeholder.
    #
    # @example
    #   Gitlab.license_template('Ruby')
    #
    # @param  [String] key The key of the license template
    # @param  [Hash] options A customizable set of options.
    # @option options [String] project(optional) The copyrighted project name.
    # @option options [String] fullname(optional) The full-name of the copyright holder
    # @return [Gitlab::ObjectifiedHash]
    def license_template(key, options = {})
      get("/templates/licenses/#{key}", query: options)
    end
  end
end