class Fog::Google::SQL::Instance

Constants

MAINTENANCE_STATE
PENDING_CREATE_STATE
RUNNABLE_STATE
SUSPENDED_STATE
UNKNOWN_STATE

Public Instance Methods

activation_policy() click to toggle source

Returns the activation policy for this instance

@return [String] The activation policy for this instance

# File lib/fog/google/models/sql/instance.rb, line 46
def activation_policy
  self.settings['activationPolicy']
end
autorized_gae_applications() click to toggle source

Returns the AppEngine app ids that can access this instance

@return [Array<String>] The AppEngine app ids that can access this instance

# File lib/fog/google/models/sql/instance.rb, line 54
def autorized_gae_applications
  self.settings['authorizedGaeApplications']
end
backup_configuration() click to toggle source

Returns the daily backup configuration for the instance

@return [Array<Hash>] The daily backup configuration for the instance

# File lib/fog/google/models/sql/instance.rb, line 62
def backup_configuration
  self.settings['backupConfiguration']
end
clone(destination_name, options = {}) click to toggle source

Creates a Cloud SQL instance as a clone of the source instance

@param [String] destination_name Name of the Cloud SQL instance to be created as a clone @param [Hash] options Method options @option options [String] :log_filename Name of the binary log file for a Cloud SQL instance @option options [Integer] :log_position Position (offset) within the binary log file @option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 75
def clone(destination_name, options = {})
  requires :identity

  data = service.clone_instance(self.identity, destination_name, options)
  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
create() click to toggle source

Creates a Cloud SQL instance

@return [Fog::Google::SQL::Instance] Instance resource

# File lib/fog/google/models/sql/instance.rb, line 90
def create
  requires :identity

  data = service.insert_instance(self.identity, self.attributes[:tier], self.attributes)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation'])
  operation.wait_for { !pending? }
  reload
end
database_flags() click to toggle source

Returns the database flags passed to the instance at startup

@return [Array<Hash>] The database flags passed to the instance at startup

# File lib/fog/google/models/sql/instance.rb, line 103
def database_flags
  self.settings['databaseFlags']
end
destroy(options = {}) click to toggle source

Deletes a Cloud SQL instance

@param [Hash] options Method options @option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 113
def destroy(options = {})
  requires :identity

  data = service.delete_instance(self.identity)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation'])
  unless options.fetch(:async, true)
    # DISABLED: A delete instance operation never reachs a 'DONE' state (bug?)
    # operation.wait_for { ready? }
  end
  operation
end
export(uri, options = {}) click to toggle source

Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file

@param [String] uri The path to the file in Google Cloud Storage where the export will be stored,

or where it was already stored

@param [Hash] options Method options @option options [Array<String>] :databases Databases (for example, guestbook) from which the export is made.

If unspecified, all databases are exported.

@option options [Array<String>] :tables Tables to export, or that were exported, from the specified database.

If you specify tables, specify one and only one database.

@option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 137
def export(uri, options = {})
  requires :identity

  data = service.export_instance(self.identity, uri, options)
  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
import(uri, options = {}) click to toggle source

Imports data into a Cloud SQL instance from a MySQL dump file in Google Cloud Storage

@param [Array<String>] uri A path to the MySQL dump file in Google Cloud Storage from which the import is

made

@param [Hash] options Method options @option options [String] :database The database (for example, guestbook) to which the import is made.

If not set, it is assumed that the database is specified in the file to be imported.

@option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 158
def import(uri, options = {})
  requires :identity

  data = service.import_instance(self.identity, uri, options)
  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
ip_configuration_authorized_networks() click to toggle source

Returns the list of external networks that are allowed to connect to the instance using the IP

@return [Array<String>] The list of external networks that are allowed to connect to the instance using the IP

# File lib/fog/google/models/sql/instance.rb, line 173
def ip_configuration_authorized_networks
  self.settings.fetch('ipConfiguration', {})['authorizedNetworks']
end
ip_configuration_enabled() click to toggle source

Returns whether the instance should be assigned an IP address or not

@return [Boolean] Whether the instance should be assigned an IP address or not

# File lib/fog/google/models/sql/instance.rb, line 181
def ip_configuration_enabled
  self.settings.fetch('ipConfiguration', {})['enabled']
