labclient 0.1.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/labclient.rb +65 -42
- data/lib/labclient/branches/branch.rb +25 -0
- data/lib/labclient/branches/create.rb +33 -0
- data/lib/labclient/client.rb +45 -5
- data/lib/labclient/common.rb +5 -0
- data/lib/labclient/docs.rb +5 -1
- data/lib/labclient/epics/epic.rb +13 -0
- data/lib/labclient/error.rb +1 -0
- data/lib/labclient/files/create.rb +14 -8
- data/lib/labclient/generator/generator.rb +70 -0
- data/lib/labclient/generator/names.rb +68 -0
- data/lib/labclient/generator/template_helper.rb +82 -0
- data/lib/labclient/generator/templates/environments.rb +98 -0
- data/lib/labclient/generator/templates/pages.rb +67 -0
- data/lib/labclient/generator/templates/pipeline_trigger.rb +82 -0
- data/lib/labclient/generator/wizard.rb +142 -0
- data/lib/labclient/groups/group.rb +17 -0
- data/lib/labclient/groups/stub.rb +8 -0
- data/lib/labclient/http.rb +8 -3
- data/lib/labclient/issues/agent_detail.rb +1 -1
- data/lib/labclient/issues/closed_by.rb +1 -1
- data/lib/labclient/issues/create.rb +17 -5
- data/lib/labclient/issues/delete.rb +1 -1
- data/lib/labclient/issues/issue.rb +21 -1
- data/lib/labclient/issues/move.rb +1 -1
- data/lib/labclient/issues/participants.rb +1 -1
- data/lib/labclient/issues/related_merge_requests.rb +1 -1
- data/lib/labclient/issues/show.rb +1 -1
- data/lib/labclient/issues/subscribe.rb +1 -1
- data/lib/labclient/issues/time_stats.rb +5 -5
- data/lib/labclient/issues/todo.rb +1 -1
- data/lib/labclient/issues/unsubscribe.rb +1 -1
- data/lib/labclient/issues/update.rb +1 -1
- data/lib/labclient/klass.rb +35 -3
- data/lib/labclient/lab_struct.rb +17 -0
- data/lib/labclient/license/list.rb +2 -2
- data/lib/labclient/members/member.rb +1 -0
- data/lib/labclient/merge_requests/accept.rb +16 -7
- data/lib/labclient/merge_requests/cancel_auto_merge.rb +1 -1
- data/lib/labclient/merge_requests/changes.rb +1 -1
- data/lib/labclient/merge_requests/closes_issues.rb +1 -1
- data/lib/labclient/merge_requests/commits.rb +1 -1
- data/lib/labclient/merge_requests/create.rb +12 -0
- data/lib/labclient/merge_requests/delete.rb +1 -1
- data/lib/labclient/merge_requests/diff_versions.rb +1 -1
- data/lib/labclient/merge_requests/merge_request.rb +49 -4
- data/lib/labclient/merge_requests/participants.rb +1 -1
- data/lib/labclient/merge_requests/pipelines.rb +2 -2
- data/lib/labclient/merge_requests/rebase.rb +1 -1
- data/lib/labclient/merge_requests/show.rb +1 -1
- data/lib/labclient/merge_requests/subscribe.rb +1 -1
- data/lib/labclient/merge_requests/time_stats.rb +5 -5
- data/lib/labclient/merge_requests/todo.rb +1 -1
- data/lib/labclient/merge_requests/unsubscribe.rb +1 -1
- data/lib/labclient/merge_requests/update.rb +1 -1
- data/lib/labclient/notes/epics/create.rb +12 -4
- data/lib/labclient/notes/epics/delete.rb +3 -3
- data/lib/labclient/notes/epics/list.rb +21 -4
- data/lib/labclient/notes/epics/show.rb +4 -4
- data/lib/labclient/notes/epics/update.rb +4 -4
- data/lib/labclient/notes/issues/create.rb +11 -1
- data/lib/labclient/notes/issues/list.rb +18 -3
- data/lib/labclient/notes/issues/show.rb +1 -1
- data/lib/labclient/notes/merge_requests/create.rb +8 -0
- data/lib/labclient/notes/merge_requests/list.rb +20 -2
- data/lib/labclient/notes/snippets/create.rb +1 -1
- data/lib/labclient/notes/snippets/list.rb +20 -3
- data/lib/labclient/notes/snippets/show.rb +1 -1
- data/lib/labclient/notifications/update.rb +1 -1
- data/lib/labclient/overview.rb +117 -16
- data/lib/labclient/paginated_response.rb +6 -1
- data/lib/labclient/pipelines/pipeline.rb +41 -0
- data/lib/labclient/projects/access_requests/access_request.rb +0 -1
- data/lib/labclient/projects/badges/project_badge.rb +0 -1
- data/lib/labclient/projects/clusters/project_cluster.rb +0 -1
- data/lib/labclient/projects/create.rb +13 -0
- data/lib/labclient/projects/deployments/project_deployment.rb +1 -3
- data/lib/labclient/projects/environments/project_environment.rb +0 -1
- data/lib/labclient/projects/forks/existing.rb +0 -2
- data/lib/labclient/projects/forks/fork.rb +1 -1
- data/lib/labclient/projects/forks/list.rb +0 -1
- data/lib/labclient/projects/forks/remove.rb +0 -1
- data/lib/labclient/projects/hooks/project_hook.rb +0 -1
- data/lib/labclient/projects/labels/project_label.rb +0 -1
- data/lib/labclient/projects/methods.rb +76 -2
- data/lib/labclient/projects/mirrors/project_mirror.rb +0 -1
- data/lib/labclient/projects/reference.rb +17 -0
- data/lib/labclient/projects/release_links/project_release_link.rb +0 -1
- data/lib/labclient/projects/releases/project_release.rb +0 -1
- data/lib/labclient/projects/services/project_service.rb +0 -1
- data/lib/labclient/projects/snippets/project_snippet.rb +12 -0
- data/lib/labclient/projects/stars/star.rb +0 -2
- data/lib/labclient/projects/stars/starred_projects.rb +0 -2
- data/lib/labclient/projects/stars/starrers.rb +1 -1
- data/lib/labclient/projects/triggers/project_trigger.rb +0 -1
- data/lib/labclient/projects/variables/project_variable.rb +0 -1
- data/lib/labclient/protected_branches/protect.rb +6 -5
- data/lib/labclient/protected_environments/list.rb +29 -0
- data/lib/labclient/protected_environments/protect.rb +53 -0
- data/lib/labclient/protected_environments/protected_environment.rb +22 -0
- data/lib/labclient/protected_environments/show.rb +24 -0
- data/lib/labclient/protected_environments/unprotect.rb +31 -0
- data/lib/labclient/snippets/snippet.rb +2 -2
- data/lib/labclient/users/membership.rb +62 -0
- data/lib/labclient/users/memberships.rb +8 -3
- data/lib/labclient/users/user.rb +13 -1
- data/lib/labclient/version.rb +1 -1
- metadata +38 -9
- data/lib/labclient/open_struct.rb +0 -14
|
@@ -86,7 +86,7 @@ module LabClient
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def link_regex
|
|
89
|
-
/<([^>]+)>; rel
|
|
89
|
+
/<([^>]+)>; rel="([^"]+)"/
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def next_page
|
|
@@ -111,5 +111,10 @@ module LabClient
|
|
|
111
111
|
process_entry(entry, @response)
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
|
+
|
|
115
|
+
# Forward response success
|
|
116
|
+
def success?
|
|
117
|
+
@response.success?
|
|
118
|
+
end
|
|
114
119
|
end
|
|
115
120
|
end
|
|
@@ -33,6 +33,45 @@ module LabClient
|
|
|
33
33
|
client.jobs.pipeline(project_id, id, scope)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def reload
|
|
37
|
+
project_id = collect_project_id
|
|
38
|
+
update_self client.pipelines.show(project_id, id)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The status of pipelines, one of: running, pending, success, failed, canceled, skipped, created, manual
|
|
42
|
+
|
|
43
|
+
# Wait for Import / Set a Hard Limit
|
|
44
|
+
def wait_for_status(total_time = 300, sleep_time = 15)
|
|
45
|
+
# running
|
|
46
|
+
# pending
|
|
47
|
+
# success
|
|
48
|
+
# failed
|
|
49
|
+
# canceled
|
|
50
|
+
# skipped
|
|
51
|
+
# manual
|
|
52
|
+
# created
|
|
53
|
+
|
|
54
|
+
# Wait
|
|
55
|
+
# [running created pending]
|
|
56
|
+
|
|
57
|
+
# Success
|
|
58
|
+
# [skipped manual canceled success]
|
|
59
|
+
|
|
60
|
+
# Fail
|
|
61
|
+
# [failed]
|
|
62
|
+
|
|
63
|
+
Timeout.timeout(total_time) do
|
|
64
|
+
loop do
|
|
65
|
+
reload
|
|
66
|
+
puts "Waiting for Pipeline: #{status}"
|
|
67
|
+
break if %w[skipped manual canceled success].include? status
|
|
68
|
+
raise 'Pipeline failed' if status == 'failed'
|
|
69
|
+
|
|
70
|
+
sleep sleep_time
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
36
75
|
# DateTime Fields
|
|
37
76
|
date_time_attrs %i[created_at updated_at finished_at started_at]
|
|
38
77
|
user_attrs %i[user]
|
|
@@ -43,6 +82,8 @@ module LabClient
|
|
|
43
82
|
option 'retry', 'Retry jobs in this pipeline'
|
|
44
83
|
option 'cancel', 'Cancel jobs in this pipeline'
|
|
45
84
|
option 'delete', 'Delete this pipeline'
|
|
85
|
+
option 'reload', 'Reload this pipeline object (New API Call)'
|
|
86
|
+
option 'wait_for_status', 'Looping, wait for merge request status [Timeout, Interval]'
|
|
46
87
|
end
|
|
47
88
|
end
|
|
48
89
|
end
|
|
@@ -32,6 +32,16 @@ module LabClient
|
|
|
32
32
|
example 'client.projects.create(name: "Verbal", description: "hes gone", visibility: :private)'
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
doc 'Create' do
|
|
36
|
+
desc 'Via Group'
|
|
37
|
+
example <<~DOC
|
|
38
|
+
group = client.groups.show(51)
|
|
39
|
+
group.project_create(name: "Hobby", description: "We do have time for your darned hobbies!")
|
|
40
|
+
DOC
|
|
41
|
+
|
|
42
|
+
example 'client.projects.create(name: "Verbal", description: "hes gone", visibility: :private)'
|
|
43
|
+
end
|
|
44
|
+
|
|
35
45
|
doc 'Create' do
|
|
36
46
|
title 'For User'
|
|
37
47
|
desc 'Creates a new project owned by the specified user [user id, params]'
|
|
@@ -42,7 +52,10 @@ module LabClient
|
|
|
42
52
|
client.request(:post, "projects/user/#{user_id}", Project, query)
|
|
43
53
|
end
|
|
44
54
|
|
|
55
|
+
# TODO: Test Project/Group Creation
|
|
56
|
+
# TODO: Create helper for group
|
|
45
57
|
def create(query = {})
|
|
58
|
+
format_query_id(:namespace_id, query)
|
|
46
59
|
client.request(:post, 'projects', Project, query)
|
|
47
60
|
end
|
|
48
61
|
end
|
|
@@ -28,11 +28,9 @@ module LabClient
|
|
|
28
28
|
user_attrs %i[user]
|
|
29
29
|
|
|
30
30
|
help do
|
|
31
|
-
|
|
32
|
-
subtitle 'ProjectDeployment'
|
|
31
|
+
subtitle 'Project Deployment'
|
|
33
32
|
option 'project', 'Show Project'
|
|
34
33
|
option 'update', 'Update this deployment [Hash]'
|
|
35
|
-
option 'delete', 'Delete this deployment'
|
|
36
34
|
option 'stop', 'Stop this deployment'
|
|
37
35
|
end
|
|
38
36
|
end
|
|
@@ -7,8 +7,8 @@ module LabClient
|
|
|
7
7
|
client.projects.users(id)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def events
|
|
11
|
-
client.events.project(id)
|
|
10
|
+
def events(query = {})
|
|
11
|
+
client.events.project(id, query)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def delete
|
|
@@ -75,10 +75,15 @@ module LabClient
|
|
|
75
75
|
update_self(client.projects.fork_existing(id, target_id))
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
# Issues
|
|
78
79
|
def issues(query = {})
|
|
79
80
|
client.issues.project_issues(id, query)
|
|
80
81
|
end
|
|
81
82
|
|
|
83
|
+
def issue_create(query)
|
|
84
|
+
client.issues.create(id, query)
|
|
85
|
+
end
|
|
86
|
+
|
|
82
87
|
# Hooks
|
|
83
88
|
def hooks
|
|
84
89
|
client.projects.hooks.list(id)
|
|
@@ -341,6 +346,10 @@ module LabClient
|
|
|
341
346
|
client.branches.show(id, branch_id)
|
|
342
347
|
end
|
|
343
348
|
|
|
349
|
+
def branch_create(query)
|
|
350
|
+
client.branches.create(id, query)
|
|
351
|
+
end
|
|
352
|
+
|
|
344
353
|
def branch_delete(branch_id)
|
|
345
354
|
client.branches.delete(id, branch_id)
|
|
346
355
|
end
|
|
@@ -483,6 +492,23 @@ module LabClient
|
|
|
483
492
|
client.projects.environments.stop(id, environment_id)
|
|
484
493
|
end
|
|
485
494
|
|
|
495
|
+
# Protected Environments
|
|
496
|
+
def protected_environments
|
|
497
|
+
client.protected_environments.list(id)
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
def protected_environment(environment_id)
|
|
501
|
+
client.protected_environments.show(id, environment_id)
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def protect_environment(query)
|
|
505
|
+
client.protected_environments.protect(id, query)
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
def unprotect_environment(environment_id)
|
|
509
|
+
client.protected_environments.unprotect(id, environment_id)
|
|
510
|
+
end
|
|
511
|
+
|
|
486
512
|
# Project Triggers
|
|
487
513
|
def triggers
|
|
488
514
|
client.projects.triggers.list(id)
|
|
@@ -615,6 +641,10 @@ module LabClient
|
|
|
615
641
|
client.merge_requests.list_project(id, query)
|
|
616
642
|
end
|
|
617
643
|
|
|
644
|
+
def merge_request_create(query)
|
|
645
|
+
client.merge_requests.create(id, query)
|
|
646
|
+
end
|
|
647
|
+
|
|
618
648
|
# Access Requests
|
|
619
649
|
def request_access
|
|
620
650
|
client.projects.access_requests.create(id)
|
|
@@ -676,6 +706,50 @@ module LabClient
|
|
|
676
706
|
def clusters
|
|
677
707
|
client.projects.clusters.list(id)
|
|
678
708
|
end
|
|
709
|
+
|
|
710
|
+
# Reload
|
|
711
|
+
def reload
|
|
712
|
+
update_self client.projects.show(id)
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
# Parent Helper
|
|
716
|
+
def parent
|
|
717
|
+
case namespace.kind
|
|
718
|
+
when 'user'
|
|
719
|
+
client.users.show(namespace.id)
|
|
720
|
+
when 'group'
|
|
721
|
+
client.groups.show(namespace.id)
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
# Snippets
|
|
726
|
+
def snippets
|
|
727
|
+
client.projects.snippets.list(id)
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
def snippet_create(query)
|
|
731
|
+
client.projects.snippets.create(id, query)
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
# Wait for Import / Set a Hard Limit
|
|
735
|
+
def wait_for_import(total_time = 300, sleep_time = 15)
|
|
736
|
+
# none
|
|
737
|
+
# scheduled
|
|
738
|
+
# failed
|
|
739
|
+
# started
|
|
740
|
+
# finished
|
|
741
|
+
|
|
742
|
+
Timeout.timeout(total_time) do
|
|
743
|
+
loop do
|
|
744
|
+
reload
|
|
745
|
+
puts "Waiting for Import Status: #{import_status}"
|
|
746
|
+
break if %w[none finished].include? import_status
|
|
747
|
+
raise "Import Failed: #{import_error}" if import_status == 'failed'
|
|
748
|
+
|
|
749
|
+
sleep sleep_time
|
|
750
|
+
end
|
|
751
|
+
end
|
|
752
|
+
end
|
|
679
753
|
end
|
|
680
754
|
# rubocop:enable Metrics/ModuleLength
|
|
681
755
|
end
|
|
@@ -8,11 +8,17 @@ module LabClient
|
|
|
8
8
|
option 'archive', 'Archive this project'
|
|
9
9
|
option 'delete', 'Schedule/Delete this project'
|
|
10
10
|
option 'events', "List this project's events"
|
|
11
|
+
option 'reload', 'Reload this project object (New API Call)'
|
|
12
|
+
option 'wait_for_import', 'Looping, wait for project import [Timeout, Interval]'
|
|
13
|
+
|
|
11
14
|
option 'fork_existing', 'Create Fork Relationship [Target/Source Project]'
|
|
12
15
|
option 'fork_remove', 'Remove Fork Relationshgip'
|
|
13
16
|
option 'fork', 'Fork this project, accepts hash, [namespace, path, name]'
|
|
14
17
|
option 'forks', 'List forks of this project'
|
|
18
|
+
|
|
19
|
+
# Issues
|
|
15
20
|
option 'issues', 'List project issues [Hash]'
|
|
21
|
+
option 'issue_create', 'Create a new issue in this project [Hash]'
|
|
16
22
|
|
|
17
23
|
option 'housekeeping', 'Start the Housekeeping'
|
|
18
24
|
option 'languages', 'Get percentage value of languages used.'
|
|
@@ -65,6 +71,12 @@ module LabClient
|
|
|
65
71
|
option 'environment_update', 'Update project environment [Environment ID, Hash]'
|
|
66
72
|
option 'environment_stop', 'Stop project environment [Environment ID]'
|
|
67
73
|
|
|
74
|
+
# Protected Environments
|
|
75
|
+
option 'protected_environments', 'List protected environments [String]'
|
|
76
|
+
option 'protected_environment', 'Show single protected environment [String]'
|
|
77
|
+
option 'protect_environment', 'Protect a single environment [Hash]'
|
|
78
|
+
option 'unprotect_environment', 'Unprotect environment [Environment]'
|
|
79
|
+
|
|
68
80
|
# Deployments
|
|
69
81
|
option 'deployments', "List this project's deployments"
|
|
70
82
|
option 'deployment_create', 'Create project deployment [Hash]'
|
|
@@ -198,6 +210,7 @@ module LabClient
|
|
|
198
210
|
# Branches
|
|
199
211
|
option 'branches', 'List repository branches [String]'
|
|
200
212
|
option 'branch', 'Get a single repository branches [Branch Name]'
|
|
213
|
+
option 'branch_create', 'Create a repository branches [Hash]'
|
|
201
214
|
option 'branch_delete', 'Delete a single repository branches [Branch Name]'
|
|
202
215
|
option 'branch_delete_merged', 'Will delete all branches that are merged into the project’s default branch'
|
|
203
216
|
|
|
@@ -235,6 +248,7 @@ module LabClient
|
|
|
235
248
|
|
|
236
249
|
# Merge Requests
|
|
237
250
|
option 'merge_requests', 'List project merge requests, [Hash]'
|
|
251
|
+
option 'merge_request_create', 'Create new merge request [Hash]'
|
|
238
252
|
|
|
239
253
|
# Access Requests
|
|
240
254
|
option 'access_requests', 'List access requests for project'
|
|
@@ -248,6 +262,9 @@ module LabClient
|
|
|
248
262
|
|
|
249
263
|
# Clusters
|
|
250
264
|
option 'clusters', 'Returns a list of project clusters.'
|
|
265
|
+
|
|
266
|
+
option 'events', 'List project events [Hash]'
|
|
267
|
+
option 'parent', 'Show (API Call) Project Parent, returns either Group or User'
|
|
251
268
|
end
|
|
252
269
|
end
|
|
253
270
|
# rubocop:enable Metrics/BlockLength, Metrics/ClassLength
|
|
@@ -35,6 +35,14 @@ module LabClient
|
|
|
35
35
|
client.projects.snippets.delete(project_id, id)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def notes
|
|
39
|
+
client.notes.snippets.list(project_id, id)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def note_create(query)
|
|
43
|
+
client.notes.snippets.create(project_id, id, query)
|
|
44
|
+
end
|
|
45
|
+
|
|
38
46
|
date_time_attrs %i[updated_at created_at]
|
|
39
47
|
|
|
40
48
|
user_attrs %i[author]
|
|
@@ -45,6 +53,10 @@ module LabClient
|
|
|
45
53
|
option 'agent_detail', 'Hash of user agent details.'
|
|
46
54
|
option 'delete', 'Delete this deploy key.'
|
|
47
55
|
option 'update', 'Update this this deploy key.'
|
|
56
|
+
|
|
57
|
+
# Notes
|
|
58
|
+
option 'notes', 'List notes/comments. [Hash]'
|
|
59
|
+
option 'note_create', 'Creates a new note. [Hash]'
|
|
48
60
|
end
|
|
49
61
|
end
|
|
50
62
|
end
|