Class: Fog::Google::SQL::SslCert

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/google/models/sql/ssl_cert.rb

Overview

A SSL certificate resource

Instance Method Summary collapse

Instance Method Details

#destroy(options = {}) ⇒ Fog::Google::SQL::Operation

Deletes a SSL certificate. The change will not take effect until the instance is restarted.

Parameters:

  • options (Hash) (defaults to: {})

    Method options

Options Hash (options):

  • :async (Boolean)

    If the operation must be performed asynchronously (true by default)

Returns:



32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/google/models/sql/ssl_cert.rb', line 32

def destroy(options = {})
  requires :instance, :identity

  data = service.delete_ssl_cert(self.instance, self.identity)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation'])
  unless options.fetch(:async, true)
    operation.wait_for { ready? }
  end
  operation
end

#reloadFog::Google::SQL::SslCert

Reloads a SSL certificate

Returns:



47
48
49
50
51
52
53
# File 'lib/fog/google/models/sql/ssl_cert.rb', line 47

def reload
  requires :instance, :identity

  data = collection.get(self.instance, self.identity)
  merge_attributes(data.attributes)
  self
end

#saveObject

Creates a SSL certificate. The new certificate will not be usable until the instance is restarted.

Raises:

  • (Fog::Errors::Error)

    If SSL certificate already exists



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/google/models/sql/ssl_cert.rb', line 59

def save
  requires :instance, :common_name

  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?

  data = service.insert_ssl_cert(self.instance, self.common_name).body
  merge_attributes(data['clientCert']['certInfo'])
  self.server_ca_cert = Fog::Google::SQL::SslCert.new(data['serverCaCert'])
  self.cert_private_key = data['clientCert']['certPrivateKey']
  self
end