end
ip_configuration_require_ssl() click to toggle source

Returns whether the mysqld should default to ‘REQUIRE X509’ for users connecting over IP

@return [Boolean] Whether the mysqld should default to ‘REQUIRE X509’ for users connecting over IP

# File lib/fog/google/models/sql/instance.rb, line 189
def ip_configuration_require_ssl
  self.settings.fetch('ipConfiguration', {})['requireSsl']
end
location_preference_zone() click to toggle source

Returns the preferred Compute Engine zone

@return [String] The preferred Compute Engine zone

# File lib/fog/google/models/sql/instance.rb, line 205
def location_preference_zone
  self.settings.fetch('locationPreference', {})['zone']
end
location_preference_zone_follow_gae_application() click to toggle source

Returns the AppEngine application to follow

@return [String] The AppEngine application to follow

# File lib/fog/google/models/sql/instance.rb, line 197
def location_preference_zone_follow_gae_application
  self.settings.fetch('locationPreference', {})['followGaeApplication']
end
pricing_plan() click to toggle source

Returns the pricing plan for this instance

@return [String] The pricing plan for this instance

# File lib/fog/google/models/sql/instance.rb, line 213
def pricing_plan
  self.settings['pricingPlan']
end
ready?() click to toggle source

Checks if the instance is running

@return [Boolean] True if the instance is running; False otherwise

# File lib/fog/google/models/sql/instance.rb, line 221
def ready?
  self.state == RUNNABLE_STATE
end
replication_type() click to toggle source

Returns the type of replication this instance uses

@return [String] The type of replication this instance uses

# File lib/fog/google/models/sql/instance.rb, line 229
def replication_type
  self.settings['replicationType']
end
reset_ssl_config(options = {}) click to toggle source

Deletes all client certificates and generates a new server SSL certificate for the instance

@param [Hash] options Method options @option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 239
def reset_ssl_config(options = {})
  requires :identity

  data = service.reset_instance_ssl_config(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
restart(options = {}) click to toggle source

Restarts a Cloud SQL instance

@param [Hash] options Method options @option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 256
def restart(options = {})
  requires :identity

  data = service.restart_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
restore_backup(backup_configuration, due_time, options = {}) click to toggle source

Restores a backup of a Cloud SQL instance

@param [String] backup_configuration The identifier of the backup configuration @param [String] due_time The time when this run is due to start in RFC 3339 format @param [Hash] options Method options @option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 275
def restore_backup(backup_configuration, due_time, options = {})
  requires :identity

  data = service.restore_instance_backup(self.identity, backup_configuration, due_time)
  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
save() click to toggle source

Saves a Cloud SQL instance

@return [Fog::Google::SQL::Instance] Instance resource

# File lib/fog/google/models/sql/instance.rb, line 290
def save
  self.etag ? update : create
end
set_root_password(password, options = {}) click to toggle source

Sets the password for the root user

@param [String] password The password for the root user @param [Hash] options Method options @option options [Boolean] :async If the operation must be performed asynchronously (true by default) @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 301
def set_root_password(password, options = {})
  requires :identity

  data = service.set_instance_root_password(self.identity, password)
  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
settings_version() click to toggle source

Returns the version of instance settings

@return [String] The version of instance settings

# File lib/fog/google/models/sql/instance.rb, line 316
def settings_version
  self.settings['settingsVersion']
end
ssl_certs() click to toggle source

Lists all of the current SSL certificates for the instance

@return [Array<Fog::Google::SQL::SslCert>] List of SSL certificate resources

# File lib/fog/google/models/sql/instance.rb, line 324
def ssl_certs
  requires :identity

  service.ssl_certs.all(self.identity)
end
tier() click to toggle source

Returns the tier of service for this instance

@return [String] The tier of service for this instance

# File lib/fog/google/models/sql/instance.rb, line 334
def tier
  self.settings['tier']
end
update() click to toggle source

Updates settings of a Cloud SQL instance

@return [Fog::Google::SQL::Instance] Instance resource

# File lib/fog/google/models/sql/instance.rb, line 342
def update
  requires :identity

  data = service.update_instance(self.identity, self.settings_version, self.tier, self.attributes)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation'])
  operation.wait_for { !pending? }
  reload
end