Class: Morpheus::BlueprintsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::BlueprintsInterface
- Defined in:
- lib/morpheus/api/blueprints_interface.rb
Instance Method Summary collapse
- #create(payload) ⇒ Object
- #destroy(id) ⇒ Object
- #duplicate(id, payload) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ BlueprintsInterface
constructor
A new instance of BlueprintsInterface.
- #list(params = {}) ⇒ Object
- #list_tiers(payload = {}) ⇒ Object
- #list_types(params = {}) ⇒ Object
-
#save_image(id, image_file, params = {}) ⇒ Object
multipart image upload.
- #update(id, payload) ⇒ Object
- #update_permissions(id, payload) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ BlueprintsInterface
Returns a new instance of BlueprintsInterface.
4 5 6 7 8 9 |
# File 'lib/morpheus/api/blueprints_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(payload) ⇒ Object
24 25 26 27 28 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 24 def create(payload) url = "#{@base_url}/api/blueprints" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#destroy(id) ⇒ Object
58 59 60 61 62 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 58 def destroy(id) url = "#{@base_url}/api/blueprints/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :delete, url: url, headers: headers) end |
#duplicate(id, payload) ⇒ Object
52 53 54 55 56 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 52 def duplicate(id, payload) url = "#{@base_url}/api/blueprints/#{id}/duplicate" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } 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/blueprints_interface.rb', line 11 def get(id) raise "#{self.class}.get() passed a blank id!" if id.to_s == '' url = "#{@base_url}/api/blueprints/#{id}" headers = { params: {}, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#list(params = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 18 def list(params={}) url = "#{@base_url}/api/blueprints" headers = { params: params, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#list_tiers(payload = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 64 def list_tiers(payload={}) url = "#{@base_url}/api/blueprints/tiers" headers = { params: {}, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#list_types(params = {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 70 def list_types(params={}) url = "#{@base_url}/api/blueprints/types" headers = { params: params, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#save_image(id, image_file, params = {}) ⇒ Object
multipart image upload
43 44 45 46 47 48 49 50 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 43 def save_image(id, image_file, params={}) url = "#{@base_url}/api/blueprints/#{id}/image" headers = { :params => params, :authorization => "Bearer #{@access_token}"} payload = {} payload[:templateImage] = image_file payload[:multipart] = true execute(method: :post, url: url, headers: headers, payload: payload) end |
#update(id, payload) ⇒ Object
30 31 32 33 34 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 30 def update(id, payload) url = "#{@base_url}/api/blueprints/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |
#update_permissions(id, payload) ⇒ Object
36 37 38 39 40 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 36 def (id, payload) url = "#{@base_url}/api/blueprints/#{id}/update-permissions" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |