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".freeze
- PENDING_CREATE_STATE =
"PENDING_CREATE".freeze
- RUNNABLE_STATE =
"RUNNABLE".freeze
- SUSPENDED_STATE =
"SUSPENDED".freeze
- UNKNOWN_STATE =
"UNKNOWN_STATE".freeze
Instance Method Summary collapse
-
#activation_policy ⇒ String
Returns the activation policy for this instance.
-
#authorized_gae_applications ⇒ Array<String>
Returns the AppEngine app ids that can access this instance.
-
#backup_configuration ⇒ Hash
Returns the daily backup configuration for the instance.
-
#clone(destination_name, async: true, log_filename: nil, log_position: nil) ⇒ Fog::Google::SQL::Operation
Creates a Cloud SQL instance as a clone of the source instance.
-
#create(async = false) ⇒ Fog::Google::SQL::Instance
Creates a Cloud SQL instance.
-
#database_flags ⇒ Array<Hash>
Returns the database flags passed to the instance at startup.
-
#destroy(async = false) ⇒ 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_ipv4_enabled ⇒ Boolean
Returns whether the instance should be assigned an IP address or not.
-
#ip_configuration_require_ssl ⇒ Boolean
Returns whether SSL connections over IP should be enforced or not.
-
#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.
-
#reload ⇒ Fog::Google::SQL::Instance
Reload a Cloud SQL instance.
-
#replication_type ⇒ String
Returns the type of replication this instance uses.
-
#reset_ssl_config(async: true) ⇒ Fog::Google::SQL::Operation
Deletes all client certificates and generates a new server SSL certificate for the instance.
-
#restart(async: true) ⇒ Fog::Google::SQL::Operation
Restarts a Cloud SQL instance.
-
#restore_backup(backup_run_id, async: true) ⇒ Fog::Google::SQL::Operation
Restores a backup of a Cloud SQL instance.
-
#save ⇒ Fog::Google::SQL::Instance
Saves a Cloud SQL instance.
-
#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[:activation_policy] end |
#authorized_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 settings[:authorized_gae_applications] end |
#backup_configuration ⇒ 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["backup_configuration"] end |
#clone(destination_name, async: true, log_filename: nil, log_position: nil) ⇒ Fog::Google::SQL::Operation
Creates a Cloud SQL instance as a clone of the source instance
74 75 76 77 78 79 80 81 82 83 84 |
# 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(async = false) ⇒ Fog::Google::SQL::Instance
Creates a Cloud SQL instance
97 98 99 100 101 102 103 104 |
# File 'lib/fog/google/models/sql/instance.rb', line 97 def create(async = false) requires :identity data = service.insert_instance(identity, attributes[:tier], attributes) operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name) operation.wait_for { ready? } unless async reload end |
#database_flags ⇒ Array<Hash>
Returns the database flags passed to the instance at startup
110 111 112 |
# File 'lib/fog/google/models/sql/instance.rb', line 110 def database_flags settings[:database_flags] end |
#destroy(async = false) ⇒ Fog::Google::SQL::Operation
Deletes a Cloud SQL instance
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/fog/google/models/sql/instance.rb', line 121 def destroy(async = false) requires :identity # TODO(2.0): Add a deprecation warning here, depending on the decision in #27 # This is a compatibility fix leftover from breaking named parameter change if async.is_a?(Hash) async = async[:async] end 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: {}) ⇒ Fog::Google::SQL::Operation
Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file
147 148 149 150 151 152 153 |
# File 'lib/fog/google/models/sql/instance.rb', line 147 def export(uri, options: {}) requires :identity data = service.export_instance(identity, uri, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name) operation.tap { |o| o.wait_for { ready? } unless async } end |
#import(uri, options = {}) ⇒ Fog::Google::SQL::Operation
Imports data into a Cloud SQL instance from a MySQL dump file in Google Cloud Storage
165 166 167 168 169 170 171 |
# File 'lib/fog/google/models/sql/instance.rb', line 165 def import(uri, = {}) requires :identity data = service.import_instance(identity, uri, ) operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name) operation.tap { |o| o.wait_for { ready? } unless .fetch(:async, true) } end |
#ip_configuration_authorized_networks ⇒ Array<String>
Returns the list of external networks that are allowed to connect to the instance using the IP
177 178 179 180 |
# File 'lib/fog/google/models/sql/instance.rb', line 177 def settings.fetch(:ip_configuration, {}) .fetch(:authorized_networks, []) end |
#ip_configuration_ipv4_enabled ⇒ Boolean
Returns whether the instance should be assigned an IP address or not
186 187 188 |
# File 'lib/fog/google/models/sql/instance.rb', line 186 def ip_configuration_ipv4_enabled settings.fetch(:ip_configuration, {})[:ipv4_enabled] end |
#ip_configuration_require_ssl ⇒ Boolean
Returns whether SSL connections over IP should be enforced or not.
194 195 196 |
# File 'lib/fog/google/models/sql/instance.rb', line 194 def ip_configuration_require_ssl settings.fetch(:ip_configuration, {})[:require_ssl] end |
#location_preference_zone ⇒ String
Returns the preferred Compute Engine zone
210 211 212 |
# File 'lib/fog/google/models/sql/instance.rb', line 210 def location_preference_zone settings.fetch(:location_preference, {})[:zone] end |
#location_preference_zone_follow_gae_application ⇒ String
Returns the AppEngine application to follow
202 203 204 |
# File 'lib/fog/google/models/sql/instance.rb', line 202 def location_preference_zone_follow_gae_application settings.fetch(:location_preference, {})[:follow_gae_application] end |
#pricing_plan ⇒ String
Returns the pricing plan for this instance
218 219 220 |
# File 'lib/fog/google/models/sql/instance.rb', line 218 def pricing_plan settings[:pricing_plan] end |
#ready? ⇒ Boolean
Checks if the instance is running
226 227 228 |
# File 'lib/fog/google/models/sql/instance.rb', line 226 def ready? state == RUNNABLE_STATE end |
#reload ⇒ Fog::Google::SQL::Instance
Reload a Cloud SQL instance
329 330 331 332 333 334 335 |
# File 'lib/fog/google/models/sql/instance.rb', line 329 def reload requires :identity data = collection.get(identity) merge_attributes(data.attributes) self end |
#replication_type ⇒ String
Returns the type of replication this instance uses
234 235 236 |
# File 'lib/fog/google/models/sql/instance.rb', line 234 def replication_type settings[:replication_type] end |
#reset_ssl_config(async: true) ⇒ Fog::Google::SQL::Operation
Deletes all client certificates and generates a new server SSL certificate for the instance
243 244 245 246 247 248 249 |
# File 'lib/fog/google/models/sql/instance.rb', line 243 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) ⇒ Fog::Google::SQL::Operation
Restarts a Cloud SQL instance
256 257 258 259 260 261 262 |
# File 'lib/fog/google/models/sql/instance.rb', line 256 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) ⇒ Fog::Google::SQL::Operation
Restores a backup of a Cloud SQL instance
270 271 272 273 274 275 276 |
# File 'lib/fog/google/models/sql/instance.rb', line 270 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 ⇒ Fog::Google::SQL::Instance
Saves a Cloud SQL instance
282 283 284 |
# File 'lib/fog/google/models/sql/instance.rb', line 282 def save etag ? update : create end |
#settings_version ⇒ String
Returns the version of instance settings
290 291 292 |
# File 'lib/fog/google/models/sql/instance.rb', line 290 def settings_version settings[:settings_version] end |
#ssl_certs ⇒ Array<Fog::Google::SQL::SslCert>
Lists all of the current SSL certificates for the instance
298 299 300 301 302 |
# File 'lib/fog/google/models/sql/instance.rb', line 298 def ssl_certs requires :identity service.ssl_certs.all(identity) end |
#tier ⇒ String
Returns the tier of service for this instance
308 309 310 |
# File 'lib/fog/google/models/sql/instance.rb', line 308 def tier settings[:tier] end |
#update ⇒ Fog::Google::SQL::Instance
Updates settings of a Cloud SQL instance
316 317 318 319 320 321 322 323 |
# File 'lib/fog/google/models/sql/instance.rb', line 316 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 { ready? } reload end |