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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79977702325d9d9a7df2569a8e1e948db351fc35deea828a832a548048efa7b3
4
- data.tar.gz: 1febe4b7a2eab857c37fc814b299678a35c86be61c8d346806c5d8092ea154af
3
+ metadata.gz: 6891782100fb734939767870fa735c9a0f34127582767b4b67c47bdad1f64646
4
+ data.tar.gz: 503518a6a45eba73b86bf44c8997d969cd78396210943753c59e330fe06b3be4
5
5
  SHA512:
6
- metadata.gz: 14eabf457805cece5387012fcd28ae9922ce554a6981aa21653d98404b274e6438b49686e0b6a7f8f3dbd14f16520089c58141ff08f2310c5314b52d31facc6c
7
- data.tar.gz: 93b298936e970390a1886e03ddb4473d57df7adcfe75be983770fe09d5674cd5544776abd239c02c11a9ab93445aeee10c77fcb7cd2236e884174d844eec4e9b
6
+ metadata.gz: b8f5c439041953cf54681ead1caddc945e913d397cfb3b5b12d3abe81415bcebe0878c5cf13f4c541c1bc7481035d490144d429ac0e37adb82f02da21199f906
7
+ data.tar.gz: d160894003a7d1e48fbc952a6f3e8c27de913816162938b4b77bb67114e3294e04ce46ef866e08ca0696e6cbbb4f2762d7f811cee6721f6b8c4c447fc22e6c85
@@ -3,7 +3,7 @@ require 'oj'
3
3
  require 'pry'
4
4
  require 'typhoeus'
5
5
  require 'active_support/all'
6
- require 'awesome_print'
6
+ require 'amazing_print'
7
7
  require 'gitlab_chronic_duration'
8
8
  require 'ostruct'
9
9
 
@@ -13,8 +13,8 @@ require 'labclient/http'
13
13
  require 'labclient/access_levels'
14
14
  require 'labclient/common'
15
15
  require 'labclient/curl'
16
+ require 'labclient/lab_struct'
16
17
  require 'labclient/klass'
17
- require 'labclient/open_struct'
18
18
  require 'labclient/class_helpers'
19
19
  require 'labclient/paginated_response'
20
20
  require 'labclient/error'
@@ -36,7 +36,6 @@ require 'labclient/users/current'
36
36
  require 'labclient/users/status'
37
37
  require 'labclient/users/counts'
38
38
  require 'labclient/users/activity'
39
- require 'labclient/users/memberships'
40
39
  require 'labclient/users/search'
41
40
  require 'labclient/users/create'
42
41
  require 'labclient/users/update'
@@ -47,47 +46,10 @@ require 'labclient/users/activate'
47
46
  require 'labclient/users/deactivate'
48
47
  require 'labclient/users/delete'
49
48
  require 'labclient/users/delete_identity'
49
+ require 'labclient/users/memberships'
50
+ require 'labclient/users/membership'
50
51
  require 'labclient/users/user'
51
52
 
52
- # User Keys
53
- require 'labclient/users/keys/client'
54
- require 'labclient/users/keys/list'
55
- require 'labclient/users/keys/show'
56
- require 'labclient/users/keys/create'
57
- require 'labclient/users/keys/delete'
58
-
59
- # Notifications
60
- require 'labclient/notifications/list'
61
- require 'labclient/notifications/update'
62
-
63
- # User GPG Keys
64
- require 'labclient/users/gpg/client'
65
- require 'labclient/users/gpg/list'
66
- require 'labclient/users/gpg/show'
67
- require 'labclient/users/gpg/create'
68
- require 'labclient/users/gpg/delete'
69
- require 'labclient/users/gpg/gpg_key'
70
-
71
- # User Emails
72
- require 'labclient/users/email/client'
73
- require 'labclient/users/email/list'
74
- require 'labclient/users/email/show'
75
- require 'labclient/users/email/create'
76
- require 'labclient/users/email/delete'
77
- require 'labclient/users/email/email'
78
-
79
- # Impersonation Tokens
80
- require 'labclient/impersonation_tokens/impersonation_token'
81
- require 'labclient/impersonation_tokens/list'
82
- require 'labclient/impersonation_tokens/show'
83
- require 'labclient/impersonation_tokens/create'
84
- require 'labclient/impersonation_tokens/revoke'
85
-
86
- # Namespaces
87
- require 'labclient/namespaces/namespace'
88
- require 'labclient/namespaces/list'
89
- require 'labclient/namespaces/show'
90
-
91
53
  # ===============================================
92
54
  # Projects
93
55
  # ===============================================
@@ -116,6 +78,9 @@ require 'labclient/projects/restore'
116
78
  require 'labclient/projects/snapshot'
117
79
  require 'labclient/projects/github_import'
118
80
 
