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
  settings[:activation_policy]
end
authorized_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 authorized_gae_applications
  settings[:authorized_gae_applications]
end
backup_configuration() click to toggle source

Returns the daily backup configuration for the instance

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

# File lib/fog/google/models/sql/instance.rb, line 62
def backup_configuration
  settings["backup_configuration"]
end
clone(destination_name, async: true, log_filename: nil, log_position: nil) 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 [Boolean] async If the operation must be performed asynchronously (true by default) @param [String] log_filename Name of the binary log file for a Cloud SQL instance @param [Integer] log_position Position (offset) within the binary log file @return [Fog::Google::SQL::Operation] A Operation resource

# File lib/fog/google/models/sql/instance.rb, line 74
def clone(destination_name, async: true, log_filename: nil, log_position: nil)
  requires :identity

  data = service.clone_instance(
    identity, destination_name,
    :log_filename => log_filename,
    :log_position => log_position
  )
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless async }
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(identity, attributes[:tier], attributes)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  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
  settings[:database_flags]
end
destroy(async: nil) click to toggle source

Deletes a Cloud SQL instance

@param [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 112
def destroy(async: nil)
  requires :identity

  data = service.delete_instance(identity)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless async }
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 132
def export(uri, options: {})
  requires :identity

  data = service.export_instance(identity, uri, options)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless async }
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 150
def import(uri, options = {})
  requires :identity

  data = service.import_instance(identity, uri, options)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless options.fetch(:async, true) }
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 162
def ip_configuration_authorized_networks
  settings.fetch(:ip_configuration, {})
          .fetch(:authorized_networks, [])
end
ip_configuration_ipv4_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 171
def ip_configuration_ipv4_enabled
  settings.fetch(:ip_configuration, {})[:ipv4_enabled]
end
ip_configuration_require_ssl() click to toggle source

Returns whether SSL connections over IP should be enforced or not.

@return [Boolean] Whether SSL connections over IP should be enforced or not.

# File lib/fog/google/models/sql/instance.rb, line 179
def ip_configuration_require_ssl
  settings.fetch(:ip_configuration, {})[:require_ssl]
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 195
def location_preference_zone
  settings.fetch(:location_preference, {})[: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 187
def location_preference_zone_follow_gae_application
  settings.fetch(:location_preference, {})[:follow_gae_application]
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 203
def pricing_plan
  settings[:pricing_plan]
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 211
def ready?
  state == RUNNABLE_STATE
end
reload() click to toggle source

Reload a Cloud SQL instance

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

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

  data = collection.get(identity)
  merge_attributes(data.attributes)
  self
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 219
def replication_type
  settings[:replication_type]
end
reset_ssl_config(async: true) click to toggle source

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

@param [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 228
def reset_ssl_config(async: true)
  requires :identity

  data = service.reset_instance_ssl_config(identity)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless async }
end
restart(async: true) click to toggle source

Restarts a Cloud SQL instance

@param [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 241
def restart(async: true)
  requires :identity

  data = service.restart_instance(identity)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless async }
end
restore_backup(backup_run_id, async: true) click to toggle source

Restores a backup of a Cloud SQL instance

@param [String] backup_run_id The identifier of the backup configuration @param [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 255
def restore_backup(backup_run_id, async: true)
  requires :identity

  data = service.restore_instance_backup(identity, backup_run_id)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.tap { |o| o.wait_for { ready? } unless async }
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 267
def save
  etag ? update : create
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 275
def settings_version
  settings[:settings_version]
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 283
def ssl_certs
  requires :identity

  service.ssl_certs.all(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 293
def tier
  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 301
def update
  requires :identity, :settings_version, :tier

  data = service.update_instance(identity, settings_version, tier, settings)
  operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name)
  operation.wait_for { !pending? }
  reload
end