Class: Netscaler::HttpAdapter
- Defined in:
- lib/netscaler/http_adapter.rb
Instance Method Summary collapse
- #delete(part, args = {}) ⇒ Object
- #get(part, args = {}) ⇒ Object
-
#initialize(args) ⇒ HttpAdapter
constructor
A new instance of HttpAdapter.
- #post(part, data, args = {}) ⇒ Object
- #post_no_body(part, data, args = {}) ⇒ Object
- #put(part, data, args = {}) ⇒ Object
- #put_no_body(part, data, args = {}) ⇒ Object
Methods inherited from Adapter
Constructor Details
#initialize(args) ⇒ HttpAdapter
Returns a new instance of HttpAdapter.
7 8 9 10 11 12 13 |
# File 'lib/netscaler/http_adapter.rb', line 7 def initialize(args) @site = RestClient::Resource.new(args[:hostname], { :user => args[:username], :password => args[:password], :verify_ssl => args[:verify_ssl] }) end |
Instance Method Details
#delete(part, args = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/netscaler/http_adapter.rb', line 89 def delete(part, args={}) url = get_uri(part) = (args) begin @site[url].delete do |response, request, result| return process_result(result, response) end rescue RestClient::Exception => e fr = Netscaler::Adapter::FailedRequest.new "Bad request", e.response , e raise fr end end |
#get(part, args = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/netscaler/http_adapter.rb', line 75 def get(part, args={}) url = get_uri(part) = (args) begin @site[url].get do |response, request, result| return process_result(result, response) end rescue RestClient::Exception => e fr = Netscaler::Adapter::FailedRequest.new "Bad request", e.response , e raise fr end end |
#post(part, data, args = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/netscaler/http_adapter.rb', line 29 def post(part, data, args={}) url = get_uri(part) = (args) [:content_type] = 'application/x-www-form-urlencoded' post_data = prepare_payload(data) begin @site[url].post post_data, do |response, request, result| return process_result(result, response) end rescue RestClient::Exception => e fr = Netscaler::Adapter::FailedRequest.new "Bad request", e.response , e raise fr end end |
#post_no_body(part, data, args = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/netscaler/http_adapter.rb', line 15 def post_no_body(part, data, args={}) url = get_uri(part) = (args) [:content_type] = 'application/x-www-form-urlencoded' post_data = prepare_payload(data) begin @site[url].post post_data, rescue RestClient::Exception => e fr = Netscaler::Adapter::FailedRequest.new "Bad request", e.response , e raise fr end end |
#put(part, data, args = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/netscaler/http_adapter.rb', line 45 def put(part, data, args={}) url = get_uri(part) = (args) [:content_type] = 'application/x-www-form-urlencoded' put_data = prepare_payload(data, args) begin @site[url].put put_data, do |response, request, result| return process_result(result, response) end rescue RestClient::Exception => e fr = Netscaler::Adapter::FailedRequest.new "Bad request", e.response , e raise fr end end |
#put_no_body(part, data, args = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/netscaler/http_adapter.rb', line 61 def put_no_body(part, data, args={}) url = get_uri(part) = (args) [:content_type] = 'application/x-www-form-urlencoded' put_data = prepare_payload(data) begin @site[url].put put_data, rescue RestClient::Exception => e fr = Netscaler::Adapter::FailedRequest.new "Bad request", e.response , e raise fr end end |