81
+ # Group Stub / Docs ORder
82
+ require 'labclient/groups/stub'
83
+
119
84
  # Project Forks
120
85
  require 'labclient/projects/forks/list'
121
86
  require 'labclient/projects/forks/fork'
@@ -185,6 +150,13 @@ require 'labclient/projects/environments/delete'
185
150
  require 'labclient/projects/environments/stop'
186
151
  require 'labclient/projects/environments/project_environment'
187
152
 
153
+ # Protected Environments
154
+ require 'labclient/protected_environments/list'
155
+ require 'labclient/protected_environments/show'
156
+ require 'labclient/protected_environments/protect'
157
+ require 'labclient/protected_environments/unprotect'
158
+ require 'labclient/protected_environments/protected_environment'
159
+
188
160
  # Project Deployments
189
161
  require 'labclient/projects/deployments/client'
190
162
  require 'labclient/projects/deployments/list'
@@ -684,6 +656,45 @@ require 'labclient/notes/epics/delete'
684
656
  require 'labclient/notes/note'
685
657
  # -----------------------------------
686
658
 
659
+ # User Keys
660
+ require 'labclient/users/keys/client'
661
+ require 'labclient/users/keys/list'
662
+ require 'labclient/users/keys/show'
663
+ require 'labclient/users/keys/create'
664
+ require 'labclient/users/keys/delete'
665
+
666
+ # Notifications
667
+ require 'labclient/notifications/list'
668
+ require 'labclient/notifications/update'
669
+
670
+ # User GPG Keys
671
+ require 'labclient/users/gpg/client'
672
+ require 'labclient/users/gpg/list'
673
+ require 'labclient/users/gpg/show'
674
+ require 'labclient/users/gpg/create'
675
+ require 'labclient/users/gpg/delete'
676
+ require 'labclient/users/gpg/gpg_key'
677
+
678
+ # User Emails
679
+ require 'labclient/users/email/client'
680
+ require 'labclient/users/email/list'
681
+ require 'labclient/users/email/show'
682
+ require 'labclient/users/email/create'
683
+ require 'labclient/users/email/delete'
684
+ require 'labclient/users/email/email'
685
+
686
+ # Impersonation Tokens
687
+ require 'labclient/impersonation_tokens/impersonation_token'
688
+ require 'labclient/impersonation_tokens/list'
689
+ require 'labclient/impersonation_tokens/show'
690
+ require 'labclient/impersonation_tokens/create'
691
+ require 'labclient/impersonation_tokens/revoke'
692
+
693
+ # Namespaces
694
+ require 'labclient/namespaces/namespace'
695
+ require 'labclient/namespaces/list'
696
+ require 'labclient/namespaces/show'
697
+
687
698
  # Runners
688
699
  require 'labclient/runners/list'
689
700
  require 'labclient/runners/all'
@@ -765,6 +776,7 @@ require 'labclient/files/delete'
765
776
  # Branches
766
777
  require 'labclient/branches/list'
767
778
  require 'labclient/branches/show'
779
+ require 'labclient/branches/create'
768
780
  require 'labclient/branches/delete'
769
781
  require 'labclient/branches/delete_merged'
770
782
  require 'labclient/branches/branch'
@@ -839,5 +851,16 @@ require 'labclient/resource_labels/merge_requests/show'
839
851
 
840
852
  require 'labclient/resource_labels/resource_label'
841
853
 
854
+ # Generators
855
+ require 'labclient/generator/names'
856
+ require 'labclient/generator/template_helper' # Default Include Template
857
+
858
+ # Wizard
859
+ require 'labclient/generator/generator'
860
+ require 'labclient/generator/wizard'
861
+
862
+ # Dynamically Require Templates (Simplify new template creation)
863
+ Dir[File.dirname(__FILE__) + '/labclient/generator/templates/*.rb'].sort.each { |file| require file }
864
+
842
865
  # I am Very Last
843
866
  require 'labclient/client'
@@ -11,5 +11,30 @@ module LabClient
11
11
  def commit
12
12
  Commit.new(@table[:commit], response, client)
13
13
  end
14
+
15
+ def pipelines
16
+ project_id = collect_project_id
17
+ client.pipelines.list(project_id, ref: name)
18
+ end
19
+
20
+ # Wait for Import / Set a Hard Limit
21
+ def wait_for_pipelines(total_time = 300, sleep_time = 15)
22
+ Timeout.timeout(total_time) do
23
+ loop do
24
+ reload
25
+ puts 'Waiting for Pipelines'
26
+ break unless pipelines.empty?
27
+
28
+ sleep sleep_time
29
+ end
30
+ end
31
+ end
32
+
33
+ help do
34
+ subtitle 'Branch'
35
+ option 'commit', 'Show Commit information for branch'
36
+ option 'pipelines', 'Show Pipelines for this Branch/Ref'
37
+ option 'wait_for_pipelines', 'Looping, on newly created branches, wait for pipelines to populate (not finish) [Timeout, Interval]'
38
+ end
14
39
  end
