Codebase list ruby-gitlab / upstream/4.8.0 lib / gitlab / client / projects.rb
upstream/4.8.0

Tree @upstream/4.8.0 (Download .tar.gz)

projects.rb @upstream/4.8.0raw · history · blame

  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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# frozen_string_literal: true

class Gitlab::Client
  # Defines methods related to projects.
  # @see https://docs.gitlab.com/ce/api/projects.html
  module Projects
    # Gets a list of projects owned by the authenticated user.
    #
    # @example
    #   Gitlab.projects
    #
    # @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.
    # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#list-all-projects Gitlab docs} for all valid options)
    #
    # @return [Array<Gitlab::ObjectifiedHash>]
    def projects(options = {})
      get('/projects', query: options)
    end

    # Search for projects by name.
    #
    # @example
    #   Gitlab.project_search('gitlab')
    #   Gitlab.project_search('gitlab', { order_by: 'last_activity_at' })
    #   Gitlab.search_projects('gitlab', { order_by: 'name', sort: 'asc' })
    #
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :per_page Number of projects to return per page
    # @option options [String] :page The page to retrieve
    # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
    # @option options [String] :sort Return requests sorted in asc or desc order
    # @return [Array<Gitlab::ObjectifiedHash>]
    def project_search(query, options = {})
      get('/projects', query: options.merge(search: query))
    end
    alias search_projects project_search

    # Gets information about a project.
    #
    # @example
    #   Gitlab.project(3)
    #   Gitlab.project('gitlab')
    #
    # @param  [Integer, String] id The ID or path of a project.
    # @return [Gitlab::ObjectifiedHash]
    def project(id)
      get("/projects/#{url_encode id}")
    end

    # Creates a new project.
    #
    # @example
    #   Gitlab.create_project('gitlab')
    #   Gitlab.create_project('viking', { description: 'Awesome project' })
    #   Gitlab.create_project('Red', { wall_enabled: false })
    #
    # @param  [String] name The name of a project.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :description The description of a project.
    # @option options [String] :default_branch The default branch of a project.
    # @option options [String] :path Repository name for new project. (Default is lowercase name with dashes)
    # @option options [String] :namespace_id The namespace in which to create a project.
    # @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
    # @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
    # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
    # @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
    # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
    # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
    # @option options [Integer] :user_id The user/owner id of a project.
    # @return [Gitlab::ObjectifiedHash] Information about created project.
    def create_project(name, options = {})
      url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects'
      post(url, body: { name: name }.merge(options))
    end

    # Deletes a project.
    #
    # @example
    #   Gitlab.delete_project(4)
    #
    # @param  [Integer, String] id The ID or path of a project.
    # @return [Gitlab::ObjectifiedHash] Information about deleted project.
    def delete_project(id)
      delete("/projects/#{url_encode id}")
    end

    # Gets a list of project team members.
    #
    # @example
    #   Gitlab.team_members(42)
    #   Gitlab.team_members('gitlab')
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :query The search query.
    # @option options [Integer] :page The page number.
    # @option options [Integer] :per_page The number of results per page.
    # @return [Array<Gitlab::ObjectifiedHash>]
    def team_members(project, options = {})
      get("/projects/#{url_encode project}/members", query: options)
    end

    # Gets a project team member.
    #
    # @example
    #   Gitlab.team_member('gitlab', 2)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a project team member.
    # @return [Gitlab::ObjectifiedHash]
    def team_member(project, id)
      get("/projects/#{url_encode project}/members/#{id}")
    end

    # Adds a user to project team.
    #
    # @example
    #   Gitlab.add_team_member('gitlab', 2, 40)
    #   Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"})
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a user.
    # @param  [Integer] access_level The access level to project.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
    # @return [Gitlab::ObjectifiedHash] Information about added team member.
    def add_team_member(project, id, access_level, options = {})
      body = { user_id: id, access_level: access_level }.merge(options)
      post("/projects/#{url_encode project}/members", body: body)
    end

    # Updates a team member's project access level.
    #
    # @example
    #   Gitlab.edit_team_member('gitlab', 3, 20)
    #   Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"})
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a user.
    # @param  [Integer] access_level The access level to project.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
    # @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
    def edit_team_member(project, id, access_level, options = {})
      body = { access_level: access_level }.merge(options)
      put("/projects/#{url_encode project}/members/#{id}", body: body)
    end

    # Removes a user from project team.
    #
    # @example
    #   Gitlab.remove_team_member('gitlab', 2)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a user.
    # @param  [Hash] options A customizable set of options.
    # @return [Gitlab::ObjectifiedHash] Information about removed team member.
    def remove_team_member(project, id)
      delete("/projects/#{url_encode project}/members/#{id}")
    end

    # Gets a list of project hooks.
    #
    # @example
    #   Gitlab.project_hooks(42)
    #   Gitlab.project_hooks('gitlab')
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @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 project_hooks(project, options = {})
      get("/projects/#{url_encode project}/hooks", query: options)
    end

    # Gets a project hook.
    #
    # @example
    #   Gitlab.project_hook(42, 5)
    #   Gitlab.project_hook('gitlab', 5)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a hook.
    # @return [Gitlab::ObjectifiedHash]
    def project_hook(project, id)
      get("/projects/#{url_encode project}/hooks/#{id}")
    end

    # Adds a new hook to the project.
    #
    # @example
    #   Gitlab.add_project_hook(42, 'https://api.example.net/v1/webhooks/ci')
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [String] url The hook URL.
    # @param  [Hash] options A customizable set of options.
    # @param  option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
    # @param  option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
    # @param  option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
    # @param  option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
    # @return [Gitlab::ObjectifiedHash] Information about added hook.
    def add_project_hook(project, url, options = {})
      body = { url: url }.merge(options)
      post("/projects/#{url_encode project}/hooks", body: body)
    end

    # Updates a project hook URL.
    #
    # @example
    #   Gitlab.edit_project_hook(42, 1, 'https://api.example.net/v1/webhooks/ci')
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of the hook.
    # @param  [String] url The hook URL.
    # @param  [Hash] options A customizable set of options.
    # @param  option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
    # @param  option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
    # @param  option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
    # @param  option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
    # @return [Gitlab::ObjectifiedHash] Information about updated hook.
    def edit_project_hook(project, id, url, options = {})
      body = { url: url }.merge(options)
      put("/projects/#{url_encode project}/hooks/#{id}", body: body)
    end

    # Deletes a hook from project.
    #
    # @example
    #   Gitlab.delete_project_hook('gitlab', 4)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [String] id The ID of the hook.
    # @return [Gitlab::ObjectifiedHash] Information about deleted hook.
    def delete_project_hook(project, id)
      delete("/projects/#{url_encode project}/hooks/#{id}")
    end

    # Gets a project push rule.
    # @see https://docs.gitlab.com/ee/api/projects.html#show-project-push-rules
    #
    # @example
    #   Gitlab.push_rule(42)
    #
    # @param  [Integer] id The ID of a project.
    # @return [Gitlab::ObjectifiedHash]
    def push_rule(id)
      get("/projects/#{url_encode id}/push_rule")
    end

    # Adds a project push rule.
    # @see https://docs.gitlab.com/ee/api/projects.html#add-project-push-rule
    #
    # @example
    #   Gitlab.add_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
    #
    # @param  [Integer] id The ID of a project.
    # @param  [Hash] options A customizable set of options.
    # @param  option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
    # @param  option [String] :commit_message_regex Commit message regex
    # @return [Gitlab::ObjectifiedHash] Information about added push rule.
    def add_push_rule(id, options = {})
      post("/projects/#{url_encode id}/push_rule", body: options)
    end

    # Updates a project push rule.
    # @see https://docs.gitlab.com/ee/api/projects.html#edit-project-push-rule
    #
    # @example
    #   Gitlab.edit_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
    #
    # @param  [Integer] id The ID of a project.
    # @param  [Hash] options A customizable set of options.
    # @param  option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
    # @param  option [String] :commit_message_regex Commit message regex
    # @return [Gitlab::ObjectifiedHash] Information about updated push rule.
    def edit_push_rule(id, options = {})
      put("/projects/#{url_encode id}/push_rule", body: options)
    end

    # Deletes a push rule from a project.
    # @see https://docs.gitlab.com/ee/api/projects.html#delete-project-push-rule
    #
    # @example
    #   Gitlab.delete_push_rule(42)
    #
    # @param  [Integer] id The ID of a project.
    # @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
    def delete_push_rule(id)
      delete("/projects/#{url_encode id}/push_rule")
    end

    # Mark this project as forked from the other
    #
    # @example
    #   Gitlab.make_forked(42, 24)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of the project it is forked from.
    # @return [Gitlab::ObjectifiedHash] Information about the forked project.
    def make_forked_from(project, id)
      post("/projects/#{url_encode project}/fork/#{id}")
    end

    # Remove a forked_from relationship for a project.
    #
    # @example
    #  Gitlab.remove_forked(42)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] project The ID of the project it is forked from
    # @return [Gitlab::ObjectifiedHash] Information about the forked project.
    def remove_forked(project)
      delete("/projects/#{url_encode project}/fork")
    end

    # Gets a project deploy keys.
    #
    # @example
    #   Gitlab.deploy_keys(42)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @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 deploy_keys(project, options = {})
      get("/projects/#{url_encode project}/deploy_keys", query: options)
    end

    # Gets a single project deploy key.
    #
    # @example
    #   Gitlab.deploy_key(42, 1)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a deploy key.
    # @return [Gitlab::ObjectifiedHash]
    def deploy_key(project, id)
      get("/projects/#{url_encode project}/deploy_keys/#{id}")
    end

    # Creates a new deploy key.
    #
    # @example
    #   Gitlab.create_deploy_key(42, 'My Key', 'Key contents', can_push: true)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [String] title The title of a deploy key.
    # @param  [String] key The content of a deploy key.
    # @param  [Hash] options A customizable set of options.
    # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
    def create_deploy_key(project, title, key, options = {})
      post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge(options))
    end

    # Enables a deploy key at the project.
    #
    # @example
    #   Gitlab.enable_deploy_key(42, 66)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] key The ID of a deploy key.
    # @return [Gitlab::ObjectifiedHash] Information about the enabled deploy key.
    def enable_deploy_key(project, key)
      post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key })
    end

    # Disables a deploy key at the project.
    #
    # @example
    #   Gitlab.disable_deploy_key(42, 66)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] key The ID of a deploy key.
    # @return [Gitlab::ObjectifiedHash] Information about the disabled deploy key.
    def disable_deploy_key(project, key)
      post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
    end

    # Deletes a deploy key from project.
    #
    # @example
    #   Gitlab.delete_deploy_key(42, 1)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a deploy key.
    # @return [Gitlab::ObjectifiedHash] Information about deleted deploy key.
    def delete_deploy_key(project, id)
      delete("/projects/#{url_encode project}/deploy_keys/#{id}")
    end

    # Forks a project into the user namespace.
    #
    # @example
    #   Gitlab.create_fork(42)
    #   Gitlab.create_fork(42, { sudo: 'another_username' })
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :sudo The username the project will be forked for
    # @return [Gitlab::ObjectifiedHash] Information about the forked project.
    def create_fork(id, options = {})
      post("/projects/#{url_encode id}/fork", body: options)
    end

    # Get a list of all visible projects across GitLab for the authenticated user.
    # When accessed without authentication, only public projects are returned.
    #
    # Note: This feature was introduced in GitLab 10.1
    #
    # @example
    #   Gitlab.project_forks(42)
    #
    # @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.
    # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
    # @option options [String] :sort Return requests sorted in asc or desc order
    # @return [Array<Gitlab::ObjectifiedHash>]
    def project_forks(id, options = {})
      get("/projects/#{url_encode id}/forks", query: options)
    end

    # Updates an existing project.
    #
    # @example
    #   Gitlab.edit_project(42)
    #   Gitlab.edit_project(42, { name: 'Project Name' })
    #   Gitlab.edit_project('project-name', { name: 'New Project Name', path: 'new-project-patth' })
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Hash] options A customizable set of options
    # @option options [String] :name The name of a project
    # @option options [String] :path The project's repository name, also used in Gitlab's URLs
    # @option options [String] :description The description to show in Gitlab
    # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#edit-project Gitlab docs} for all valid options)
    #
    # @return [Gitlab::ObjectifiedHash] Information about the edited project.
    def edit_project(id, options = {})
      put("/projects/#{url_encode id}", body: options)
    end

    # Share project with group.
    #
    # @example
    #   Gitlab.share_project_with_group('gitlab', 2, 40)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a group.
    # @param  [Integer] group_access The access level to project.
    def share_project_with_group(project, id, group_access)
      post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
    end

    # Unshare project with group.
    #
    # @example
    #   Gitlab.unshare_project_with_group('gitlab', 2)
    #
    # @param  [Integer, String] project The ID or path of a project.
    # @param  [Integer] id The ID of a group.
    # @return [void] This API call returns an empty response body.
    def unshare_project_with_group(project, id)
      delete("/projects/#{url_encode project}/share/#{id}")
    end

    # Transfer a project to a new namespace.
    #
    # @example
    #   Gitlab.transfer_project(42, 'yolo')
    #
    # @param  [Integer, String] project The ID or path of a project
    # @param  [Integer, String] namespace The ID or path of the namespace to transfer to project to
    # @return [Gitlab::ObjectifiedHash] Information about transfered project.
    def transfer_project(project, namespace)
      put("/projects/#{url_encode project}/transfer", body: { namespace: namespace })
    end

    # Stars a project.
    # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
    #
    # @example
    #   Gitlab.star_project(42)
    #   Gitlab.star_project('gitlab-org/gitlab-ce')
    #
    # @param  [Integer, String] id The ID or path of a project.
    # @return [Gitlab::ObjectifiedHash] Information about starred project.
    def star_project(id)
      post("/projects/#{url_encode id}/star")
    end

    # Unstars a project.
    # @see https://docs.gitlab.com/ce/api/projects.html#unstar-a-project
    #
    # @example
    #   Gitlab.unstar_project(42)
    #   Gitlab.unstar_project('gitlab-org/gitlab-ce')
    #
    # @param  [Integer, String] id The ID or path of a project.
    # @return [Gitlab::ObjectifiedHash] Information about unstarred project.
    def unstar_project(id)
      delete("/projects/#{url_encode id}/star")
    end

    # Get a list of visible projects for the given user.
    # @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
    #
    # @example
    #   Gitlab.user_projects(1)
    #   Gitlab.user_projects(1, { order_by: 'last_activity_at' })
    #   Gitlab.user_projects('username', { order_by: 'name', sort: 'asc' })
    #
    # @param  [Integer, String] user_id The ID or username of the user.
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :per_page Number of projects to return per page
    # @option options [String] :page The page to retrieve
    # @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
    # @option options [String] :sort Return projects sorted in asc or desc order.
    # @return [Array<Gitlab::ObjectifiedHash>]
    def user_projects(user_id, options = {})
      get("/users/#{url_encode user_id}/projects", query: options)
    end

    # Uploads a file to the specified project to be used in an issue or
    # merge request description, or a comment.
    # @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file
    #
    # @example
    #   Gitlab.upload_file(1, File.open(File::NULL, 'r'))
    #   File.open('myfile') { |file| Gitlab.upload_file(1, file) }
    #
    # @param  [Integer, String] id The ID or path of a project.
    # @param  [File] The file you are interested to upload.
    # @return [Gitlab::ObjectifiedHash]
    def upload_file(id, file)
      post("/projects/#{url_encode id}/uploads", body: { file: file })
    end

    # Get all project templates of a particular type
    # @see https://docs.gitlab.com/ce/api/project_templates.html
    #
    # @example
    #   Gitlab.project_templates(1, 'dockerfiles')
    #   Gitlab.project_templates(1, 'licenses')
    #
    # @param  [Integer, String] id The ID or URL-encoded path of the project.
    # @param  [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
    # @return [Array<Gitlab::ObjectifiedHash>]
    def project_templates(project, type)
      get("/projects/#{url_encode project}/templates/#{type}")
    end

    # Get one project template of a particular type
    # @see https://docs.gitlab.com/ce/api/project_templates.html
    #
    # @example
    #   Gitlab.project_template(1, 'dockerfiles', 'dockey')
    #   Gitlab.project_template(1, 'licenses', 'gpl', { project: 'some project', fullname: 'Holder Holding' })
    #
    # @param  [Integer, String] project The ID or URL-encoded path of the project.
    # @param  [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
    # @param  [String] key The key of the template, as obtained from the collection endpoint
    # @param  [Hash] options A customizable set of options.
    # @option options [String] project(optional) The project name to use when expanding placeholders in the template. Only affects licenses
    # @option options [String] fullname(optional) The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses
    # @return [Gitlab::ObjectifiedHash]
    def project_template(project, type, key, options = {})
      get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
    end
  end
end