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 ⇒ 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: nil) ⇒ 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 ⇒ 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(identity, attributes[:tier], attributes) operation = Fog::Google::SQL::Operations.new(:service => service).get(data.name) 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 settings[:database_flags] end |
#destroy(async: nil) ⇒ Fog::Google::SQL::Operation
Deletes a Cloud SQL instance
112 113 114 115 116 117 118 |
# 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: {}) ⇒ Fog::Google::SQL::Operation
Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file
132 133 134 135 136 137 138 |
# File 'lib/fog/google/models/sql/instance.rb', line 132 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
150 151 152 153 154 155 156 |
# File 'lib/fog/google/models/sql/instance.rb', line 150 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
162 163 164 165 |
# File 'lib/fog/google/models/sql/instance.rb', line 162 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
171 172 173 |
# 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 ⇒ Boolean
Returns whether SSL connections over IP should be enforced or not.
179 180 181 |
# 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 ⇒ String
Returns the preferred Compute Engine zone
195 196 197 |
# 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 ⇒ String
Returns the AppEngine application to follow
187 188 189 |
# 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 ⇒ String
Returns the pricing plan for this instance
203 204 205 |
# File 'lib/fog/google/models/sql/instance.rb', line 203 def pricing_plan settings[:pricing_plan] end |
#ready? ⇒ Boolean
Checks if the instance is running
211 212 213 |
# File 'lib/fog/google/models/sql/instance.rb', line 211 def ready? state == RUNNABLE_STATE end |
#reload ⇒ Fog::Google::SQL::Instance
Reload a Cloud SQL instance
314 315 316 317 318 319 320 |
# 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 ⇒ String
Returns the type of replication this instance uses
219 220 221 |
# File 'lib/fog/google/models/sql/instance.rb', line 219 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
228 229 230 231 232 233 234 |
# 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) ⇒ Fog::Google::SQL::Operation
Restarts a Cloud SQL instance
241 242 243 244 245 246 247 |
# 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) ⇒ Fog::Google::SQL::Operation
Restores a backup of a Cloud SQL instance
255 256 257 258 259 260 261 |
# 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 ⇒ Fog::Google::SQL::Instance
Saves a Cloud SQL instance
267 268 269 |
# File 'lib/fog/google/models/sql/instance.rb', line 267 def save etag ? update : create end |
#settings_version ⇒ String
Returns the version of instance settings
275 276 277 |
# File 'lib/fog/google/models/sql/instance.rb', line 275 def settings_version settings[:settings_version] end |
#ssl_certs ⇒ Array<Fog::Google::SQL::SslCert>
Lists all of the current SSL certificates for the instance
283 284 285 286 287 |
# File 'lib/fog/google/models/sql/instance.rb', line 283 def ssl_certs requires :identity service.ssl_certs.all(identity) end |
#tier ⇒ String
Returns the tier of service for this instance
293 294 295 |
# File 'lib/fog/google/models/sql/instance.rb', line 293 def tier settings[:tier] end |
#update ⇒ Fog::Google::SQL::Instance
Updates settings of a Cloud SQL instance
301 302 303 304 305 306 307 308 |
# 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 |