labclient 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/lib/labclient.rb +65 -42
  3. data/lib/labclient/branches/branch.rb +25 -0
  4. data/lib/labclient/branches/create.rb +33 -0
  5. data/lib/labclient/client.rb +45 -5
  6. data/lib/labclient/common.rb +5 -0
  7. data/lib/labclient/docs.rb +5 -1
  8. data/lib/labclient/epics/epic.rb +13 -0
  9. data/lib/labclient/error.rb +1 -0
  10. data/lib/labclient/files/create.rb +14 -8
  11. data/lib/labclient/generator/generator.rb +70 -0
  12. data/lib/labclient/generator/names.rb +68 -0
  13. data/lib/labclient/generator/template_helper.rb +82 -0
  14. data/lib/labclient/generator/templates/environments.rb +98 -0
  15. data/lib/labclient/generator/templates/pages.rb +67 -0
  16. data/lib/labclient/generator/templates/pipeline_trigger.rb +82 -0
  17. data/lib/labclient/generator/wizard.rb +142 -0
  18. data/lib/labclient/groups/group.rb +17 -0
  19. data/lib/labclient/groups/stub.rb +8 -0
  20. data/lib/labclient/http.rb +8 -3
  21. data/lib/labclient/issues/agent_detail.rb +1 -1
  22. data/lib/labclient/issues/closed_by.rb +1 -1
  23. data/lib/labclient/issues/create.rb +17 -5
  24. data/lib/labclient/issues/delete.rb +1 -1
  25. data/lib/labclient/issues/issue.rb +21 -1
  26. data/lib/labclient/issues/move.rb +1 -1
  27. data/lib/labclient/issues/participants.rb +1 -1
  28. data/lib/labclient/issues/related_merge_requests.rb +1 -1
  29. data/lib/labclient/issues/show.rb +1 -1
  30. data/lib/labclient/issues/subscribe.rb +1 -1
  31. data/lib/labclient/issues/time_stats.rb +5 -5
  32. data/lib/labclient/issues/todo.rb +1 -1
  33. data/lib/labclient/issues/unsubscribe.rb +1 -1
  34. data/lib/labclient/issues/update.rb +1 -1
  35. data/lib/labclient/klass.rb +35 -3
  36. data/lib/labclient/lab_struct.rb +17 -0
  37. data/lib/labclient/license/list.rb +2 -2
  38. data/lib/labclient/members/member.rb +1 -0
  39. data/lib/labclient/merge_requests/accept.rb +16 -7
  40. data/lib/labclient/merge_requests/cancel_auto_merge.rb +1 -1
  41. data/lib/labclient/merge_requests/changes.rb +1 -1
  42. data/lib/labclient/merge_requests/closes_issues.rb +1 -1
  43. data/lib/labclient/merge_requests/commits.rb +1 -1
  44. data/lib/labclient/merge_requests/create.rb +12 -0
  45. data/lib/labclient/merge_requests/delete.rb +1 -1
  46. data/lib/labclient/merge_requests/diff_versions.rb +1 -1
  47. data/lib/labclient/merge_requests/merge_request.rb +49 -4
  48. data/lib/labclient/merge_requests/participants.rb +1 -1
  49. data/lib/labclient/merge_requests/pipelines.rb +2 -2
  50. data/lib/labclient/merge_requests/rebase.rb +1 -1
  51. data/lib/labclient/merge_requests/show.rb +1 -1
  52. data/lib/labclient/merge_requests/subscribe.rb +1 -1
  53. data/lib/labclient/merge_requests/time_stats.rb +5 -5
  54. data/lib/labclient/merge_requests/todo.rb +1 -1
  55. data/lib/labclient/merge_requests/unsubscribe.rb +1 -1
  56. data/lib/labclient/merge_requests/update.rb +1 -1
  57. data/lib/labclient/notes/epics/create.rb +12 -4
  58. data/lib/labclient/notes/epics/delete.rb +3 -3
  59. data/lib/labclient/notes/epics/list.rb +21 -4
  60. data/lib/labclient/notes/epics/show.rb +4 -4
  61. data/lib/labclient/notes/epics/update.rb +4 -4
  62. data/lib/labclient/notes/issues/create.rb +11 -1
  63. data/lib/labclient/notes/issues/list.rb +18 -3
  64. data/lib/labclient/notes/issues/show.rb +1 -1
  65. data/lib/labclient/notes/merge_requests/create.rb +8 -0
  66. data/lib/labclient/notes/merge_requests/list.rb +20 -2
  67. data/lib/labclient/notes/snippets/create.rb +1 -1
  68. data/lib/labclient/notes/snippets/list.rb +20 -3
  69. data/lib/labclient/notes/snippets/show.rb +1 -1
  70. data/lib/labclient/notifications/update.rb +1 -1
  71. data/lib/labclient/overview.rb +117 -16
  72. data/lib/labclient/paginated_response.rb +6 -1
  73. data/lib/labclient/pipelines/pipeline.rb +41 -0
  74. data/lib/labclient/projects/access_requests/access_request.rb +0 -1
  75. data/lib/labclient/projects/badges/project_badge.rb +0 -1
  76. data/lib/labclient/projects/clusters/project_cluster.rb +0 -1
  77. data/lib/labclient/projects/create.rb +13 -0
  78. data/lib/labclient/projects/deployments/project_deployment.rb +1 -3
  79. data/lib/labclient/projects/environments/project_environment.rb +0 -1
  80. data/lib/labclient/projects/forks/existing.rb +0 -2
  81. data/lib/labclient/projects/forks/fork.rb +1 -1
  82. data/lib/labclient/projects/forks/list.rb +0 -1
  83. data/lib/labclient/projects/forks/remove.rb +0 -1
  84. data/lib/labclient/projects/hooks/project_hook.rb +0 -1
  85. data/lib/labclient/projects/labels/project_label.rb +0 -1
  86. data/lib/labclient/projects/methods.rb +76 -2
  87. data/lib/labclient/projects/mirrors/project_mirror.rb +0 -1
  88. data/lib/labclient/projects/reference.rb +17 -0
  89. data/lib/labclient/projects/release_links/project_release_link.rb +0 -1
  90. data/lib/labclient/projects/releases/project_release.rb +0 -1
  91. data/lib/labclient/projects/services/project_service.rb +0 -1
  92. data/lib/labclient/projects/snippets/project_snippet.rb +12 -0
  93. data/lib/labclient/projects/stars/star.rb +0 -2
  94. data/lib/labclient/projects/stars/starred_projects.rb +0 -2
  95. data/lib/labclient/projects/stars/starrers.rb +1 -1
  96. data/lib/labclient/projects/triggers/project_trigger.rb +0 -1
  97. data/lib/labclient/projects/variables/project_variable.rb +0 -1
  98. data/lib/labclient/protected_branches/protect.rb +6 -5
  99. data/lib/labclient/protected_environments/list.rb +29 -0
  100. data/lib/labclient/protected_environments/protect.rb +53 -0
  101. data/lib/labclient/protected_environments/protected_environment.rb +22 -0
  102. data/lib/labclient/protected_environments/show.rb +24 -0
  103. data/lib/labclient/protected_environments/unprotect.rb +31 -0
  104. data/lib/labclient/snippets/snippet.rb +2 -2
  105. data/lib/labclient/users/membership.rb +62 -0
  106. data/lib/labclient/users/memberships.rb +8 -3
  107. data/lib/labclient/users/user.rb +13 -1
  108. data/lib/labclient/version.rb +1 -1
  109. metadata +38 -9
  110. data/lib/labclient/open_struct.rb +0 -14
@@ -4,7 +4,7 @@ module LabClient
4
4
  class MergeRequests < Common
5
5
  doc 'Update' do
6
6
  title 'Todo'
7
- desc 'Manually creates a todo for the current user on a merge request. [project id, merge request iid]'
7
+ desc 'Manually creates a todo for the current user on a merge request. [Project ID, merge request iid]'
8
8
 
9
9
  example 'client.merge_requests.todo(343, 7)'
10
10
 
@@ -4,7 +4,7 @@ module LabClient
4
4
  class MergeRequests < Common
5
5
  doc 'Update' do
6
6
  title 'Unsubscribe'
7
- desc 'Subscribes the authenticated user to a merge request to receive notification. [project id, merge request iid]'
7
+ desc 'Subscribes the authenticated user to a merge request to receive notification. [Project ID, merge request iid]'
8
8
 
9
9
  example 'client.merge_requests.unsubscribe(343, 7)'
10
10
 
@@ -3,7 +3,7 @@ module LabClient
3
3
  # Specifics
4
4
  class MergeRequests < Common
5
5
  doc 'Update' do
6
- desc 'Updates an existing merge request. You can change the target branch, title, or even close the MR. [project id, merge request iid]'
6
+ desc 'Updates an existing merge request. You can change the target branch, title, or even close the MR. [Project ID, merge request iid]'
7
7
 
