Class: Fog::Google::SQL::Instance
- Inherits:
-
Model
- Object
- Model
- Fog::Google::SQL::Instance
- Defined in:
- lib/fog/google/models/sql/instance.rb
Constant Summary collapse
- MAINTENANCE_STATE =
"MAINTENANCE"
- PENDING_CREATE_STATE =
"PENDING_CREATE"
- RUNNABLE_STATE =
"RUNNABLE"
- SUSPENDED_STATE =
"SUSPENDED"
- UNKNOWN_STATE =
"UNKNOWN_STATE"
Instance Method Summary collapse
-
#activation_policy ⇒ String
Returns the activation policy for this instance.
-
#autorized_gae_applications ⇒ Array<String>
Returns the AppEngine app ids that can access this instance.
-
#backup_configuration ⇒ Array<Hash>
Returns the daily backup configuration for the instance.
-
#clone(destination_name, options = {}) ⇒ Fog::Google::SQL::Operation
Creates a Cloud SQL instance as a clone of the source instance.
-
#create ⇒ Fog::Google::SQL::Instance
Creates a Cloud SQL instance.
-
#database_flags ⇒ Array<Hash>
Returns the database flags passed to the instance at startup.
-
#destroy(options = {}) ⇒ Fog::Google::SQL::Operation
Deletes a Cloud SQL instance.
-
#export(uri, options = {}) ⇒ Fog::Google::SQL::Operation
Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file.
-
#import(uri, options = {}) ⇒ Fog::Google::SQL::Operation
Imports data into a Cloud SQL instance from a MySQL dump file in Google Cloud Storage.
-
#ip_configuration_authorized_networks ⇒ Array<String>
Returns the list of external networks that are allowed to connect to the instance using the IP.
-
#ip_configuration_enabled ⇒ Boolean
Returns whether the instance should be assigned an IP address or not.
-
#ip_configuration_require_ssl ⇒ Boolean
Returns whether the mysqld should default to ‘REQUIRE X509’ for users connecting over IP.
-
#location_preference_zone ⇒ String
Returns the preferred Compute Engine zone.
-
#location_preference_zone_follow_gae_application ⇒ String
Returns the AppEngine application to follow.
-
#pricing_plan ⇒ String
Returns the pricing plan for this instance.
-
#ready? ⇒ Boolean
Checks if the instance is running.
-
#replication_type ⇒ String
Returns the type of replication this instance uses.
-
#reset_ssl_config(options = {}) ⇒ Fog::Google::SQL::Operation
Deletes all client certificates and generates a new server SSL certificate for the instance.
-
#restart(options = {}) ⇒ Fog::Google::SQL::Operation
Restarts a Cloud SQL instance.
-
#restore_backup(backup_configuration, due_time, options = {}) ⇒ Fog::Google::SQL::Operation
Restores a backup of a Cloud SQL instance.
-
#save ⇒ Fog::Google::SQL::Instance
Saves a Cloud SQL instance.
-
#set_root_password(password, options = {}) ⇒ Fog::Google::SQL::Operation
Sets the password for the root user.
-
#settings_version ⇒ String
Returns the version of instance settings.
-
#ssl_certs ⇒ Array<Fog::Google::SQL::SslCert>
Lists all of the current SSL certificates for the instance.
-
#tier ⇒ String
Returns the tier of service for this instance.
-
#update ⇒ Fog::Google::SQL::Instance
Updates settings of a Cloud SQL instance.
Instance Method Details
#activation_policy ⇒ String
Returns the activation policy for this instance
46 47 48 |
# File 'lib/fog/google/models/sql/instance.rb', line 46 def activation_policy settings["activationPolicy"] end |
#autorized_gae_applications ⇒ Array<String>
Returns the AppEngine app ids that can access this instance
54 55 56 |
# File 'lib/fog/google/models/sql/instance.rb', line 54 def autorized_gae_applications settings["authorizedGaeApplications"] end |
#backup_configuration ⇒ Array<Hash>
Returns the daily backup configuration for the instance
62 63 64 |
# File 'lib/fog/google/models/sql/instance.rb', line 62 def backup_configuration settings["backupConfiguration"] end |
#clone(destination_name, options = {}) ⇒ Fog::Google::SQL::Operation
Creates a Cloud SQL instance as a clone of the source instance
75 76 77 78 79 80 81 82 |
# File 'lib/fog/google/models/sql/instance.rb', line 75 def clone(destination_name, = {}) requires :identity data = service.clone_instance(identity, destination_name, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#create ⇒ Fog::Google::SQL::Instance
Creates a Cloud SQL instance
88 89 90 91 92 93 94 95 |
# File 'lib/fog/google/models/sql/instance.rb', line 88 def create requires :identity data = service.insert_instance(identity, attributes[:tier], attributes) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { !pending? } reload end |
#database_flags ⇒ Array<Hash>
Returns the database flags passed to the instance at startup
101 102 103 |
# File 'lib/fog/google/models/sql/instance.rb', line 101 def database_flags settings["databaseFlags"] end |
#destroy(options = {}) ⇒ Fog::Google::SQL::Operation
Deletes a Cloud SQL instance
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/fog/google/models/sql/instance.rb', line 111 def destroy( = {}) requires :identity data = service.delete_instance(identity) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) unless .fetch(:async, true) # DISABLED: A delete instance operation never reachs a 'DONE' state (bug?) # operation.wait_for { ready? } end operation end |
#export(uri, options = {}) ⇒ Fog::Google::SQL::Operation
Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file
135 136 137 138 139 140 141 142 |
# File 'lib/fog/google/models/sql/instance.rb', line 135 def export(uri, = {}) requires :identity data = service.export_instance(identity, uri, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#import(uri, options = {}) ⇒ Fog::Google::SQL::Operation
Imports data into a Cloud SQL instance from a MySQL dump file in Google Cloud Storage
154 155 156 157 158 159 160 161 |
# File 'lib/fog/google/models/sql/instance.rb', line 154 def import(uri, = {}) requires :identity data = service.import_instance(identity, uri, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#ip_configuration_authorized_networks ⇒ Array<String>
Returns the list of external networks that are allowed to connect to the instance using the IP
167 168 169 |
# File 'lib/fog/google/models/sql/instance.rb', line 167 def settings.fetch("ipConfiguration", {})["authorizedNetworks"] end |
#ip_configuration_enabled ⇒ Boolean
Returns whether the instance should be assigned an IP address or not
175 176 177 |
# File 'lib/fog/google/models/sql/instance.rb', line 175 def ip_configuration_enabled settings.fetch("ipConfiguration", {})["enabled"] end |
#ip_configuration_require_ssl ⇒ Boolean
Returns whether the mysqld should default to ‘REQUIRE X509’ for users connecting over IP
183 184 185 |
# File 'lib/fog/google/models/sql/instance.rb', line 183 def ip_configuration_require_ssl settings.fetch("ipConfiguration", {})["requireSsl"] end |
#location_preference_zone ⇒ String
Returns the preferred Compute Engine zone
199 200 201 |
# File 'lib/fog/google/models/sql/instance.rb', line 199 def location_preference_zone settings.fetch("locationPreference", {})["zone"] end |
#location_preference_zone_follow_gae_application ⇒ String
Returns the AppEngine application to follow
191 192 193 |
# File 'lib/fog/google/models/sql/instance.rb', line 191 def location_preference_zone_follow_gae_application settings.fetch("locationPreference", {})["followGaeApplication"] end |
#pricing_plan ⇒ String
Returns the pricing plan for this instance
207 208 209 |
# File 'lib/fog/google/models/sql/instance.rb', line 207 def pricing_plan settings["pricingPlan"] end |
#ready? ⇒ Boolean
Checks if the instance is running
215 216 217 |
# File 'lib/fog/google/models/sql/instance.rb', line 215 def ready? state == RUNNABLE_STATE end |
#replication_type ⇒ String
Returns the type of replication this instance uses
223 224 225 |
# File 'lib/fog/google/models/sql/instance.rb', line 223 def replication_type settings["replicationType"] end |
#reset_ssl_config(options = {}) ⇒ Fog::Google::SQL::Operation
Deletes all client certificates and generates a new server SSL certificate for the instance
233 234 235 236 237 238 239 240 |
# File 'lib/fog/google/models/sql/instance.rb', line 233 def reset_ssl_config( = {}) requires :identity data = service.reset_instance_ssl_config(identity) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#restart(options = {}) ⇒ Fog::Google::SQL::Operation
Restarts a Cloud SQL instance
248 249 250 251 252 253 254 255 |
# File 'lib/fog/google/models/sql/instance.rb', line 248 def restart( = {}) requires :identity data = service.restart_instance(identity) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#restore_backup(backup_configuration, due_time, options = {}) ⇒ Fog::Google::SQL::Operation
Restores a backup of a Cloud SQL instance
265 266 267 268 269 270 271 272 |
# File 'lib/fog/google/models/sql/instance.rb', line 265 def restore_backup(backup_configuration, due_time, = {}) requires :identity data = service.restore_instance_backup(identity, backup_configuration, due_time) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#save ⇒ Fog::Google::SQL::Instance
Saves a Cloud SQL instance
278 279 280 |
# File 'lib/fog/google/models/sql/instance.rb', line 278 def save etag ? update : create end |
#set_root_password(password, options = {}) ⇒ Fog::Google::SQL::Operation
Sets the password for the root user
289 290 291 292 293 294 295 296 |
# File 'lib/fog/google/models/sql/instance.rb', line 289 def set_root_password(password, = {}) requires :identity data = service.set_instance_root_password(identity, password) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { ready? } unless .fetch(:async, true) operation end |
#settings_version ⇒ String
Returns the version of instance settings
302 303 304 |
# File 'lib/fog/google/models/sql/instance.rb', line 302 def settings_version settings["settingsVersion"] end |
#ssl_certs ⇒ Array<Fog::Google::SQL::SslCert>
Lists all of the current SSL certificates for the instance
310 311 312 313 314 |
# File 'lib/fog/google/models/sql/instance.rb', line 310 def ssl_certs requires :identity service.ssl_certs.all(identity) end |
#tier ⇒ String
Returns the tier of service for this instance
320 321 322 |
# File 'lib/fog/google/models/sql/instance.rb', line 320 def tier settings["tier"] end |
#update ⇒ Fog::Google::SQL::Instance
Updates settings of a Cloud SQL instance
328 329 330 331 332 333 334 335 |
# File 'lib/fog/google/models/sql/instance.rb', line 328 def update requires :identity data = service.update_instance(identity, settings_version, tier, attributes) operation = Fog::Google::SQL::Operations.new(:service => service).get(instance, data.body["operation"]) operation.wait_for { !pending? } reload end |