Class: ForemanX509::CertificatesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_x509/certificates_controller.rb

Instance Method Summary collapse

Instance Method Details

#certificateObject



40
41
42
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 40

def certificate
  send_data @certificate.certificate.to_pem, filename: "#{@certificate.name}_cert.pem"
end

#chainObject



36
37
38
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 36

def chain
  send_data @certificate.issuer.bundle.map(&:to_pem).join('\n'), filename: "#{@certificate.name}_ca.pem"
end

#createObject



16
17
18
19
20
21
22
23
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 16

def create
  @certificate = Certificate.new(certificate_params)
  if @certificate.save
    process_success object: @certificate
  else
    process_error object: @certificate
  end
end

#destroyObject



48
49
50
51
52
53
54
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 48

def destroy
  if @certificate.destroy
    process_success object: @certificate
  else
    process_error object: @certificate
  end
end

#indexObject



8
9
10
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 8

def index
  @certificates = resource_base_search_and_page
end

#keyObject



44
45
46
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 44

def key
  send_data @certificate.key.to_pem, filename: "#{@certificate.name}_key.pem"
end

#newObject



12
13
14
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 12

def new
  @certificate = Certificate.new
end

#resource_classObject



56
57
58
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 56

def resource_class
  ForemanX509::Certificate
end

#showObject



25
26
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 25

def show
end

#updateObject



28
29
30
31
32
33
34
# File 'app/controllers/foreman_x509/certificates_controller.rb', line 28

def update
  if @certificate.update(certificate_params)
    process_success object: @certificate
  else
    process_error object: @certificate
  end
end