Class: Fog::Google::SQL::Real

Inherits:
Object
  • Object
show all
Includes:
Fog::Google::Shared
Defined in:
lib/fog/google/requests/sql/list_flags.rb,
lib/fog/google/sql/real.rb,
lib/fog/google/requests/sql/list_tiers.rb,
lib/fog/google/requests/sql/list_users.rb,
lib/fog/google/requests/sql/delete_user.rb,
lib/fog/google/requests/sql/insert_user.rb,
lib/fog/google/requests/sql/update_user.rb,
lib/fog/google/requests/sql/get_instance.rb,
lib/fog/google/requests/sql/get_ssl_cert.rb,
lib/fog/google/requests/sql/get_operation.rb,
lib/fog/google/requests/sql/clone_instance.rb,
lib/fog/google/requests/sql/get_backup_run.rb,
lib/fog/google/requests/sql/list_instances.rb,
lib/fog/google/requests/sql/list_ssl_certs.rb,
lib/fog/google/requests/sql/delete_instance.rb,
lib/fog/google/requests/sql/delete_ssl_cert.rb,
lib/fog/google/requests/sql/export_instance.rb,
lib/fog/google/requests/sql/import_instance.rb,
lib/fog/google/requests/sql/insert_instance.rb,
lib/fog/google/requests/sql/insert_ssl_cert.rb,
lib/fog/google/requests/sql/list_operations.rb,
lib/fog/google/requests/sql/update_instance.rb,
lib/fog/google/requests/sql/list_backup_runs.rb,
lib/fog/google/requests/sql/restart_instance.rb,
lib/fog/google/requests/sql/delete_backup_run.rb,
lib/fog/google/requests/sql/insert_backup_run.rb,
lib/fog/google/requests/sql/restore_instance_backup.rb,
lib/fog/google/requests/sql/reset_instance_ssl_config.rb

Overview

Deletes all client certificates and generates a new server SSL certificate for the instance. The changes will not take effect until the instance is restarted. Existing instances without a server certificate will need to call this once to set a server certificate

Instance Attribute Summary collapse

Attributes included from Fog::Google::Shared

#api_url, #api_version, #project

Instance Method Summary collapse

Methods included from Fog::Google::Shared

#build_excon_response, #initialize_google_client, #request, #shared_initialize

Constructor Details

#initialize(options) ⇒ Real

Returns a new instance of Real.


10
11
12
13
14
15
16
# File 'lib/fog/google/sql/real.rb', line 10

def initialize(options)
  shared_initialize(options[:google_project], GOOGLE_SQL_API_VERSION, GOOGLE_SQL_BASE_URL)
  options[:google_api_scope_url] = GOOGLE_SQL_API_SCOPE_URLS.join(" ")

  initialize_google_client(options)
  @sql = ::Google::Apis::SqladminV1beta4::SQLAdminService.new
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


7
8
9
# File 'lib/fog/google/sql/real.rb', line 7

def client
  @client
end

#sqlObject (readonly)

Returns the value of attribute sql


8
9
10
# File 'lib/fog/google/sql/real.rb', line 8

def sql
  @sql
end

Instance Method Details

#clone_instance(instance_id, destination_name, log_filename: nil, log_position: nil) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/google/requests/sql/clone_instance.rb', line 9

def clone_instance(instance_id, destination_name,
                   log_filename: nil, log_position: nil)
  context = {
    :kind => "sql#cloneContext",
    :destination_instance_name => destination_name
  }

  unless log_filename.nil? || log_position.nil?
    context[:bin_log_coordinates] = ::Google::Apis::SqladminV1beta4::BinLogCoordinates.new(
      :kind => "sql#binLogCoordinates",
      :log_filename => log_filename,
      :log_position => log_position
    )
  end

  clone_request = ::Google::Apis::SqladminV1beta4::CloneInstancesRequest.new(
    :clone_context => ::Google::Apis::SqladminV1beta4::CloneContext.new(context)
  )

  @sql.clone_instance(@project, instance_id, clone_request)
end

#delete_backup_run(instance_id, backup_run_id) ⇒ Object


9
10
11
# File 'lib/fog/google/requests/sql/delete_backup_run.rb', line 9

def delete_backup_run(instance_id, backup_run_id)
  @sql.delete_backup_run(@project, instance_id, backup_run_id)
end

#delete_instance(instance_id) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/delete_instance.rb', line 10