8
8
  example <<~DOC
9
9
  client.merge_requests.update(343, 2, {
@@ -4,13 +4,21 @@ 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 merge request [Project, Epic IID]'
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>
11
11
  DOC
12
12
  end
13
13
 
14
+ doc 'Epics' do
15
+ desc 'Via Epic'
16
+ example <<~DOC
17
+ epic = client.epics.show(16, 2)
18
+ epic.note_create(body: 'There!')
19
+ DOC
20
+ end
21
+
14
22
  doc 'Epics' do
15
23
  markdown <<~DOC
16
24
  | Attribute | Type | Required | Description |
@@ -20,13 +28,13 @@ module LabClient
20
28
  DOC
21
29
  end
22
30
 
23
- def create(project_id, epic_id, query = {})
24
- project_id = format_id(project_id)
31
+ def create(group_id, epic_id, query = {})
32
+ group_id = format_id(group_id)
25
33
  epic_id = format_id(epic_id)
26
34
 
27
35
  query[:created_at] = query[:created_at].to_time.iso8601 if format_time?(query[:created_at])
28
36
 
29
- client.request(:post, "projects/#{project_id}/epics/#{epic_id}/notes", Note, query)
37
+ client.request(:post, "groups/#{group_id}/epics/#{epic_id}/notes", Note, query)
30
38
  end
31
39
  end
32
40
  end
@@ -9,12 +9,12 @@ module LabClient
9
9
  end
10
10
 
11
11
  # Delete
12
- def delete(project_id, epic_id, note_id)
13
- project_id = format_id(project_id)
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, "projects/#{project_id}/epics/#{epic_id}/notes/#{note_id}")
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 merge request. [Project ID, Epic IID]'
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
- def list(project_id, epic_id)
16
- project_id = format_id(project_id)
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, "projects/#{project_id}/epics/#{epic_id}/notes", Note)
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 merge request. [Project ID, Epic IID, Note ID]'
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(project_id, epic_id, note_id)
15
- project_id = format_id(project_id)
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, "projects/#{project_id}/epics/#{epic_id}/notes/#{note_id}", Note)
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 project epic. [Project ID, Epic IID, Note ID]'
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(project_id, epic_id, note_id, body)
24
- project_id = format_id(project_id)
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, "projects/#{project_id}/epics/#{epic_id}/notes/#{note_id}", Note, query)
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,13 +4,21 @@ 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 merge request [Project, Issue IID]'
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>
11
11
  DOC
12
12
  end
13
13
 
14
+ doc 'Issues' do
15
+ desc 'Via Issue'
16
+ example <<~DOC
17
+ issue = client.issues.show(16, 1)
18
+ issue.note_create(body: 'There!')
19
+ DOC
20
+ end
21
+
14
22
  doc 'Issues' do
15
23
  markdown <<~DOC
