Class: AzkabanScheduler::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/azkaban_scheduler/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.


6
7
8
9
10
# File 'lib/azkaban_scheduler/client.rb', line 6

def initialize(url)
  uri = URI(url)
  @http = Net::HTTP.new(uri.host, uri.port)
  @http.use_ssl = uri.scheme == 'https'
end

Instance Method Details

#get(path, params = nil, headers = nil) ⇒ Object


12
13
14
15
16
# File 'lib/azkaban_scheduler/client.rb', line 12

def get(path, params=nil, headers=nil)
  path += "?#{URI.encode_www_form(params)}" if params
  req = Net::HTTP::Get.new(path)
  send_request(req, headers)
end

#multipart_post(path, params, headers = nil) ⇒ Object


24
25
26
27
# File 'lib/azkaban_scheduler/client.rb', line 24

def multipart_post(path, params, headers=nil)
  req = Net::HTTP::Post::Multipart.new(path, params)
  send_request(req, headers)
end

#post(path, params = nil, headers = nil) ⇒ Object


18
19
20
21
22
# File 'lib/azkaban_scheduler/client.rb', line 18

def post(path, params=nil, headers=nil)
  req = Net::HTTP::Post.new(path)
  req.set_form_data(params) if params
  send_request(req, headers)
end