def delete_instance(instance_id)
  @sql.delete_instance(@project, instance_id)
end

#delete_ssl_cert(instance_id, sha1_fingerprint) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/delete_ssl_cert.rb', line 10

def delete_ssl_cert(instance_id, sha1_fingerprint)
  @sql.delete_ssl_cert(@project, instance_id, sha1_fingerprint)
end

#delete_user(instance_id, host, name) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/delete_user.rb', line 10

def delete_user(instance_id, host, name)
  @sql.delete_user(@project, instance_id, host, name)
end

#export_instance(instance_id, uri, databases: [], sql_export_options: {}, csv_export_options: {}, file_type: nil) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/google/requests/sql/export_instance.rb', line 10

def export_instance(instance_id, uri,
                    databases: [],
                    sql_export_options: {},
                    csv_export_options: {},
                    file_type: nil)
  data = {
    :kind => "sql#exportContext",
    :uri => uri,
    :databases => databases
  }

  unless file_type.nil?
    data[:file_type] = file_type
  end

  unless csv_export_options.empty?
    data[:csv_export_options] =
      ::Google::Apis::SqladminV1beta4::ExportContext::CsvExportOptions.new(csv_export_options)
  end

  unless sql_export_options.nil?
    data[:sql_export_options] =
      ::Google::Apis::SqladminV1beta4::ExportContext::SqlExportOptions.new(sql_export_options)
  end

  export_context = ::Google::Apis::SqladminV1beta4::ExportContext.new(export_context)
  @sql.export_instance(
    @project,
    instance_id,
    ::Google::Apis::SqladminV1beta4::ExportInstancesRequest.new(
      :export_context => export_context
    )
  )
end

#get_backup_run(instance_id, backup_run_id) ⇒ Object


9
10
11
# File 'lib/fog/google/requests/sql/get_backup_run.rb', line 9

def get_backup_run(instance_id, backup_run_id)
  @sql.get_backup_run(@project, instance_id, backup_run_id)
end

#get_instance(instance_id) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/get_instance.rb', line 10

def get_instance(instance_id)
  @sql.get_instance(@project, instance_id)
end

#get_operation(operation_id) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/get_operation.rb', line 10

def get_operation(operation_id)
  @sql.get_operation(@project, operation_id)
end

#get_ssl_cert(instance_id, sha1_fingerprint) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/get_ssl_cert.rb', line 10

def get_ssl_cert(instance_id, sha1_fingerprint)
  @sql.get_ssl_cert(@project, instance_id, sha1_fingerprint)
end

#import_instance(instance_id, uri, database: nil, csv_import_options: nil, file_type: nil, import_user: nil) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/google/requests/sql/import_instance.rb', line 10

def import_instance(instance_id, uri, database: nil,
                    csv_import_options: nil, file_type: nil,
                    import_user: nil)
  data = {
    :kind => "sql#importContext",
    :uri => uri
  }
  data[:database] = database unless database.nil?
  data[:file_type] = file_type unless file_type.nil?
  data[:import_user] = import_user unless import_user.nil?
  unless csv_import_options.nil?
    data[:csv_import_options] =
      ::Google::Apis::SqladminV1beta4::ImportContext::CsvImportOptions.new(csv_import_options)
  end

  @sql.import_instance(
    @project,
    instance_id,
    ::Google::Apis::SqladminV1beta4::ImportInstancesRequest.new(
      :import_context => ::Google::Apis::SqladminV1beta4::ImportContext.new(data)
    )
  )
end

#insert_backup_run(instance_id, backup_run = {}) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/fog/google/requests/sql/insert_backup_run.rb', line 10

def insert_backup_run(instance_id, backup_run = {})
  @sql.insert_backup_run(
    @project,
    instance_id,
    ::Google::Apis::SqladminV1beta4::BackupRun.new(backup_run)
  )
end

#insert_instance(name, tier, instance = {}) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/fog/google/requests/sql/insert_instance.rb', line 10

def insert_instance(name, tier, instance = {})
  instance = ::Google::Apis::SqladminV1beta4::DatabaseInstance.new(instance)
  instance.name = name
  instance.settings = ::Google::Apis::SqladminV1beta4::Settings.new(instance.settings || {})
  instance.settings.tier = tier
  @sql.insert_instance(@project, instance)
end

#insert_ssl_cert(instance_id, common_name) ⇒ Object


