Class: Qtc::Cli::Mar::SslCertificates
- Inherits:
-
Base
- Object
- Base
- Qtc::Cli::Mar::SslCertificates
show all
- Defined in:
- lib/qtc/cli/mar/ssl_certificates.rb
Instance Attribute Summary
Attributes included from Common
#datacenter_id
Instance Method Summary
collapse
Methods included from Common
#client, #current_cloud_dc, #current_cloud_id, #current_cloud_token, #extract_app_in_dir, #ini_filename, #inifile, #instance_info, #platform_base_url, #platform_client
Instance Method Details
#create(options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/qtc/cli/mar/ssl_certificates.rb', line 9
def create(options)
raise ArgumentError.new("--key=#{options.key} is not a file") unless File.exists?(File.expand_path(options.key))
raise ArgumentError.new("--cert=#{options.cert} is not a file") unless File.exists?(File.expand_path(options.cert))
unless options.chain.nil?
raise ArgumentError.new("--chain=#{options.chain} is not a file") unless File.exists?(File.expand_path(options.chain))
end
instance_id = resolve_instance_id(options)
instance_data = instance_info(instance_id)
if instance_data
data = {
name: instance_id,
privateKey: File.read(File.expand_path(options.key)),
certificateBody: File.read(File.expand_path(options.cert))
}
unless options.chain.nil?
data[:certificateChain] = File.read(File.expand_path(options.chain))
end
client.post("/apps/#{instance_id}/ssl_certificate", data, {}, {'Authorization' => "Bearer #{current_cloud_token}"})
end
end
|
#destroy(options) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/qtc/cli/mar/ssl_certificates.rb', line 31
def destroy(options)
instance_id = resolve_instance_id(options)
instance_data = instance_info(instance_id)
if instance_data
client.delete("/apps/#{instance_id}/ssl_certificate", {}, {}, {'Authorization' => "Bearer #{current_cloud_token}"})
end
end
|