Class: Morpheus::BlueprintsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::BlueprintsInterface
- Defined in:
- lib/morpheus/api/blueprints_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) ⇒ BlueprintsInterface
constructor
A new instance of BlueprintsInterface.
- #list(options = {}) ⇒ Object
- #list_tiers(options = {}) ⇒ Object
- #list_types(options = {}) ⇒ Object
-
#save_image(id, image_file, params = {}) ⇒ Object
multipart image upload.
- #update(id, options) ⇒ Object
- #update_permissions(id, options) ⇒ 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(options) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 25 def create() url = "#{@base_url}/api/blueprints" 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
63 64 65 66 67 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 63 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, options) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 56 def duplicate(id, ) url = "#{@base_url}/api/blueprints/#{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/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(options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 18 def list(={}) url = "#{@base_url}/api/blueprints" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!() execute(method: :get, url: url, headers: headers) end |
#list_tiers(options = {}) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 69 def list_tiers(={}) url = "#{@base_url}/api/blueprints/tiers" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!() execute(method: :get, url: url, headers: headers) end |
#list_types(options = {}) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 76 def list_types(={}) url = "#{@base_url}/api/blueprints/types" 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
47 48 49 50 51 52 53 54 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 47 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, options) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 32 def update(id, ) url = "#{@base_url}/api/blueprints/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |
#update_permissions(id, options) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/morpheus/api/blueprints_interface.rb', line 39 def (id, ) url = "#{@base_url}/api/blueprints/#{id}/update-permissions" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |