module LabClient::ClientHelpers
Reader Methods / Accessor Helpers
Public Instance Methods
api_methods()
click to toggle source
# File lib/labclient/client/helpers.rb, line 5 def api_methods subclasses.keys.sort end
base_url()
click to toggle source
# File lib/labclient/client/helpers.rb, line 48 def base_url "#{settings[:url]}/api/v4/" end
debug?()
click to toggle source
# File lib/labclient/client/helpers.rb, line 56 def debug? settings[:debug] end
debug_handler()
click to toggle source
Debug Print Output
# File lib/labclient/client/helpers.rb, line 81 def debug_handler options = resp.request.options logger.debug( options[:method].to_s.upcase, code: resp.code, path: path, ssl_verify: options[:ssl_verifyhost], message: resp.return_message, klass: klass.to_s, base_url: resp.request.base_url ) end
delay_factor()
click to toggle source
# File lib/labclient/client/helpers.rb, line 60 def delay_factor settings[:retry][:delay_factor] end
help(help_filter = nil)
click to toggle source
# File lib/labclient/client/helpers.rb, line 9 def help(help_filter = nil) puts 'Available Methods' shown_subclasses = if help_filter api_methods.grep(/#{help_filter}/) else api_methods end puts " - #{shown_subclasses.join(' ')}\n\n" puts "See help for each specific sub-category\n" puts "- client.users.help\n" puts "- client.users.api_methods\n" nil end
home_file()
click to toggle source
# File lib/labclient/client/helpers.rb, line 26 def home_file "#{ENV['HOME']}/.gitlab-labclient" end
profile()
click to toggle source
Easier Profile Name Access
# File lib/labclient/client/helpers.rb, line 31 def profile if settings&.key? :profile settings[:profile].to_sym else ENV['LABCLIENT_PROFILE'].to_sym end end
quiet?()
click to toggle source
# File lib/labclient/client/helpers.rb, line 52 def quiet? settings[:quiet] end
retry_after()
click to toggle source
Helper for Accessing the Retry
Headers
# File lib/labclient/client/helpers.rb, line 96 def retry_after retry_header || delay_factor || 1 end
retry_header()
click to toggle source
# File lib/labclient/client/helpers.rb, line 100 def retry_header resp.headers['retry-after']&.to_i end
retry_max()
click to toggle source
# File lib/labclient/client/helpers.rb, line 64 def retry_max settings[:retry][:max] end
retry_max?()
click to toggle source
Maximum Retries
# File lib/labclient/client/helpers.rb, line 69 def retry_max? retries >= retry_max end
retry_update()
click to toggle source
On Successfully response lower delay Prevent multiple request / delays
# File lib/labclient/client/helpers.rb, line 75 def retry_update self.delay = [delay - 1, 1].max self.retries = [retries - 1, 0].max end
save_client()
click to toggle source
Instance Variable Helpers
# File lib/labclient/client/helpers.rb, line 40 def save_client resp.instance_variable_set(:@client, self) end
save_path()
click to toggle source
# File lib/labclient/client/helpers.rb, line 44 def save_path resp.instance_variable_set(:@path, path) end