Class: Morpheus::DeployInterface
Constant Summary
Constants inherited
from APIClient
APIClient::CLIENT_ID
Instance Attribute Summary
Attributes inherited from APIClient
#client_id
Instance Method Summary
collapse
Methods inherited from APIClient
#account_groups, #accounts, #activity, #appliance_settings, #approvals, #apps, #archive_buckets, #archive_files, #auth, #authorization_required?, #backup_settings, #blueprints, #budgets, #cloud_datastores, #cloud_folders, #cloud_policies, #cloud_resource_pools, #clouds, #clusters, #common_interface_options, #containers, #custom_instance_types, #cypher, #dashboard, #datastores, #default_content_type, #default_timeout, #deployments, #dry, #dry_run, #environments, #execute, #execute_schedules, #execution_request, #file_copy_request, #group_policies, #groups, #guidance, #health, #image_builder, #inspect, #instance_types, #instances, #integrations, #invoice_line_items, #invoices, #jobs, #key_pairs, #library_cluster_layouts, #library_container_scripts, #library_container_templates, #library_container_types, #library_container_upgrades, #library_instance_types, #library_layouts, #library_spec_template_types, #library_spec_templates, #license, #load_balancers, #log_settings, #logged_in?, #login, #logout, #logs, #monitoring, #network_domain_records, #network_domains, #network_groups, #network_pool_ips, #network_pool_servers, #network_pools, #network_proxies, #network_routers, #network_security_servers, #network_services, #network_types, #networks, #old_cypher, #option_type_lists, #option_types, #options, #packages, #ping, #policies, #power_schedules, #price_sets, #prices, #processes, #projects, #provision_types, #provisioning_license_types, #provisioning_licenses, #provisioning_settings, #refresh_token, #reports, #roles, #security_group_rules, #security_groups, #server_types, #servers, #service_plans, #set_ssl_verification_enabled, #setopts, #setup, #ssl_verification_enabled?, #storage_providers, #subnet_types, #subnets, #task_sets, #tasks, #to_s, #url, #user_groups, #user_settings, #user_sources, #users, #virtual_images, #whitelabel_settings, #whoami, #wiki, #withopts
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ DeployInterface
Returns a new instance of DeployInterface.
6
7
8
9
10
11
|
# File 'lib/morpheus/api/deploy_interface.rb', line 6
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(instanceId, options = nil) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/morpheus/api/deploy_interface.rb', line 27
def create(instanceId, options=nil)
url = "#{@base_url}/api/instances/#{instanceId}/deploy"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options || {}
execute(method: :post, url: url, headers: , payload: payload.to_json)
end
|
#deploy(id, options) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/morpheus/api/deploy_interface.rb', line 69
def deploy(id, options)
url = "#{@base_url}/api/deploy/#{id}/deploy"
payload = options
if !options[:appDeploy].nil?
if !options[:appDeploy][:config].nil?
options[:appDeploy][:config] = options[:appDeploy][:config].to_json
end
end
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
execute(method: :post, url: url, headers: , timeout: nil, payload: payload.to_json)
end
|
#destroy(id) ⇒ Object
63
64
65
66
67
|
# File 'lib/morpheus/api/deploy_interface.rb', line 63
def destroy(id)
url = "#{@base_url}/api/deploy/#{id}"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
execute(method: :delete, url: url, headers: )
end
|
#get(instanceId, options = nil) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/morpheus/api/deploy_interface.rb', line 14
def get(instanceId, options=nil)
url = "#{@base_url}/api/instances/#{instanceId}/deploy"
= { params: {}, authorization: "Bearer #{@access_token}" }
if options.is_a?(Hash)
[:params].merge!(options)
elsif options.is_a?(String)
[:params]['name'] = options
end
execute(method: :get, url: url, headers: )
end
|
#list_files(id) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/morpheus/api/deploy_interface.rb', line 34
def list_files(id)
url = "#{@base_url}/api/deploy/#{id}/files"
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
payload = options
execute(method: :get, url: url, headers: )
end
|
#upload_file(id, path, destination = nil) ⇒ Object
todo: use execute() to support @dry_run?
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/morpheus/api/deploy_interface.rb', line 42
def upload_file(id,path,destination=nil)
url = "#{@base_url}/api/deploy/#{id}/files"
if !destination.empty?
url += "/#{destination}"
end
= { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/octet-stream' }
opts = { method: :post, url: url, headers: , payload: File.new(path,'rb')}
if @dry_run
return opts
end
uri = URI.parse(url)
req = Net::HTTP::Post::Multipart.new uri.path,
"file" => UploadIO.new(File.new(path,'rb'), "image/jpeg", File.basename(path))
req['Authorization'] = "Bearer #{@access_token}"
res = Net::HTTP.start(uri.host, uri.port) do |http|
http.request(req)
end
res
end
|