15
40
  end
@@ -0,0 +1,33 @@
1
+ # Top namespace
2
+ module LabClient
3
+ # Specifics
4
+ class Branches < Common
5
+ doc 'Create' do
6
+ desc 'Get a list of repository branches from a project, sorted by name alphabetically. [Project ID, String]'
7
+ example 'client.branches.create(264, branch: :branch, ref: :master)'
8
+ result '[#<Branch name: feature>, #<Branch name: master>]'
9
+
10
+ markdown <<~DOC
11
+ | Attribute | Type | Required | Description |
12
+ |----------|--------|---------|-------------------------------------------------------------------------------------------------------------|
13
+ | id | integer | yes | ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user. |
14
+ | branch | string | yes | Name of the branch. |
15
+ | ref | string | yes | Branch name or commit SHA to create branch from. |
16
+ DOC
17
+ end
18
+
19
+ doc 'Create' do
20
+ desc 'via Project'
21
+ example <<~DOC
22
+ project = client.projects.show(264)
23
+ project.branch_create(branch: :branch, ref: :master)
24
+ DOC
25
+ end
26
+
27
+ def create(project_id, query)
28
+ project_id = format_id(project_id)
29
+
30
+ client.request(:post, "projects/#{project_id}/repository/branches", Branch, query)
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,7 @@
1
1
  # Top Namespace
2
2
  module LabClient
3
3
  # API Specifics
4
+ # rubocop:disable Metrics/ClassLength
4
5
  class Client
5
6
  # include HTTParty
6
7
  attr_accessor :settings, :resp, :klass, :link, :http
@@ -37,6 +38,7 @@ module LabClient
37
38
  epics: Epics,
38
39
  events: Events,
39
40
  files: Files,
41
+ wizard: Generator::Wizard,
40
42
  groups: Groups,
41
43
  impersonation_tokens: ImpersonationTokens,
42
44
  issues: Issues,
@@ -54,6 +56,7 @@ module LabClient
54
56
  project_runners: ProjectRunners,
55
57
  projects: Projects,
56
58
  protected_branches: ProtectedBranches,
59
+ protected_environments: ProtectedEnvironments,
57
60
  protected_tags: ProtectedTags,
58
61
  registry: Registry,
59
62
  repo: Repositories,
@@ -90,18 +93,33 @@ module LabClient
90
93
  end
91
94
 
92
95
  # Default setup, pull in settings
93
- def initialize(settings = nil)
94
- @settings = settings
96
+ def initialize(user_settings = nil)
97
+ @settings = user_settings
98
+ setup_profile if user_settings&.key?(:profile) || ENV['LABCLIENT_PROFILE']
95
99
  @settings ||= fill_configuration
96
100
 
97
101
  # Set Unspecified Defaults
98
102
  unspecified_defaults
99
103
 
100
- raise 'LabClient Error - Missing URL!' if @settings[:url].nil?
104
+ prompt_for_url if @settings[:url].blank?
105
+
106
+ # Only prompt if explicitly set to nil
107
+ prompt_for_token if @settings[:token].nil?
101
108
 
102
109
  self.http = HTTP.new(@settings)
103
110
  end
104
111
 
112
+ def prompt_for_url
113
+ print 'Enter GitLab URL (e.g. https://gitlab.com): '
114
+ @settings[:url] = STDIN.gets.chomp
115
+ raise 'LabClient Error - Missing URL!' if @settings[:url].blank?
116
+ end
117
+
118
+ def prompt_for_token
119
+ print 'Enter Personal Access Token: '
120
+ @settings[:token] = STDIN.gets.chomp
121
+ end
122
+
105
123
  def unspecified_defaults
106
124
  @settings[:paginate] = true if @settings[:paginate].nil?
107
125
  @settings[:ssl_verify] = true if @settings[:ssl_verify].nil?
@@ -111,6 +129,27 @@ module LabClient
111
129
  ENV['HOME'] + '/.gitlab-labclient'
112
130
  end
113
131
 
132
+ # Easier Profile Name Access
133
+ def profile
134
+ if settings&.key? :profile
135
+ settings[:profile].to_sym
136
+ else
137
+ ENV['LABCLIENT_PROFILE'].to_sym
138
+ end
139
+ end
140
+
141
+ # Support for Named Profiles
142
+ def setup_profile
143
+ return false unless File.exist? home_file
144
+
145
+ config = Oj.load_file(home_file, { symbol_keys: true })
146
+ return false unless config.key? profile
147
+
148
+ self.settings ||= {}
149
+ settings.merge! config[profile]
150
+ end
151
+
152
+ # Load default profile
114
153
  def fill_configuration
115
154
  if File.exist? home_file
