Class: OpsmanagerClient::HTTPClient
- Inherits:
-
Object
- Object
- OpsmanagerClient::HTTPClient
- Includes:
- HTTMultiParty
- Defined in:
- lib/opsmanager_client/http_client.rb
Instance Method Summary collapse
- #add_product(product) ⇒ Object
- #apply_changes ⇒ Object
- #available_products ⇒ Object
- #delete_unused_products ⇒ Object
-
#initialize(url, username, password) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
- #installation ⇒ Object
- #remove_product_with_guid(guid) ⇒ Object
- #uninstall_product_with_guid(guid) ⇒ Object
- #upgrade_product(product, guid) ⇒ Object
- #upload_product_from_file(product_file) ⇒ Object
Constructor Details
#initialize(url, username, password) ⇒ HTTPClient
Returns a new instance of HTTPClient.
19 20 21 22 |
# File 'lib/opsmanager_client/http_client.rb', line 19 def initialize(url, username, password) HTTPClient.base_uri(url) HTTPClient.basic_auth(username, password) end |
Instance Method Details
#add_product(product) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/opsmanager_client/http_client.rb', line 50 def add_product(product) query_params = { 'name' => product.name, 'product_version' => product.version } ensure_successful( HTTPClient.post("/api/installation_settings/products", query(query_params)) ) end |
#apply_changes ⇒ Object
81 82 83 84 85 |
# File 'lib/opsmanager_client/http_client.rb', line 81 def apply_changes response = ensure_successful(HTTPClient.post("/api/installation", query)) task_id = response.fetch("install").fetch("id") task_id end |
#available_products ⇒ Object
36 37 38 39 40 |
# File 'lib/opsmanager_client/http_client.rb', line 36 def available_products ensure_successful( HTTPClient.get("/api/products", query) ) end |
#delete_unused_products ⇒ Object
30 31 32 33 34 |
# File 'lib/opsmanager_client/http_client.rb', line 30 def delete_unused_products ensure_successful( HTTPClient.delete("/api/products", query) ) end |
#installation ⇒ Object
24 25 26 27 28 |
# File 'lib/opsmanager_client/http_client.rb', line 24 def installation ensure_successful( HTTPClient.get("/api/installation_settings", query) ) end |
#remove_product_with_guid(guid) ⇒ Object
60 61 62 63 64 |
# File 'lib/opsmanager_client/http_client.rb', line 60 def remove_product_with_guid(guid) ensure_successful( HTTPClient.delete("/api/installation_settings/products/#{guid}", query) ) end |
#uninstall_product_with_guid(guid) ⇒ Object
75 76 77 78 79 |
# File 'lib/opsmanager_client/http_client.rb', line 75 def uninstall_product_with_guid(guid) ensure_successful( HTTPClient.delete("/api/installation_settings/products/#{guid}", query) ) end |
#upgrade_product(product, guid) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/opsmanager_client/http_client.rb', line 66 def upgrade_product(product, guid) query_params = { 'to_version' => product.version } ensure_successful( HTTPClient.put("/api/installation_settings/products/#{guid}", query(query_params)) ) end |
#upload_product_from_file(product_file) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/opsmanager_client/http_client.rb', line 42 def upload_product_from_file(product_file) retry_on_fail do ensure_successful( HTTPClient.post("/api/products", query(:product => {:file => product_file})) ) end end |