labclient 0.3.5 → 0.5.1
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/branches/branch.rb +1 -1
- data/lib/labclient/client/helpers.rb +116 -0
- data/lib/labclient/client/meta.rb +81 -0
- data/lib/labclient/client/setup.rb +53 -0
- data/lib/labclient/client.rb +41 -162
- data/lib/labclient/common.rb +9 -4
- data/lib/labclient/docs.rb +6 -1
- data/lib/labclient/epics/issues/remove.rb +1 -1
- data/lib/labclient/epics/issues/update.rb +1 -1
- data/lib/labclient/error.rb +9 -0
- data/lib/labclient/feature_flags/list.rb +1 -1
- data/lib/labclient/files/show.rb +5 -5
- data/lib/labclient/generator/template_helper.rb +4 -3
- data/lib/labclient/generator/wizard.rb +11 -12
- data/lib/labclient/groups/group.rb +0 -2
- data/lib/labclient/groups/search.rb +2 -6
- data/lib/labclient/groups/stub.rb +1 -0
- data/lib/labclient/http.rb +27 -9
- data/lib/labclient/issues/issue.rb +1 -1
- data/lib/labclient/klass.rb +10 -11
- data/lib/labclient/lab_struct.rb +39 -7
- data/lib/labclient/logger.rb +50 -0
- data/lib/labclient/merge_requests/delete.rb +10 -2
- data/lib/labclient/merge_requests/merge_request.rb +1 -3
- data/lib/labclient/notifications/update.rb +1 -1
- data/lib/labclient/overview.rb +40 -2
- data/lib/labclient/paginated_response.rb +0 -2
- data/lib/labclient/pipelines/pipeline.rb +1 -1
- data/lib/labclient/projects/methods.rb +6 -2
- data/lib/labclient/projects/reference.rb +2 -2
- data/lib/labclient/projects/search.rb +2 -6
- data/lib/labclient/repository/repository_tree.rb +7 -0
- data/lib/labclient/repository/tree.rb +1 -1
- data/lib/labclient/version.rb +7 -1
- data/lib/labclient.rb +8 -2
- metadata +66 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a516961c1eaeef85e9ee1d1de52980e03aae212122fd8d1bc49a05e9d4328ac
|
4
|
+
data.tar.gz: 384c408eb1320f1d31e661fe153edaacad187f02a6971775d7b1afd918eaf88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3b2453fa6d325e570360ca1b956261e5841901c528d8df3af44b28db7bf20081b0bd49c490e58c71055524b1ceff090ba63fb8205d6f379f0547161bfd80aec
|
7
|
+
data.tar.gz: 942ce7e24982e01141d664b0f4038dd4f8207ccb9f849cd74a058125aecf672c51af03e198f9e2ce7dd7f9bd35976f7e9a35fe1fe7b088240a636edd376d6d6c
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Top Namespace
|
2
|
+
module LabClient
|
3
|
+
# Reader Methods / Accessor Helpers
|
4
|
+
module ClientHelpers
|
5
|
+
def api_methods
|
6
|
+
subclasses.keys.sort
|
7
|
+
end
|
8
|
+
|
9
|
+
def help(help_filter = nil)
|
10
|
+
puts 'Available Methods'
|
11
|
+
|
12
|
+
shown_subclasses = if help_filter
|
13
|
+
api_methods.grep(/#{help_filter}/)
|
14
|
+
else
|
15
|
+
api_methods
|
16
|
+
end
|
17
|
+
|
18
|
+
puts " - #{shown_subclasses.join(' ')}\n\n"
|
19
|
+
puts "See help for each specific sub-category\n"
|
20
|
+
puts "- client.users.help\n"
|
21
|
+
puts "- client.users.api_methods\n"
|
22
|
+
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def home_file
|
27
|
+
"#{ENV['HOME']}/.gitlab-labclient"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Easier Profile Name Access
|
31
|
+
def profile
|
32
|
+
if settings&.key? :profile
|
33
|
+
settings[:profile].to_sym
|
34
|
+
else
|
35
|
+
ENV['LABCLIENT_PROFILE'].to_sym
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Instance Variable Helpers
|
40
|
+
def save_client
|
41
|
+
resp.instance_variable_set(:@client, self)
|
42
|
+
end
|
43
|
+
|
44
|
+
def save_path
|
45
|
+
resp.instance_variable_set(:@path, path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def base_url
|
49
|
+
"#{settings[:url]}/api/v4/"
|
50
|
+
end
|
51
|
+
|
52
|
+
def quiet?
|
53
|
+
settings[:quiet]
|
54
|
+
end
|
55
|
+
|
56
|
+
def debug?
|
57
|
+
settings[:debug]
|
58
|
+
end
|
59
|
+
|
60
|
+
def delay_factor
|
61
|
+
settings[:retry][:delay_factor]
|
62
|
+
end
|
63
|
+
|
64
|
+
def retry_max
|
65
|
+
settings[:retry][:max]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Maximum Retries
|
69
|
+
def retry_max?
|
70
|
+
retries >= retry_max
|
71
|
+
end
|
72
|
+
|
73
|
+
# On Successfully response lower delay
|
74
|
+
# Prevent multiple request / delays
|
75
|
+
def retry_update
|
76
|
+
self.delay = [delay - 1, 1].max
|
77
|
+
self.retries = [retries - 1, 0].max
|
78
|
+
end
|
79
|
+
|
80
|
+
# Debug Print Output
|
81
|
+
def debug_handler
|
82
|
+
options = resp.request.options
|
83
|
+
|
84
|
+
logger.debug(
|
85
|
+
options[:method].to_s.upcase,
|
86
|
+
code: resp.code,
|
87
|
+
path: path,
|
88
|
+
ssl_verify: options[:ssl_verifyhost],
|
89
|
+
message: resp.return_message,
|
90
|
+
klass: klass.to_s,
|
91
|
+
base_url: resp.request.base_url
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Helper for Accessing the Retry Headers
|
96
|
+
def retry_after
|
97
|
+
retry_header || delay_factor || 1
|
98
|
+
end
|
99
|
+
|
100
|
+
def retry_header
|
101
|
+
resp.headers['retry-after']&.to_i
|
102
|
+
end
|
103
|
+
|
104
|
+
def retry_debug_headers
|
105
|
+
resp.headers.select { |k, _v| k.include? 'ratelimit' }
|
106
|
+
end
|
107
|
+
|
108
|
+
# Handle Retry Logic
|
109
|
+
# 1. If response merits a retry
|
110
|
+
# 2. Retry is enabled
|
111
|
+
# 3. Retry Sleep Max isn't hit
|
112
|
+
def should_retry?
|
113
|
+
resp.retry? && settings[:retry] && !retry_max?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Top Namespace
|
2
|
+
module LabClient
|
3
|
+
# Variables / Meta
|
4
|
+
class Client
|
5
|
+
# include HTTParty
|
6
|
+
attr_accessor :settings, :resp, :klass, :link, :http, :delay, :retries, :path
|
7
|
+
|
8
|
+
def inspect
|
9
|
+
"#<LabClient::Client url: \"#{@settings[:url]}\">"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Helper to make subclasses directly accessible
|
13
|
+
def subclasses
|
14
|
+
self.class.instance_variable_get(:@subclasses)
|
15
|
+
end
|
16
|
+
|
17
|
+
# ----------
|
18
|
+
# Alias List
|
19
|
+
# approvals == merge_request_approvals
|
20
|
+
# repo == repository
|
21
|
+
# ----------
|
22
|
+
@subclasses = {
|
23
|
+
appearance: Appearances,
|
24
|
+
application_settings: ApplicationSettings,
|
25
|
+
application_statistics: ApplicationStatistics,
|
26
|
+
applications: Applications,
|
27
|
+
approvals: Approvals,
|
28
|
+
audit_events: AuditEvents,
|
29
|
+
avatar: Avatars,
|
30
|
+
awards: Awards,
|
31
|
+
branches: Branches,
|
32
|
+
broadcast_messages: BroadcastMessages,
|
33
|
+
ci_lint: CiLint,
|
34
|
+
commits: Commits,
|
35
|
+
deploy_keys: DeployKeys,
|
36
|
+
discussions: Discussions,
|
37
|
+
epics: Epics,
|
38
|
+
events: Events,
|
39
|
+
feature_flags: FeatureFlags,
|
40
|
+
files: Files,
|
41
|
+
groups: Groups,
|
42
|
+
impersonation_tokens: ImpersonationTokens,
|
43
|
+
issues: Issues,
|
44
|
+
jobs: Jobs,
|
45
|
+
keys: Keys,
|
46
|
+
license: Licenses,
|
47
|
+
markdown: Markdown,
|
48
|
+
members: Members,
|
49
|
+
merge_request_approvals: Approvals,
|
50
|
+
merge_requests: MergeRequests,
|
51
|
+
namespaces: Namespaces,
|
52
|
+
notes: Notes,
|
53
|
+
notifications: Notifications,
|
54
|
+
pipelines: Pipelines,
|
55
|
+
project_runners: ProjectRunners,
|
56
|
+
projects: Projects,
|
57
|
+
protected_branches: ProtectedBranches,
|
58
|
+
protected_environments: ProtectedEnvironments,
|
59
|
+
protected_tags: ProtectedTags,
|
60
|
+
registry: Registry,
|
61
|
+
repo: Repositories,
|
62
|
+
repository: Repositories,
|
63
|
+
resource_labels: ResourceLabels,
|
64
|
+
runners: Runners,
|
65
|
+
snippets: Snippets,
|
66
|
+
system_hooks: SystemHooks,
|
67
|
+
tags: Tags,
|
68
|
+
todos: Todos,
|
69
|
+
users: Users,
|
70
|
+
version: Version,
|
71
|
+
wikis: Wikis,
|
72
|
+
wizard: Generator::Wizard
|
73
|
+
}
|
74
|
+
|
75
|
+
@subclasses.each do |name, obj|
|
76
|
+
define_method(name) do
|
77
|
+
obj.new(self)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Top Namespace
|
2
|
+
module LabClient
|
3
|
+
# Methods for Initialization
|
4
|
+
module ClientSetup
|
5
|
+
# Load default profile
|
6
|
+
def fill_configuration
|
7
|
+
if File.exist? home_file
|
8
|
+
Oj.load_file(home_file, { symbol_keys: true })
|
9
|
+
else
|
10
|
+
{
|
11
|
+
url: ENV['LABCLIENT_URL'],
|
12
|
+
token: ENV['LABCLIENT_TOKEN']
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# If nothing entered Prompt for Input
|
18
|
+
def prompt_for_url
|
19
|
+
print 'Enter GitLab URL (e.g. https://gitlab.com): '
|
20
|
+
@settings[:url] = ENV['LABCLIENT_TESTING'] ? 'testu' : $stdin.gets&.chomp
|
21
|
+
raise 'LabClient Error - Missing URL!' if @settings[:url].blank?
|
22
|
+
end
|
23
|
+
|
24
|
+
# Check for Token
|
25
|
+
def prompt_for_token
|
26
|
+
print 'Enter Personal Access Token: '
|
27
|
+
|
28
|
+
@settings[:token] = ENV['LABCLIENT_TESTING'] ? 'testt' : $stdin.gets&.chomp
|
29
|
+
end
|
30
|
+
|
31
|
+
# Fill Defaults
|
32
|
+
def unspecified_defaults
|
33
|
+
@settings[:paginate] = true if @settings[:paginate].nil?
|
34
|
+
@settings[:ssl_verify] = true if @settings[:ssl_verify].nil?
|
35
|
+
@settings[:quiet] = false if @settings[:quiet].nil?
|
36
|
+
@settings[:debug] = false if @settings[:quiet].nil?
|
37
|
+
@settings[:debug] = false if @settings[:debug].nil?
|
38
|
+
@settings[:token_type] = 'Private-Token' if @settings[:token_type].nil?
|
39
|
+
@settings[:retry] = { max: 5, delay_factor: 10, count: 0 } if @settings[:retry].nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
# Support for Named Profiles
|
43
|
+
def setup_profile
|
44
|
+
return false unless File.exist? home_file
|
45
|
+
|
46
|
+
config = Oj.load_file(home_file, { symbol_keys: true })
|
47
|
+
return false unless config.key? profile
|
48
|
+
|
49
|
+
self.settings ||= {}
|
50
|
+
settings.merge! config[profile]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/labclient/client.rb
CHANGED
@@ -1,104 +1,10 @@
|
|
1
1
|
# Top Namespace
|
2
2
|
module LabClient
|
3
3
|
# API Specifics
|
4
|
-
# rubocop:disable Metrics/ClassLength
|
5
4
|
class Client
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def inspect
|
10
|
-
"#<LabClient::Client url: \"#{@settings[:url]}\">"
|
11
|
-
end
|
12
|
-
|
13
|
-
# Helper to make subclasses directly accessible
|
14
|
-
def subclasses
|
15
|
-
self.class.instance_variable_get(:@subclasses)
|
16
|
-
end
|
17
|
-
|
18
|
-
# ----------
|
19
|
-
# Alias List
|
20
|
-
# approvals == merge_request_approvals
|
21
|
-
# repo == repository
|
22
|
-
# ----------
|
23
|
-
@subclasses = {
|
24
|
-
appearance: Appearances,
|
25
|
-
application_settings: ApplicationSettings,
|
26
|
-
application_statistics: ApplicationStatistics,
|
27
|
-
applications: Applications,
|
28
|
-
approvals: Approvals,
|
29
|
-
audit_events: AuditEvents,
|
30
|
-
avatar: Avatars,
|
31
|
-
awards: Awards,
|
32
|
-
branches: Branches,
|
33
|
-
broadcast_messages: BroadcastMessages,
|
34
|
-
ci_lint: CiLint,
|
35
|
-
commits: Commits,
|
36
|
-
deploy_keys: DeployKeys,
|
37
|
-
discussions: Discussions,
|
38
|
-
epics: Epics,
|
39
|
-
events: Events,
|
40
|
-
feature_flags: FeatureFlags,
|
41
|
-
files: Files,
|
42
|
-
groups: Groups,
|
43
|
-
impersonation_tokens: ImpersonationTokens,
|
44
|
-
issues: Issues,
|
45
|
-
jobs: Jobs,
|
46
|
-
keys: Keys,
|
47
|
-
license: Licenses,
|
48
|
-
markdown: Markdown,
|
49
|
-
members: Members,
|
50
|
-
merge_request_approvals: Approvals,
|
51
|
-
merge_requests: MergeRequests,
|
52
|
-
namespaces: Namespaces,
|
53
|
-
notes: Notes,
|
54
|
-
notifications: Notifications,
|
55
|
-
pipelines: Pipelines,
|
56
|
-
project_runners: ProjectRunners,
|
57
|
-
projects: Projects,
|
58
|
-
protected_branches: ProtectedBranches,
|
59
|
-
protected_environments: ProtectedEnvironments,
|
60
|
-
protected_tags: ProtectedTags,
|
61
|
-
registry: Registry,
|
62
|
-
repo: Repositories,
|
63
|
-
repository: Repositories,
|
64
|
-
resource_labels: ResourceLabels,
|
65
|
-
runners: Runners,
|
66
|
-
snippets: Snippets,
|
67
|
-
system_hooks: SystemHooks,
|
68
|
-
tags: Tags,
|
69
|
-
todos: Todos,
|
70
|
-
users: Users,
|
71
|
-
version: Version,
|
72
|
-
wikis: Wikis,
|
73
|
-
wizard: Generator::Wizard
|
74
|
-
}
|
75
|
-
|
76
|
-
@subclasses.each do |name, obj|
|
77
|
-
define_method(name) do
|
78
|
-
obj.new(self)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def api_methods
|
83
|
-
subclasses.keys.sort
|
84
|
-
end
|
85
|
-
|
86
|
-
def help(help_filter = nil)
|
87
|
-
puts 'Available Methods'
|
88
|
-
|
89
|
-
shown_subclasses = if help_filter
|
90
|
-
api_methods.grep(/#{help_filter}/)
|
91
|
-
else
|
92
|
-
api_methods
|
93
|
-
end
|
94
|
-
|
95
|
-
puts " - #{shown_subclasses.join(' ')}\n\n"
|
96
|
-
puts "See help for each specific sub-category\n"
|
97
|
-
puts "- client.users.help\n"
|
98
|
-
puts "- client.users.api_methods\n"
|
99
|
-
|
100
|
-
nil
|
101
|
-
end
|
5
|
+
include ClientHelpers
|
6
|
+
include ClientSetup
|
7
|
+
include Logger
|
102
8
|
|
103
9
|
# Default setup, pull in settings
|
104
10
|
def initialize(user_settings = nil)
|
@@ -114,88 +20,62 @@ module LabClient
|
|
114
20
|
# Only prompt if explicitly set to nil
|
115
21
|
prompt_for_token if @settings[:token].nil?
|
116
22
|
|
117
|
-
|
118
|
-
|
23
|
+
# Initial Delay / Retry Value
|
24
|
+
self.delay = 0
|
25
|
+
self.retries = 0
|
119
26
|
|
120
|
-
|
121
|
-
|
27
|
+
# Request Configuration
|
28
|
+
self.http = HTTP.new(@settings)
|
122
29
|
end
|
123
30
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
31
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
32
|
+
def request(method, path, klass = nil, body = {}, dump_json = true)
|
33
|
+
self.klass = klass
|
34
|
+
self.resp = http.request(method, path, body, dump_json)
|
35
|
+
self.path = path
|
129
36
|
|
130
|
-
|
131
|
-
print 'Enter Personal Access Token: '
|
132
|
-
@settings[:token] = $stdin.gets.chomp
|
133
|
-
end
|
37
|
+
debug_handler if debug?
|
134
38
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
def home_file
|
143
|
-
"#{ENV['HOME']}/.gitlab-labclient"
|
144
|
-
end
|
39
|
+
post_request_handlers
|
40
|
+
process resp
|
41
|
+
rescue LabClient::Error => e
|
42
|
+
logger.fatal('Request Failed', e.error_details) unless quiet?
|
43
|
+
resp
|
44
|
+
rescue LabClient::Retry
|
45
|
+
self.retries += 1
|
145
46
|
|
146
|
-
|
147
|
-
|
148
|
-
if
|
149
|
-
settings[:profile].to_sym
|
150
|
-
else
|
151
|
-
ENV['LABCLIENT_PROFILE'].to_sym
|
152
|
-
end
|
153
|
-
end
|
47
|
+
# Assume Retry After by Default
|
48
|
+
logger.debug('Retry After', value: retry_after, retry_debug_headers: retry_debug_headers) if debug?
|
49
|
+
self.delay = retry_after if resp.headers.key? 'retry-after'
|
154
50
|
|
155
|
-
|
156
|
-
|
157
|
-
return false unless File.exist? home_file
|
51
|
+
self.delay += delay_factor
|
52
|
+
logger.warn "Received #{resp.code}. Retry in #{delay}", limit: retry_max, retries: retries unless quiet?
|
158
53
|
|
159
|
-
|
160
|
-
return false unless config.key? profile
|
54
|
+
sleep delay unless ENV['LABCLIENT_TESTING']
|
161
55
|
|
162
|
-
|
163
|
-
settings.merge! config[profile]
|
56
|
+
retry
|
164
57
|
end
|
58
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
165
59
|
|
166
|
-
#
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
{
|
172
|
-
url: ENV['LABCLIENT_URL'],
|
173
|
-
token: ENV['LABCLIENT_TOKEN']
|
174
|
-
}
|
175
|
-
end
|
176
|
-
end
|
60
|
+
# Handling Details for after the request
|
61
|
+
# Debug,Retry, Instance Variables, Error Handling
|
62
|
+
def post_request_handlers
|
63
|
+
# Handle Retry Logic
|
64
|
+
raise LabClient::Retry if should_retry?
|
177
65
|
|
178
|
-
|
179
|
-
|
66
|
+
# Save Client
|
67
|
+
save_client
|
180
68
|
|
181
|
-
|
69
|
+
# Reset Delay/Retry Factor
|
70
|
+
retry_update if resp.success?
|
182
71
|
|
183
|
-
#
|
184
|
-
|
72
|
+
# Exit on Max Retries
|
73
|
+
raise LabClient::Error.new(resp), resp.friendly_error if retry_max?
|
185
74
|
|
186
75
|
raise LabClient::Error.new(resp), resp.friendly_error unless resp.success?
|
187
76
|
|
188
77
|
# Drop in raw path
|
189
|
-
|
190
|
-
|
191
|
-
process resp
|
192
|
-
rescue LabClient::Error => e
|
193
|
-
puts e.message unless quiet?
|
194
|
-
resp
|
195
|
-
end
|
196
|
-
|
197
|
-
def quiet?
|
198
|
-
settings[:quiet]
|
78
|
+
save_path
|
199
79
|
end
|
200
80
|
|
201
81
|
# Assume we want LabStruct if @klass is ever nil
|
@@ -214,5 +94,4 @@ module LabClient
|
|
214
94
|
end
|
215
95
|
end
|
216
96
|
end
|
217
|
-
# rubocop:enable Metrics/ClassLength
|
218
97
|
end
|
data/lib/labclient/common.rb
CHANGED
@@ -47,8 +47,13 @@ module LabClient
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Category and Primary Key for docs
|
50
|
+
# If/Else for Instance Variable Warnings
|
50
51
|
def group_name
|
51
|
-
self.class.
|
52
|
+
if self.class.instance_variable_defined? '@group_name'
|
53
|
+
self.class.instance_variable_get('@group_name')
|
54
|
+
else
|
55
|
+
klass
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
def inspect
|
@@ -70,7 +75,7 @@ module LabClient
|
|
70
75
|
return nil if obj_id.nil?
|
71
76
|
|
72
77
|
# Already a Integer
|
73
|
-
return obj_id if obj_id.
|
78
|
+
return obj_id if obj_id.instance_of?(Integer)
|
74
79
|
|
75
80
|
# If LabClient Object, send ID
|
76
81
|
return obj_id.id if obj_id.class.module_parent_name == 'LabClient'
|
@@ -107,7 +112,7 @@ module LabClient
|
|
107
112
|
# :developer => 30
|
108
113
|
# :owner => 50
|
109
114
|
def query_access_level(query, key = :group_access)
|
110
|
-
query[key] = machine_access_level query[key] if query.key?(key) && query[key].
|
115
|
+
query[key] = machine_access_level query[key] if query.key?(key) && query[key].instance_of?(Symbol)
|
111
116
|
end
|
112
117
|
|
113
118
|
# TODO: See if these are even needed
|
@@ -118,7 +123,7 @@ module LabClient
|
|
118
123
|
# 40 => Maintainer access
|
119
124
|
# 60 => Admin access
|
120
125
|
def protected_query_access_level(query, key = :push_access_level)
|
121
|
-
query[key] = machine_protected_access_level query[key] if query.key?(key) && query[key].
|
126
|
+
query[key] = machine_protected_access_level query[key] if query.key?(key) && query[key].instance_of?(Symbol)
|
122
127
|
end
|
123
128
|
end
|
124
129
|
end
|
data/lib/labclient/docs.rb
CHANGED
@@ -72,8 +72,13 @@ module LabClient
|
|
72
72
|
end
|
73
73
|
|
74
74
|
# Allow for Custom Group Name Overrides
|
75
|
+
# Ruby warning of uninitialized variables
|
75
76
|
def group_name
|
76
|
-
@group_name
|
77
|
+
if defined? @group_name
|
78
|
+
@group_name
|
79
|
+
else
|
80
|
+
name.split('::', 2).last.split(/(?=[A-Z])/).join(' ')
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
79
84
|
# Helper to Make navigation rendered out once rather than evaluated on Ember
|
@@ -29,7 +29,7 @@ module LabClient
|
|
29
29
|
epic_id = format_id(epic_id)
|
30
30
|
|
31
31
|
# This is horrible, but has to be the epic_issue_id, not the issue's id or iid
|
32
|
-
epic_issue_id = epic_issue_id.epic_issue_id if epic_issue_id.
|
32
|
+
epic_issue_id = epic_issue_id.epic_issue_id if epic_issue_id.instance_of?(Issue)
|
33
33
|
|
34
34
|
client.request(:delete, "groups/#{group_id}/epics/#{epic_id}/issues/#{epic_issue_id}")
|
35
35
|
end
|
@@ -36,7 +36,7 @@ module LabClient
|
|
36
36
|
epic_id = format_id(epic_id)
|
37
37
|
|
38
38
|
# This is horrible, but has to be the epic_issue_id, not the issue's id or iid
|
39
|
-
epic_issue_id = epic_issue_id.epic_issue_id if epic_issue_id.
|
39
|
+
epic_issue_id = epic_issue_id.epic_issue_id if epic_issue_id.instance_of?(Issue)
|
40
40
|
|
41
41
|
client.request(:put, "groups/#{group_id}/epics/#{epic_id}/issues/#{epic_issue_id}", nil, query)
|
42
42
|
end
|
data/lib/labclient/error.rb
CHANGED
data/lib/labclient/files/show.rb
CHANGED
@@ -3,11 +3,11 @@ module LabClient
|
|
3
3
|
# Specifics
|
4
4
|
class Files < Common
|
5
5
|
doc 'Show' do
|
6
|
-
desc 'Allows you to receive information about file in repository like name, size, content [Project ID, File Path, Ref (
|
6
|
+
desc 'Allows you to receive information about file in repository like name, size, content [Project ID, File Path, Ref (main default), kind]'
|
7
7
|
example 'client.files.show(264, "README.md")'
|
8
8
|
|
9
9
|
markdown <<~DOC
|
10
|
-
Ref will default to `
|
10
|
+
Ref will default to `main`
|
11
11
|
|
12
12
|
Kind can be left empty or set to either :raw or :blame
|
13
13
|
DOC
|
@@ -15,12 +15,12 @@ module LabClient
|
|
15
15
|
|
16
16
|
doc 'Show' do
|
17
17
|
desc 'Raw Content'
|
18
|
-
example 'client.files.show(264, "README.md", :
|
18
|
+
example 'client.files.show(264, "README.md", :main, :raw)'
|
19
19
|
end
|
20
20
|
|
21
21
|
doc 'Show' do
|
22
22
|
desc 'Blame'
|
23
|
-
example 'client.files.show(264, "README.md", :
|
23
|
+
example 'client.files.show(264, "README.md", :main, :blame)'
|
24
24
|
end
|
25
25
|
|
26
26
|
doc 'Show' do
|
@@ -31,7 +31,7 @@ module LabClient
|
|
31
31
|
DOC
|
32
32
|
end
|
33
33
|
|
34
|
-
def show(project_id, file_path, ref = :
|
34
|
+
def show(project_id, file_path, ref = :main, kind = nil)
|
35
35
|
kind = case kind
|
36
36
|
when :raw
|
37
37
|
'/raw'
|
@@ -16,6 +16,7 @@ module LabClient
|
|
16
16
|
# Common Helper Class
|
17
17
|
class TemplateHelper
|
18
18
|
include TemplateMethods
|
19
|
+
include LabClient::Logger
|
19
20
|
|
20
21
|
attr_reader :client
|
21
22
|
attr_accessor :opts
|
@@ -46,16 +47,16 @@ module LabClient
|
|
46
47
|
attr_accessor :group_name, :group_path, :group_suffix, :project_name
|
47
48
|
|
48
49
|
def run!
|
49
|
-
|
50
|
+
logger.info "Running: #{group_suffix}"
|
50
51
|
generate_group
|
51
52
|
|
52
53
|
# Run `setup_` prefixed classes
|
53
54
|
self.class.instance_methods.grep(/setup_/).each { |x| send(x) }
|
54
55
|
|
55
56
|
# Print Created Groups/Project
|
56
|
-
|
57
|
+
logger.info 'Group', name: @group.name, web_url: @group.web_url
|
57
58
|
@projects.each do |project|
|
58
|
-
|
59
|
+
logger.info 'Project', name: project.name, web_url: project.web_url
|
59
60
|
end
|
60
61
|
|
61
62
|
{
|