116
155
  Oj.load_file(home_file, { symbol_keys: true })
@@ -138,10 +177,10 @@ module LabClient
138
177
  resp
139
178
  end
140
179
 
141
- # Assume we want OpenStruct if @klass is ever nil
180
+ # Assume we want LabStruct if @klass is ever nil
142
181
  def process(resp)
143
182
  case resp.data
144
- when OpenStruct
183
+ when LabStruct
145
184
  klass ? klass.new(resp.data, resp, self) : resp.data
146
185
  when Array
147
186
  if @klass.nil?
@@ -154,4 +193,5 @@ module LabClient
154
193
  end
155
194
  end
156
195
  end
196
+ # rubocop:enable Metrics/ClassLength
157
197
  end
@@ -72,6 +72,11 @@ module LabClient
72
72
  CGI.escape obj_id.to_s
73
73
  end
74
74
 
75
+ def format_query_id(key, query)
76
+ query[key] = format_id(query[key]) if query.key? key
77
+ query[key.to_s] = format_id(query[key.to_s]) if query.key? key.to_s
78
+ end
79
+
75
80
  def format_query_ids(key, query)
76
81
  query[key] = query[key].map { |x| format_id(x) } if query.key? key
77
82
 
@@ -50,10 +50,14 @@ module LabClient
50
50
  end
51
51
 
52
52
  def desc(value)
53
- # @result[:desc] = simple_format value
54
53
  @result[:desc] = value
55
54
  end
56
55
 
56
+ def demo(value)
57
+ @result[:demo_url] = "https://asciinema.org/a/#{value}.js"
58
+ @result[:demo] = "<script id='asciicast-#{value}' src='#{@result[:demo_url]}' data-autoplay='true' data-loop='true' async></script>"
59
+ end
60
+
57
61
  def example(value)
58
62
  @result[:example] = value
59
63
  end
@@ -51,6 +51,15 @@ module LabClient
51
51
  client.resource_labels.epics.show(group_id, id, resource_event_id)
52
52
  end
53
53
 
54
+ # Notes
55
+ def notes
56
+ client.notes.epics.list(group_id, iid)
57
+ end
58
+
59
+ def note_create(query)
60
+ client.notes.epics.create(group_id, iid, query)
61
+ end
62
+
54
63
  date_time_attrs %i[created_at closed_at updated_at]
55
64
 
56
65
  help do
@@ -64,6 +73,10 @@ module LabClient
64
73
  option 'issue_remove', 'Remove issue from Epic [Epic Issue ID]'
65
74
  option 'issue_update', 'Update issue association [Epic Issue ID, Hash]'
66
75
 
76
+ # Notes
77
+ option 'notes', 'List notes/comments. [Hash]'
78
+ option 'note_create', 'Creates a new note. [Hash]'
79
+
67
80
  # Resource Labels
68
81
  option 'resource_labels', 'List of all label events'
69
82
  option 'resource_label', 'Show single label event [Resource Event ID]'
@@ -3,6 +3,7 @@ module LabClient
3
3
  # Class Shim
4
4
  class Error < StandardError
5
5
  attr_reader :resp
6
+
6
7
  def initialize(resp)
7
8
  super
8
9
  @resp = resp
@@ -16,15 +16,18 @@ module LabClient
16
16
  result '{:file_path=>"new.md", :branch=>"master"}'
17
17
 
18
18
  markdown <<~DOC
19
- **Parameters**:
19
+ Parameters
20
+
21
+ | **Attribute** | **Required** | **Description** |
22
+ | -------------- | ------------ | ----------------------------------------------- |
23
+ | branch | yes | Name of the branch |
24
+ | content | yes | File content |
25
+ | start_branch | no | Name of the branch to start the new commit from |
26
+ | encoding | no | Change encoding to ‘base64’. Default is text. |
27
+ | author_email | no | Specify the commit author’s email address |
28
+ | author_name | no | Specify the commit author’s name |
29
+ | commit_message | no | Commit message |
20
30
 
21
- * branch (required) - Name of the branch
22
- * start_branch (optional) - Name of the branch to start the new commit from
23
- * encoding (optional) - Change encoding to ‘base64’. Default is text.
24
- * author_email (optional) - Specify the commit author’s email address
25
- * author_name (optional) - Specify the commit author’s name
26
- * content (required) - File content
27
- * commit_message (required) - Commit message
28
31
 
29
32
  DOC
30
33
  end
@@ -43,6 +46,9 @@ module LabClient
43
46
  def create(project_id, file_path, query)
44
47
  project_id = format_id(project_id)
45
48
 
49
+ # Path Name Encoding
50
+ file_path = CGI.escape(file_path)
51
+
46
52
  client.request(:post, "projects/#{project_id}/repository/files/#{file_path}", nil, query)
47
53
  end
48
54
  end