16
24
  | Attribute | Type | Required | Description |
@@ -26,6 +34,8 @@ module LabClient
26
34
 
27
35
  query[:created_at] = query[:created_at].to_time.iso8601 if format_time?(query[:created_at])
28
36
 
37
+ # POST /projects/:id/issues/:issue_iid/notes
38
+
29
39
  client.request(:post, "projects/#{project_id}/issues/#{issue_id}/notes", Note, query)
30
40
  end
31
41
  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 merge request. [Project ID, Issue IID]'
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
- def list(project_id, issue_id)
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 merge request. [Project ID, Issue IID, Note ID]'
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>
@@ -11,6 +11,14 @@ module LabClient
11
11
  DOC
12
12
  end
13
13
 
14
+ doc 'Merge Request' do
15
+ desc 'Via Merge Request'
16
+ example <<~DOC
17
+ merge_request = client.merge_requests.show(16, 2)
18
+ merge_request.note_create(body: 'There!')
19
+ DOC
20
+ end
21
+
14
22
  doc 'Merge Requests' do
15
23
  markdown <<~DOC
16
24
  | Attribute | Type | Required | Description |
@@ -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
- def list(project_id, merge_request_id)
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 merge request [Project, Snippet ID]'
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 merge request. [Project ID, Snippet ID]'
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
- def list(project_id, snippet_id)
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 merge request. [Project ID, Snippet ID, Note ID]'
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,7 +33,7 @@ module LabClient
33
33
  result <<~DOC
