Class: Morpheus::AppTemplatesInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::AppTemplatesInterface
- Defined in:
- lib/morpheus/api/app_templates_interface.rb
Instance Method Summary collapse
- #create(options) ⇒ Object
- #destroy(id) ⇒ Object
- #duplicate(id, options) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppTemplatesInterface
constructor
A new instance of AppTemplatesInterface.
- #list(options = {}) ⇒ Object
- #list_tiers(options = {}) ⇒ Object
-
#save_image(id, image_file, params = {}) ⇒ Object
multipart image upload.
- #update(id, options) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ AppTemplatesInterface
Returns a new instance of AppTemplatesInterface.
4 5 6 7 8 9 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 4 def initialize(access_token, refresh_token,expires_at = nil, base_url=nil) @access_token = access_token @refresh_token = refresh_token @base_url = base_url @expires_at = expires_at end |
Instance Method Details
#create(options) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 25 def create() url = "#{@base_url}/api/app-templates" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#destroy(id) ⇒ Object
64 65 66 67 68 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 64 def destroy(id) url = "#{@base_url}/api/app-templates/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :delete, url: url, headers: headers) end |
#duplicate(id, options) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 57 def duplicate(id, ) url = "#{@base_url}/api/app-templates/#{id}/duplicate" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#get(id) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 11 def get(id) raise "#{self.class}.get() passed a blank id!" if id.to_s == '' url = "#{@base_url}/api/app-templates/#{id}" headers = { params: {}, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#list(options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 18 def list(={}) url = "#{@base_url}/api/app-templates" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!() execute(method: :get, url: url, headers: headers) end |
#list_tiers(options = {}) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 70 def list_tiers(={}) url = "#{@base_url}/api/app-templates/tiers" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!() execute(method: :get, url: url, headers: headers) end |
#save_image(id, image_file, params = {}) ⇒ Object
multipart image upload
48 49 50 51 52 53 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 48 def save_image(id, ) url = "#{@base_url}/api/app-templates/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |
#update(id, options) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/morpheus/api/app_templates_interface.rb', line 32 def update(id, ) url = "#{@base_url}/api/app-templates/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |