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 self.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 self.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 self.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 83 84 |
# File 'lib/fog/google/models/sql/instance.rb', line 75 def clone(destination_name, = {}) requires :identity data = service.clone_instance(self.identity, destination_name, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation']) unless .fetch(:async, true) operation.wait_for { ready? } end operation end |
#create ⇒ Fog::Google::SQL::Instance
Creates a Cloud SQL instance
90 91 92 93 94 95 96 97 |
# 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 ⇒ Array<Hash>
Returns the database flags passed to the instance at startup
103 104 105 |
# File 'lib/fog/google/models/sql/instance.rb', line 103 def database_flags self.settings['databaseFlags'] end |
#destroy(options = {}) ⇒ Fog::Google::SQL::Operation
Deletes a Cloud SQL instance
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/fog/google/models/sql/instance.rb', line 113 def destroy( = {}) requires :identity data = service.delete_instance(self.identity) operation = Fog::Google::SQL::Operations.new(:service => service).get(self.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
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/fog/google/models/sql/instance.rb', line 137 def export(uri, = {}) requires :identity data = service.export_instance(self.identity, uri, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation']) unless .fetch(:async, true) operation.wait_for { ready? } end 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
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/fog/google/models/sql/instance.rb', line 158 def import(uri, = {}) requires :identity data = service.import_instance(self.identity, uri, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation']) unless .fetch(:async, true) operation.wait_for { ready? } end 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
173 174 175 |
# File 'lib/fog/google/models/sql/instance.rb', line 173 def self.settings.fetch('ipConfiguration', {})['authorizedNetworks'] end |
#ip_configuration_enabled ⇒ Boolean
Returns whether the instance should be assigned an IP address or not
181 182 183 |
# File 'lib/fog/google/models/sql/instance.rb', line 181 def ip_configuration_enabled self.settings.fetch('ipConfiguration', {})['enabled'] end |
#ip_configuration_require_ssl ⇒ Boolean
Returns whether the mysqld should default to ‘REQUIRE X509’ for users connecting over IP
189 190 191 |
# File 'lib/fog/google/models/sql/instance.rb', line 189 def ip_configuration_require_ssl self.settings.fetch('ipConfiguration', {})['requireSsl'] end |
#location_preference_zone ⇒ String
Returns the preferred Compute Engine zone
205 206 207 |
# 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 ⇒ String
Returns the AppEngine application to follow
197 198 199 |
# 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 ⇒ String
Returns the pricing plan for this instance
213 214 215 |
# File 'lib/fog/google/models/sql/instance.rb', line 213 def pricing_plan self.settings['pricingPlan'] end |
#ready? ⇒ Boolean
Checks if the instance is running
221 222 223 |
# File 'lib/fog/google/models/sql/instance.rb', line 221 def ready? self.state == RUNNABLE_STATE end |
#replication_type ⇒ String
Returns the type of replication this instance uses
229 230 231 |
# File 'lib/fog/google/models/sql/instance.rb', line 229 def replication_type self.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
239 240 241 242 243 244 245 246 247 248 |
# File 'lib/fog/google/models/sql/instance.rb', line 239 def reset_ssl_config( = {}) 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 .fetch(:async, true) operation.wait_for { ready? } end operation end |
#restart(options = {}) ⇒ Fog::Google::SQL::Operation
Restarts a Cloud SQL instance
256 257 258 259 260 261 262 263 264 265 |
# File 'lib/fog/google/models/sql/instance.rb', line 256 def restart( = {}) requires :identity data = service.restart_instance(self.identity) operation = Fog::Google::SQL::Operations.new(:service => service).get(self.instance, data.body['operation']) unless .fetch(:async, true) operation.wait_for { ready? } end operation end |
#restore_backup(backup_configuration, due_time, options = {}) ⇒ Fog::Google::SQL::Operation
Restores a backup of a Cloud SQL instance
275 276 277 278 279 280 281 282 283 284 |
# File 'lib/fog/google/models/sql/instance.rb', line 275 def restore_backup(backup_configuration, due_time, = {}) 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 .fetch(:async, true) operation.wait_for { ready? } end operation end |
#save ⇒ Fog::Google::SQL::Instance
Saves a Cloud SQL instance
290 291 292 |
# File 'lib/fog/google/models/sql/instance.rb', line 290 def save self.etag ? update : create end |
#set_root_password(password, options = {}) ⇒ Fog::Google::SQL::Operation
Sets the password for the root user
301 302 303 304 305 306 307 308 309 310 |
# File 'lib/fog/google/models/sql/instance.rb', line 301 def set_root_password(password, = {}) 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 .fetch(:async, true) operation.wait_for { ready? } end operation end |
#settings_version ⇒ String
Returns the version of instance settings
316 317 318 |
# File 'lib/fog/google/models/sql/instance.rb', line 316 def settings_version self.settings['settingsVersion'] end |
#ssl_certs ⇒ Array<Fog::Google::SQL::SslCert>
Lists all of the current SSL certificates for the instance
324 325 326 327 328 |
# File 'lib/fog/google/models/sql/instance.rb', line 324 def ssl_certs requires :identity service.ssl_certs.all(self.identity) end |
#tier ⇒ String
Returns the tier of service for this instance
334 335 336 |
# File 'lib/fog/google/models/sql/instance.rb', line 334 def tier self.settings['tier'] end |
#update ⇒ Fog::Google::SQL::Instance
Updates settings of a Cloud SQL instance
342 343 344 345 346 347 348 349 |
# 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 |