Class: Netdata::Client::Helper::Network
- Inherits:
-
Object
- Object
- Netdata::Client::Helper::Network
- Defined in:
- lib/netdata/client/helper/network.rb
Overview
Perform HTTP requests
Instance Attribute Summary collapse
-
#config ⇒ Object
Access the configuration object instance externally.
Instance Method Summary collapse
-
#get(endpoint, url, args, version = 'v1') ⇒ Object
- Perform a GET request to a specified URL Params:
url
- The URL you want to hit
key
-
The authentication key to pass via headers to the URL.
- The URL you want to hit
- Perform a GET request to a specified URL Params:
-
#post(endpoint, url, args, version = 'v1') ⇒ Object
- Perform a POST request to a specified URL Params:
url
- The URL you want to hit
key
-
The authentication key to pass via headers to the URL.
- The URL you want to hit
- Perform a POST request to a specified URL Params:
Instance Attribute Details
#config ⇒ Object
Access the configuration object instance externally
7 8 9 |
# File 'lib/netdata/client/helper/network.rb', line 7 def config @config end |
Instance Method Details
#get(endpoint, url, args, version = 'v1') ⇒ Object
Perform a GET request to a specified URL Params:
url
-
The URL you want to hit
key
-
The authentication key to pass via headers to the URL
13 14 15 16 17 18 |
# File 'lib/netdata/client/helper/network.rb', line 13 def get(endpoint, url, args, version = 'v1') qs = build_qs(args) req_url = "#{url}/api/#{version}/#{endpoint}?#{qs}" request(req_url, :GET) end |
#post(endpoint, url, args, version = 'v1') ⇒ Object
Perform a POST request to a specified URL Params:
url
-
The URL you want to hit
key
-
The authentication key to pass via headers to the URL
24 25 26 27 28 29 |
# File 'lib/netdata/client/helper/network.rb', line 24 def post(endpoint, url, args, version = 'v1') qs = build_qs(args) req_url = "#{url}/api/#{version}/#{endpoint}?#{qs}" request(req_url, :POST) end |