labclient 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labclient.rb +7 -4
- data/lib/labclient/branches/branch.rb +25 -0
- data/lib/labclient/branches/create.rb +33 -0
- data/lib/labclient/client.rb +2 -2
- 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 +2 -14
- data/lib/labclient/generator/names.rb +17 -3
- 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 +24 -30
- data/lib/labclient/generator/templates/pipeline_trigger.rb +82 -0
- data/lib/labclient/generator/wizard.rb +23 -7
- data/lib/labclient/http.rb +2 -1
- data/lib/labclient/issues/issue.rb +6 -1
- data/lib/labclient/klass.rb +3 -2
- data/lib/labclient/lab_struct.rb +17 -0
- data/lib/labclient/license/list.rb +2 -2
- data/lib/labclient/merge_requests/accept.rb +15 -6
- data/lib/labclient/merge_requests/create.rb +12 -0
- data/lib/labclient/merge_requests/merge_request.rb +49 -4
- data/lib/labclient/notes/epics/create.rb +4 -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 +3 -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/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/paginated_response.rb +1 -1
- data/lib/labclient/pipelines/pipeline.rb +41 -0
- data/lib/labclient/projects/methods.rb +30 -2
- data/lib/labclient/projects/reference.rb +5 -0
- data/lib/labclient/projects/snippets/project_snippet.rb +12 -0
- data/lib/labclient/snippets/snippet.rb +2 -2
- data/lib/labclient/users/user.rb +6 -0
- data/lib/labclient/version.rb +1 -1
- metadata +10 -7
- data/lib/labclient/generator/templates/template.rb +0 -23
- data/lib/labclient/open_struct.rb +0 -14
@@ -4,7 +4,7 @@ module LabClient
|
|
4
4
|
class EpicNotes < Common
|
5
5
|
doc 'Epics' do
|
6
6
|
title 'Create'
|
7
|
-
desc 'Creates a new note for a single
|
7
|
+
desc 'Creates a new note for a single epic [Project, Epic IID]'
|
8
8
|
example 'client.notes.epics.create(16, 2, body: "Hello!")'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 44, type: Epic>
|
@@ -20,13 +20,13 @@ module LabClient
|
|
20
20
|
DOC
|
21
21
|
end
|
22
22
|
|
23
|
-
def create(
|
24
|
-
|
23
|
+
def create(group_id, epic_id, query = {})
|
24
|
+
group_id = format_id(group_id)
|
25
25
|
epic_id = format_id(epic_id)
|
26
26
|
|
27
27
|
query[:created_at] = query[:created_at].to_time.iso8601 if format_time?(query[:created_at])
|
28
28
|
|
29
|
-
client.request(:post, "
|
29
|
+
client.request(:post, "groups/#{group_id}/epics/#{epic_id}/notes", Note, query)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -9,12 +9,12 @@ module LabClient
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Delete
|
12
|
-
def delete(
|
13
|
-
|
12
|
+
def delete(group_id, epic_id, note_id)
|
13
|
+
group_id = format_id(group_id)
|
14
14
|
epic_id = format_id(epic_id)
|
15
15
|
note_id = format_id(note_id)
|
16
16
|
|
17
|
-
client.request(:delete, "
|
17
|
+
client.request(:delete, "groups/#{group_id}/epics/#{epic_id}/notes/#{note_id}")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -5,18 +5,35 @@ module LabClient
|
|
5
5
|
@group_name = 'Notes'
|
6
6
|
doc 'Epics' do
|
7
7
|
title 'List'
|
8
|
-
desc 'Gets a list of all notes for a single
|
8
|
+
desc 'Gets a list of all notes for a single epic. [Project ID, Epic IID]'
|
9
|
+
markdown <<~DOC
|
10
|
+
| Attribute | Type | Required | Description |
|
11
|
+
| --------- | ------ | -------- | ------------------------------------------------------------------------------------ |
|
12
|
+
| sort | string | no | Return epic notes sorted in asc or desc order. Default is desc |
|
13
|
+
| order_by | string | no | Return epic notes ordered by created_at or updated_at fields. Default is created_at |
|
14
|
+
DOC
|
15
|
+
end
|
16
|
+
|
17
|
+
doc 'Epics' do
|
9
18
|
example 'client.notes.epics.list(16, 1)'
|
10
19
|
result <<~DOC
|
11
20
|
=> [#<Note id: 21, type: Epic>, #<Note id: 20, type: Epic> .. ]
|
12
21
|
DOC
|
13
22
|
end
|
14
23
|
|
15
|
-
|
16
|
-
|
24
|
+
doc 'Epics' do
|
25
|
+
desc 'Filter or Sort'
|
26
|
+
example 'client.notes.epics.list(16, 1, order_by: :created_at, sort: :asc)'
|
27
|
+
result <<~DOC
|
28
|
+
=> [#<Note id: 21, type: Epic>, #<Note id: 20, type: Epic> .. ]
|
29
|
+
DOC
|
30
|
+
end
|
31
|
+
|
32
|
+
def list(group_id, epic_id, query = {})
|
33
|
+
group_id = format_id(group_id)
|
17
34
|
epic_id = format_id(epic_id)
|
18
35
|
|
19
|
-
client.request(:get, "
|
36
|
+
client.request(:get, "groups/#{group_id}/epics/#{epic_id}/notes", Note, query)
|
20
37
|
end
|
21
38
|
end
|
22
39
|
end
|
@@ -4,19 +4,19 @@ module LabClient
|
|
4
4
|
class EpicNotes < Common
|
5
5
|
doc 'Epics' do
|
6
6
|
title 'Show'
|
7
|
-
desc 'Returns a single note for a given
|
7
|
+
desc 'Returns a single note for a given epic. [Project ID, Epic IID, Note ID]'
|
8
8
|
example 'client.notes.epics.show(16, 1, 43)'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 21, type: Epic>
|
11
11
|
DOC
|
12
12
|
end
|
13
13
|
|
14
|
-
def show(
|
15
|
-
|
14
|
+
def show(group_id, epic_id, note_id)
|
15
|
+
group_id = format_id(group_id)
|
16
16
|
epic_id = format_id(epic_id)
|
17
17
|
note_id = format_id(note_id)
|
18
18
|
|
19
|
-
client.request(:get, "
|
19
|
+
client.request(:get, "groups/#{group_id}/epics/#{epic_id}/notes/#{note_id}", Note)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -4,7 +4,7 @@ module LabClient
|
|
4
4
|
class EpicNotes < Common
|
5
5
|
doc 'Epics' do
|
6
6
|
title 'Update'
|
7
|
-
desc 'Get a single
|
7
|
+
desc 'Get a single group epic. [Project ID, Epic IID, Note ID]'
|
8
8
|
example 'client.notes.epics.update(16, 1, 43, "Updaaate")'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 43, type: Epic>
|
@@ -20,13 +20,13 @@ module LabClient
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Show
|
23
|
-
def update(
|
24
|
-
|
23
|
+
def update(group_id, epic_id, note_id, body)
|
24
|
+
group_id = format_id(group_id)
|
25
25
|
epic_id = format_id(epic_id)
|
26
26
|
note_id = format_id(note_id)
|
27
27
|
query = { body: body }
|
28
28
|
|
29
|
-
client.request(:put, "
|
29
|
+
client.request(:put, "groups/#{group_id}/epics/#{epic_id}/notes/#{note_id}", Note, query)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -4,7 +4,7 @@ module LabClient
|
|
4
4
|
class IssueNotes < Common
|
5
5
|
doc 'Issues' do
|
6
6
|
title 'Create'
|
7
|
-
desc 'Creates a new note for a single
|
7
|
+
desc 'Creates a new note for a single issue [Project, Issue IID]'
|
8
8
|
example 'client.notes.issues.create(16, 2, body: "Hello!")'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 44, type: Issue>
|
@@ -26,6 +26,8 @@ module LabClient
|
|
26
26
|
|
27
27
|
query[:created_at] = query[:created_at].to_time.iso8601 if format_time?(query[:created_at])
|
28
28
|
|
29
|
+
# POST /projects/:id/issues/:issue_iid/notes
|
30
|
+
|
29
31
|
client.request(:post, "projects/#{project_id}/issues/#{issue_id}/notes", Note, query)
|
30
32
|
end
|
31
33
|
end
|
@@ -3,20 +3,35 @@ module LabClient
|
|
3
3
|
# Specifics
|
4
4
|
class IssueNotes < Common
|
5
5
|
@group_name = 'Notes'
|
6
|
+
|
6
7
|
doc 'Issues' do
|
7
8
|
title 'List'
|
8
|
-
desc 'Gets a list of all notes for a single
|
9
|
+
desc 'Gets a list of all notes for a single issue. [Project ID, Issue IID]'
|
10
|
+
markdown <<~DOC
|
11
|
+
| Attribute | Type | Required | Description |
|
12
|
+
| --------- | ------ | -------- | ------------------------------------------------------------------------------------ |
|
13
|
+
| sort | string | no | Return issue notes sorted in asc or desc order. Default is desc |
|
14
|
+
| order_by | string | no | Return issue notes ordered by created_at or updated_at fields. Default is created_at |
|
15
|
+
DOC
|
16
|
+
end
|
17
|
+
|
18
|
+
doc 'Issues' do
|
9
19
|
example 'client.notes.issues.list(16, 1)'
|
10
20
|
result <<~DOC
|
11
21
|
=> [#<Note id: 21, type: Issue>, #<Note id: 20, type: Issue> .. ]
|
12
22
|
DOC
|
13
23
|
end
|
14
24
|
|
15
|
-
|
25
|
+
doc 'Issues' do
|
26
|
+
desc 'Sort or Filter'
|
27
|
+
example 'client.notes.issues.list(16, 1, order_by: :created_at, sort: :asc)'
|
28
|
+
end
|
29
|
+
|
30
|
+
def list(project_id, issue_id, query = {})
|
16
31
|
project_id = format_id(project_id)
|
17
32
|
issue_id = format_id(issue_id)
|
18
33
|
|
19
|
-
client.request(:get, "projects/#{project_id}/issues/#{issue_id}/notes", Note)
|
34
|
+
client.request(:get, "projects/#{project_id}/issues/#{issue_id}/notes", Note, query)
|
20
35
|
end
|
21
36
|
end
|
22
37
|
end
|
@@ -4,7 +4,7 @@ module LabClient
|
|
4
4
|
class IssueNotes < Common
|
5
5
|
doc 'Issues' do
|
6
6
|
title 'Show'
|
7
|
-
desc 'Returns a single note for a given
|
7
|
+
desc 'Returns a single note for a given issue. [Project ID, Issue IID, Note ID]'
|
8
8
|
example 'client.notes.issues.show(16, 1, 43)'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 21, type: Issue>
|
@@ -6,17 +6,35 @@ module LabClient
|
|
6
6
|
doc 'Merge Requests' do
|
7
7
|
title 'List'
|
8
8
|
desc 'Gets a list of all notes for a single merge request. [Project ID, Merge Request IID]'
|
9
|
+
|
10
|
+
markdown <<~DOC
|
11
|
+
| Attribute | Type | Required | Description |
|
12
|
+
| --------- | ------ | -------- | -------------------------------------------------------------------------------------------- |
|
13
|
+
| sort | string | no | Return merge request notes sorted in asc or desc order. Default is desc |
|
14
|
+
| order_by | string | no | Return merge request notes ordered by created_at or updated_at fields. Default is created_at |
|
15
|
+
DOC
|
16
|
+
end
|
17
|
+
|
18
|
+
doc 'Merge Requests' do
|
9
19
|
example 'client.notes.merge_requests.list(16, 1)'
|
10
20
|
result <<~DOC
|
11
21
|
=> [#<Note id: 21, type: MergeRequest>, #<Note id: 20, type: MergeRequest> .. ]
|
12
22
|
DOC
|
13
23
|
end
|
14
24
|
|
15
|
-
|
25
|
+
doc 'Merge Requests' do
|
26
|
+
desc 'Sort or Filter'
|
27
|
+
example 'client.notes.merge_requests.list(16, 1, order_by: :created_at, sort: :asc)'
|
28
|
+
result <<~DOC
|
29
|
+
=> [#<Note id: 21, type: MergeRequest>, #<Note id: 20, type: MergeRequest> .. ]
|
30
|
+
DOC
|
31
|
+
end
|
32
|
+
|
33
|
+
def list(project_id, merge_request_id, query = {})
|
16
34
|
project_id = format_id(project_id)
|
17
35
|
merge_request_id = format_id(merge_request_id)
|
18
36
|
|
19
|
-
client.request(:get, "projects/#{project_id}/merge_requests/#{merge_request_id}/notes", Note)
|
37
|
+
client.request(:get, "projects/#{project_id}/merge_requests/#{merge_request_id}/notes", Note, query)
|
20
38
|
end
|
21
39
|
end
|
22
40
|
end
|
@@ -4,7 +4,7 @@ module LabClient
|
|
4
4
|
class SnippetNotes < Common
|
5
5
|
doc 'Snippets' do
|
6
6
|
title 'Create'
|
7
|
-
desc 'Creates a new note for a single
|
7
|
+
desc 'Creates a new note for a single snippet [Project, Snippet ID]'
|
8
8
|
example 'client.notes.snippets.create(16, 2, body: "Hello!")'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 44, type: Snippet>
|
@@ -5,18 +5,35 @@ module LabClient
|
|
5
5
|
@group_name = 'Notes'
|
6
6
|
doc 'Snippets' do
|
7
7
|
title 'List'
|
8
|
-
desc 'Gets a list of all notes for a single
|
8
|
+
desc 'Gets a list of all notes for a single snippet. [Project ID, Snippet ID]'
|
9
|
+
markdown <<~DOC
|
10
|
+
| Attribute | Type | Required | Description |
|
11
|
+
| --------- | ------ | -------- | ------------------------------------------------------------------------------------ |
|
12
|
+
| sort | string | no | Return snippet notes sorted in asc or desc order. Default is desc |
|
13
|
+
| order_by | string | no | Return snippet notes ordered by created_at or updated_at fields. Default is created_at |
|
14
|
+
DOC
|
15
|
+
end
|
16
|
+
|
17
|
+
doc 'Snippets' do
|
9
18
|
example 'client.notes.snippets.list(16, 1)'
|
10
19
|
result <<~DOC
|
11
20
|
=> [#<Note id: 21, type: Snippet>, #<Note id: 20, type: Snippet> .. ]
|
12
21
|
DOC
|
13
22
|
end
|
14
23
|
|
15
|
-
|
24
|
+
doc 'Snippets' do
|
25
|
+
desc 'Filter or Sort'
|
26
|
+
example 'client.notes.snippets.list(16, 1, order_by: :created_at, sort: :asc)'
|
27
|
+
result <<~DOC
|
28
|
+
=> [#<Note id: 21, type: Snippet>, #<Note id: 20, type: Snippet> .. ]
|
29
|
+
DOC
|
30
|
+
end
|
31
|
+
|
32
|
+
def list(project_id, snippet_id, query = {})
|
16
33
|
project_id = format_id(project_id)
|
17
34
|
snippet_id = format_id(snippet_id)
|
18
35
|
|
19
|
-
client.request(:get, "projects/#{project_id}/snippets/#{snippet_id}/notes", Note)
|
36
|
+
client.request(:get, "projects/#{project_id}/snippets/#{snippet_id}/notes", Note, query)
|
20
37
|
end
|
21
38
|
end
|
22
39
|
end
|
@@ -4,7 +4,7 @@ module LabClient
|
|
4
4
|
class SnippetNotes < Common
|
5
5
|
doc 'Snippets' do
|
6
6
|
title 'Show'
|
7
|
-
desc 'Returns a single note for a given
|
7
|
+
desc 'Returns a single note for a given snippet. [Project ID, Snippet ID, Note ID]'
|
8
8
|
example 'client.notes.snippets.show(16, 1, 43)'
|
9
9
|
result <<~DOC
|
10
10
|
=> #<Note id: 21, type: Snippet>
|
@@ -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
|
@@ -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
|
@@ -346,6 +346,10 @@ module LabClient
|
|
346
346
|
client.branches.show(id, branch_id)
|
347
347
|
end
|
348
348
|
|
349
|
+
def branch_create(query)
|
350
|
+
client.branches.create(id, query)
|
351
|
+
end
|
352
|
+
|
349
353
|
def branch_delete(branch_id)
|
350
354
|
client.branches.delete(id, branch_id)
|
351
355
|
end
|
@@ -620,6 +624,10 @@ module LabClient
|
|
620
624
|
client.merge_requests.list_project(id, query)
|
621
625
|
end
|
622
626
|
|
627
|
+
def merge_request_create(query)
|
628
|
+
client.merge_requests.create(id, query)
|
629
|
+
end
|
630
|
+
|
623
631
|
# Access Requests
|
624
632
|
def request_access
|
625
633
|
client.projects.access_requests.create(id)
|
@@ -687,6 +695,25 @@ module LabClient
|
|
687
695
|
update_self client.projects.show(id)
|
688
696
|
end
|
689
697
|
|
698
|
+
# Parent Helper
|
699
|
+
def parent
|
700
|
+
case namespace.kind
|
701
|
+
when 'user'
|
702
|
+
client.users.show(namespace.id)
|
703
|
+
when 'group'
|
704
|
+
client.groups.show(namespace.id)
|
705
|
+
end
|
706
|
+
end
|
707
|
+
|
708
|
+
# Snippets
|
709
|
+
def snippets
|
710
|
+
client.projects.snippets.list(id)
|
711
|
+
end
|
712
|
+
|
713
|
+
def snippet_create(query)
|
714
|
+
client.projects.snippets.create(id, query)
|
715
|
+
end
|
716
|
+
|
690
717
|
# Wait for Import / Set a Hard Limit
|
691
718
|
def wait_for_import(total_time = 300, sleep_time = 15)
|
692
719
|
# none
|
@@ -698,6 +725,7 @@ module LabClient
|
|
698
725
|
Timeout.timeout(total_time) do
|
699
726
|
loop do
|
700
727
|
reload
|
728
|
+
puts "Waiting for Import Status: #{import_status}"
|
701
729
|
break if %w[none finished].include? import_status
|
702
730
|
raise "Import Failed: #{import_error}" if import_status == 'failed'
|
703
731
|
|
@@ -204,6 +204,7 @@ module LabClient
|
|
204
204
|
# Branches
|
205
205
|
option 'branches', 'List repository branches [String]'
|
206
206
|
option 'branch', 'Get a single repository branches [Branch Name]'
|
207
|
+
option 'branch_create', 'Create a repository branches [Hash]'
|
207
208
|
option 'branch_delete', 'Delete a single repository branches [Branch Name]'
|
208
209
|
option 'branch_delete_merged', 'Will delete all branches that are merged into the project’s default branch'
|
209
210
|
|
@@ -241,6 +242,7 @@ module LabClient
|
|
241
242
|
|
242
243
|
# Merge Requests
|
243
244
|
option 'merge_requests', 'List project merge requests, [Hash]'
|
245
|
+
option 'merge_request_create', 'Create new merge request [Hash]'
|
244
246
|
|
245
247
|
# Access Requests
|
246
248
|
option 'access_requests', 'List access requests for project'
|
@@ -254,6 +256,9 @@ module LabClient
|
|
254
256
|
|
255
257
|
# Clusters
|
256
258
|
option 'clusters', 'Returns a list of project clusters.'
|
259
|
+
|
260
|
+
option 'events', 'List project events [Hash]'
|
261
|
+
option 'parent', 'Show (API Call) Project Parent, returns either Group or User'
|
257
262
|
end
|
258
263
|
end
|
259
264
|
# rubocop:enable Metrics/BlockLength, Metrics/ClassLength
|