module WallixRestClient
Gem to use the Wallix Admin Bastion REST API
Constants
- VERSION
Attributes
configuration[RW]
Public Class Methods
build_http(uri)
click to toggle source
Build http object with ssl or not
# File lib/wallix_rest_client.rb, line 45 def build_http(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == 'https') http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless configuration.options[:verify_ssl] http end
build_query_params(query_params)
click to toggle source
Build query parameters
# File lib/wallix_rest_client.rb, line 69 def build_query_params(query_params) if query_params.empty? '' else '?' + URI.encode_www_form(query_params) end end
build_request(type, uri)
click to toggle source
Build request object with appropriate headers
# File lib/wallix_rest_client.rb, line 54 def build_request(type, uri) request = type.new(uri.request_uri) case configuration.options[:auth] when :basic request.basic_auth(configuration.user, configuration.secret) when :apikey request['X-Auth-User'] = configuration.user request['X-Auth-Key'] = configuration.secret end request end
get(path, resource, query_params = {})
click to toggle source
Get requests handler
# File lib/wallix_rest_client.rb, line 95 def get(path, resource, query_params = {}) run_request(path, resource, Net::HTTP::Get, query_params) end
get_approvals_requests_target(target = nil, query_params = {})
click to toggle source
Wallix API methods
# File lib/wallix_rest_client.rb, line 34 def self.get_approvals_requests_target(target = nil, query_params = {}) get 'approvals/requests/target/', target, query_params end
get_targetpasswords_checkout(target = nil, query_params = {})
click to toggle source
# File lib/wallix_rest_client.rb, line 38 def self.get_targetpasswords_checkout(target = nil, query_params = {}) get 'targetpasswords/checkout/', target, query_params end
post(path, resource, query_params = {}, post_params = {})
click to toggle source
Post requests handler
# File lib/wallix_rest_client.rb, line 100 def post(path, resource, query_params = {}, post_params = {}) run_request(path, resource, Net::HTTP::Post, query_params, post_params) end
run_request(path, resource, type, query_params = {}, post_params = {})
click to toggle source
Run the HTTP request
# File lib/wallix_rest_client.rb, line 78 def run_request(path, resource, type, query_params = {}, post_params = {}) uri = URI::join( configuration.base_uri, '/api/', path, URI.encode_www_form_component(resource.to_s, enc=Encoding::UTF_8), build_query_params(query_params) ) http = build_http(uri) request = build_request(type, uri) # Add post data if applicable request.set_form_data(post_params) unless post_params.empty? http.request(request) end
setup() { |configuration| ... }
click to toggle source
# File lib/wallix_rest_client.rb, line 13 def self.setup @configuration ||= Configuration.new yield(configuration) end