10
11
12
13
14
15
16
17
18
# File 'lib/fog/google/requests/sql/insert_ssl_cert.rb', line 10

def insert_ssl_cert(instance_id, common_name)
  @sql.insert_ssl_cert(
    @project,
    instance_id,
    ::Google::Apis::SqladminV1beta4::InsertSslCertsRequest.new(
      :common_name => common_name
    )
  )
end

#insert_user(instance_id, user) ⇒ Object


10
11
12
13
# File 'lib/fog/google/requests/sql/insert_user.rb', line 10

def insert_user(instance_id, user)
  @sql.insert_user(@project, instance_id,
                   ::Google::Apis::SqladminV1beta4::User.new(user))
end

#list_backup_runs(instance_id, max_results: nil, page_token: nil) ⇒ Object


11
12
13
14
15
# File 'lib/fog/google/requests/sql/list_backup_runs.rb', line 11

def list_backup_runs(instance_id, max_results: nil, page_token: nil)
  @sql.list_backup_runs(@project, instance_id,
                        :max_results => max_results,
                        :page_token => page_token)
end

#list_flags(database_version: nil) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/list_flags.rb', line 10

def list_flags(database_version: nil)
  @sql.list_flags(:database_version => database_version)
end

#list_instances(filter: nil, max_results: nil, page_token: nil) ⇒ Object


10
11
12
13
14
15
# File 'lib/fog/google/requests/sql/list_instances.rb', line 10

def list_instances(filter: nil, max_results: nil, page_token: nil)
  @sql.list_instances(@project,
                      :filter => filter,
                      :max_results => max_results,
                      :page_token => page_token)
end

#list_operations(instance_id, max_results: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/google/requests/sql/list_operations.rb', line 11

def list_operations(instance_id, max_results: nil, page_token: nil)
  @sql.list_operations(@project,
                       instance_id,
                       :max_results => max_results,
                       :page_token => page_token)
end

#list_ssl_certs(instance_id) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/list_ssl_certs.rb', line 10

def list_ssl_certs(instance_id)
  @sql.list_ssl_certs(@project, instance_id)
end

#list_tiersObject


10
11
12
# File 'lib/fog/google/requests/sql/list_tiers.rb', line 10

def list_tiers
  @sql.list_tiers(@project)
end

#list_users(instance_id) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/list_users.rb', line 10

def list_users(instance_id)
  @sql.list_users(@project, instance_id)
end

#reset_instance_ssl_config(instance_id) ⇒ Object


12
13
14
# File 'lib/fog/google/requests/sql/reset_instance_ssl_config.rb', line 12

def reset_instance_ssl_config(instance_id)
  @sql.reset_instance_ssl_config(@project, instance_id)
end

#restart_instance(instance_id) ⇒ Object


10
11
12
# File 'lib/fog/google/requests/sql/restart_instance.rb', line 10

def restart_instance(instance_id)
  @sql.restart_instance(@project, instance_id)
end

#restore_instance_backup(instance_id, backup_run_id) ⇒ Object


10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/google/requests/sql/restore_instance_backup.rb', line 10

def restore_instance_backup(instance_id, backup_run_id)
  request = ::Google::Apis::SqladminV1beta4::RestoreInstancesBackupRequest.new(
    :restore_backup_context => ::Google::Apis::SqladminV1beta4::RestoreBackupContext.new(
      :backup_run_id => backup_run_id,
      :instance_id => instance_id,
      :kind => "sql#restoreBackupContext"
    )
  )
  @sql.restore_instance_backup(@project, instance_id, request)
end

#update_instance(instance_id, settings_version, tier, settings = {}) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/google/requests/sql/update_instance.rb', line 9

def update_instance(instance_id, settings_version, tier, settings = {})
  settings = ::Google::Apis::SqladminV1beta4::Settings.new(settings)
  settings.tier = tier
  settings.settings_version = settings_version

  @sql.update_instance(
    @project,
    instance_id,
    ::Google::Apis::SqladminV1beta4::DatabaseInstance.new(:settings => settings)
  )
end

#update_user(instance_id, host, name, user) ⇒ Object


10
11
12
13
14
15
# File 'lib/fog/google/requests/sql/update_user.rb', line 10

def update_user(instance_id, host, name, user)
  @sql.update_user(
    @project, instance_id, host, name,
    ::Google::Apis::SqladminV1beta4::User.new(user)
  )
end