# File lib/rhc/commands/alias.rb, line 16 def add(app, app_alias) rest_app = rest_client.find_application(options.namespace, app) rest_app.add_alias(app_alias) results { say "Alias '#{app_alias}' has been added." } 0 end
# File lib/rhc/commands/alias.rb, line 86 def delete_cert(app, app_alias) rest_app = rest_client.find_application(options.namespace, app) rest_alias = rest_app.find_alias(app_alias) if rest_client.api_version_negotiated >= 1.4 confirm_action "#{color("This is a non-reversible action! Your SSL certificate will be permanently deleted from application '#{app}'.", :yellow)}\n\nAre you sure you want to delete the SSL certificate?" rest_alias.delete_certificate results { say "SSL certificate successfully deleted." } 0 else raise RHC::Rest::SslCertificatesNotSupported, "The server does not support SSL certificates for custom aliases." end end
# File lib/rhc/commands/alias.rb, line 103 def list(app) rest_app = rest_client.find_application(options.namespace, app) items = rest_app.aliases.map do |a| a.is_a?(String) ? [a, 'no', '-'] : [a.id, a.has_private_ssl_certificate? ? 'yes' : 'no', a.has_private_ssl_certificate? ? Date.parse(a.certificate_added_at) : '-'] end if items.empty? results { say "No aliases associated with the application #{app}." } else table(items, :header => ["Alias", "Has Certificate?", "Certificate Added"]).each { |s| say s } end 0 end
# File lib/rhc/commands/alias.rb, line 29 def remove(app, app_alias) rest_app = rest_client.find_application(options.namespace, app) rest_app.remove_alias(app_alias) results { say "Alias '#{app_alias}' has been removed." } 0 end
# File lib/rhc/commands/alias.rb, line 56 def update_cert(app, app_alias) certificate_file_path = options.certificate raise ArgumentError, "Certificate file not found: #{certificate_file_path}" if !File.exist?(certificate_file_path) || !File.file?(certificate_file_path) private_key_file_path = options.private_key raise ArgumentError, "Private key file not found: #{private_key_file_path}" if !File.exist?(private_key_file_path) || !File.file?(private_key_file_path) certificate_content = File.read(certificate_file_path) raise ArgumentError, "Invalid certificate file: #{certificate_file_path} is empty" if certificate_content.to_s.strip.length == 0 private_key_content = File.read(private_key_file_path) raise ArgumentError, "Invalid private key file: #{private_key_file_path} is empty" if private_key_content.to_s.strip.length == 0 rest_app = rest_client.find_application(options.namespace, app) rest_alias = rest_app.find_alias(app_alias) if rest_client.api_version_negotiated >= 1.4 rest_alias.add_certificate(certificate_content, private_key_content, options.passphrase) results { say "SSL certificate successfully added." } 0 else raise RHC::Rest::SslCertificatesNotSupported, "The server does not support SSL certificates for custom aliases." end end