34
34
  OpenStruct {
35
35
  :level => "custom",
36
- :events => OpenStruct {
36
+ :events => LabStruct {
37
37
  :new_release => nil,
38
38
  :new_note => nil,
39
39
  :new_issue => nil,
@@ -7,11 +7,15 @@ module LabClient
7
7
 
8
8
  doc 'Overview' do
9
9
  title 'About'
10
- desc <<~DOC
10
+ markdown <<~DOC
11
11
  Labclient is another Gitlab API Gem. A focus on ease of use and helpers and snippets.
12
12
 
13
13
  <a href="https://github.com/NARKOZ/gitlab">Gitlab</a> is an excellent gem, and is nearly complete in its implementation. While this is still a work in progress and you are looking for general use you should use it.
14
+
15
+ Here's a quick whirlwind example of some of the features:
14
16
  DOC
17
+
18
+ demo '350689'
15
19
  end
16
20
 
17
21
  doc 'Overview' do
@@ -44,6 +48,41 @@ module LabClient
44
48
  DOC
45
49
  end
46
50
 
51
+ doc 'Authentication' do
52
+ title 'Named Profiles'
53
+ markdown 'Within the `~/.gitlab-labclient` you can also specify profile names'
54
+ example <<~DOC
55
+ {
56
+ "prod": {
57
+ "url": "https://labclient-prod",
58
+ "token": "super_secure",
59
+ "paginate": false
60
+ },
61
+ "dev": {
62
+ "url": "https://labclient-dev",
63
+ "token": "super_secure",
64
+ "ssl_verify": false,
65
+ "paginate": true
66
+ }
67
+ }
68
+ DOC
69
+ end
70
+
71
+ doc 'Authentication' do
72
+ desc 'Manually select a named profile'
73
+ example <<~DOC
74
+ client = LabClient::Client.new(profile: 'prod')
75
+ DOC
76
+ end
77
+
78
+ doc 'Authentication' do
79
+ desc 'Automatically select via ENV Variables'
80
+ example <<~DOC
81
+ ENV['LABCLIENT_PROFILE'] = 'dev'
82
+ client = LabClient::Client.new
83
+ DOC
84
+ end
85
+
47
86
  doc 'Authentication' do
48
87
  title 'Environment Variables'
49
88
  desc 'If not provided, and credentials file does not exist will attempt to use ENV variables'
@@ -143,6 +182,27 @@ module LabClient
143
182
  DOC
144
183
  end
145
184
 
185
+ doc 'Response' do
186
+ title 'Status'
187
+ desc 'Each object/call will return a "response" object or the instantiated class object. On each of these you can use "success?" to verify the response of a call.'
188
+
189
+ result <<~DOC
190
+ project = client.projects.show 123123
191
+ # => #<TyphoeusResponse code: 404>
192
+ project.success?
193
+ # => false
194
+
195
+ user = client.users.show 1
196
+ => #<User id: 1, username: root>
197
+ user.success?
198
+ => true
199
+ DOC
200
+
201
+ result <<~DOC
202
+ curl -k -H "Private-Token: super_secret_token" -H "Accept: application/json" "https://labclient/api/v4/users?"
203
+ DOC
204
+ end
205
+
146
206
  doc 'Other' do
147
207
  title 'Common Helpers'
148
208
  markdown <<~DOC
@@ -173,6 +233,38 @@ module LabClient
173
233
  DOC
174
234
  end
175
235
 
236
+ doc 'Other' do
237
+ title 'Object Helpers'
238
+ markdown <<~DOC
239
+ Each created object will have additional helper methods
240
+ DOC
241
+
242
+ result <<~DOC
243
+ project = client.projects.show(5)
244
+
245
+ # Awesome Print all details
246
+ project.verbose
247
+
248
+ # Awesome Print all details
249
+ project.valid_group_project_levels
250
+ # => [:guest, :reporter, :developer, :maintainer, :owner]
251
+ DOC
252
+ end
253
+
254
+ doc 'Other' do
255
+ desc 'Object Help'
256
+
257
+ result <<~DOC
258
+ project = client.projects.show(5)
259
+
260
+ # List Possible Methods
261
+ project.help
262
+
263
+ # Array result of methods
264
+ project.api_methods
265
+ DOC
266
+ end
267
+
176
268
  doc 'Other' do
177
269
  title 'Object IDs'
178
270
 
@@ -199,21 +291,6 @@ module LabClient
199
291
  DOC
200
292
  end
201
293
 
202
- doc 'Other' do
203
- title 'Docker'
204
- desc 'A docker image is created from master and can be used to execute snippets or load a quick pry session'
205
-
206
- example 'docker run -it registry.gitlab.com/labclient/labclient'
207
-
208
- result <<~DOC
209
- # Run Container
210
- docker run -it -e LABCLIENT_URL="https://labclient" -e LABCLIENT_TOKEN="token" registry.gitlab.com/labclient/labclient
211
-
212
- client = LabClient::Client.new
213
- client.users.list
214
- DOC
215
- end
216
-
217
294
  doc 'Other' do
218
295
  title 'Curl'
219
296
  desc 'Sometimes you just wana have a curl example to test or send someone'
@@ -238,6 +315,30 @@ module LabClient
238
315
  - [API Authentication](https://docs.gitlab.com/ee/api/README.html#authentication)
239
316
  DOC
240
317
  end
318
+
319
+ doc 'Docker' do
320
+ desc 'A docker image is created from master and can be used to execute snippets or load a quick pry session'
321
+
322
+ example 'docker run -it registry.gitlab.com/labclient/labclient'
323
+
324
+ result <<~DOC
325
+ # Run Container
326
+ docker run -it registry.gitlab.com/labclient/labclient
327
+ # Without settings configured, initial will prompt for credentials
328
+
329
+ client.users.list
330
+ DOC
331
+ end
332
+
333
+ doc 'Docker' do
334
+ desc 'The docker container configured and execute code snippets'
335
+
336
+ example 'docker run -it registry.gitlab.com/labclient/labclient'
337
+
338
+ result <<~DOC
339
+ docker run -it -e LABCLIENT_URL="https://labclient" -e LABCLIENT_TOKEN="secure_token" labclient 'puts client.users.list.count'
340
+ DOC
341
+ end
241
342
  end
242
343
  end
243
344
  # rubocop:enable Metrics/ClassLength