Class: Fog::Google::SQL::Mock
- Inherits:
-
Object
- Object
- Fog::Google::SQL::Mock
- Includes:
- Fog::Google::Shared
- Defined in:
- lib/fog/google/sql.rb,
lib/fog/google/requests/sql/list_flags.rb,
lib/fog/google/requests/sql/list_tiers.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/restore_instance_backup.rb,
lib/fog/google/requests/sql/reset_instance_ssl_config.rb,
lib/fog/google/requests/sql/set_instance_root_password.rb
Instance Attribute Summary
Attributes included from Fog::Google::Shared
#api_url, #api_version, #project
Class Method Summary collapse
Instance Method Summary collapse
- #clone_instance(instance_id, destination_name, options = {}) ⇒ Object
- #data ⇒ Object
- #delete_instance(instance_id) ⇒ Object
- #delete_ssl_cert(instance_id, sha1_fingerprint) ⇒ Object
- #export_instance(instance_id, uri, options = {}) ⇒ Object
- #get_backup_run(instance_id, backup_configuration_id, due_time) ⇒ Object
- #get_instance(instance_id) ⇒ Object
- #get_operation(instance_id, operation_id) ⇒ Object
- #get_ssl_cert(instance_id, sha1_fingerprint) ⇒ Object
- #import_instance(instance_id, uri, options = {}) ⇒ Object
-
#initialize(options) ⇒ Mock
constructor
A new instance of Mock.
- #insert_instance(name, tier, options = {}) ⇒ Object
- #insert_ssl_cert(instance_id, common_name) ⇒ Object
- #list_backup_runs(instance_id, backup_configuration_id) ⇒ Object
- #list_flags ⇒ Object
- #list_instances ⇒ Object
- #list_operations(instance_id) ⇒ Object
- #list_ssl_certs(instance_id) ⇒ Object
- #list_tiers ⇒ Object
- #random_operation ⇒ Object
- #reset_data ⇒ Object
- #reset_instance_ssl_config(instance_id) ⇒ Object
- #restart_instance(instance_id) ⇒ Object
- #restore_instance_backup(identity, backup_configuration, due_time) ⇒ Object
- #set_instance_root_password(instance_id, password) ⇒ Object
- #update_instance(instance_id, settings_version, tier, options = {}) ⇒ Object
Methods included from Fog::Google::Shared
#build_excon_response, #create_signing_key, #initialize_google_client, #new_pk12_google_client, #request, #shared_initialize
Constructor Details
#initialize(options) ⇒ Mock
Returns a new instance of Mock.
84 85 86 |
# File 'lib/fog/google/sql.rb', line 84 def initialize() shared_initialize([:google_project], GOOGLE_SQL_API_VERSION, GOOGLE_SQL_BASE_URL) end |
Class Method Details
.data ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fog/google/sql.rb', line 88 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :backup_runs => {}, :instances => {}, :operations => {}, :ssl_certs => {}, } end end |
.reset ⇒ Object
99 100 101 |
# File 'lib/fog/google/sql.rb', line 99 def self.reset @data = nil end |
Instance Method Details
#clone_instance(instance_id, destination_name, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fog/google/requests/sql/clone_instance.rb', line 40 def clone_instance(instance_id, destination_name, = {}) self.data[:instances][destination_name] = self.data[:instances][instance_id] self.data[:instances][destination_name]['instance'] = destination_name self.data[:ssl_certs][destination_name] = {} self.data[:backup_runs][destination_name] = {} operation = self.random_operation self.data[:operations][destination_name] ||= {} self.data[:operations][destination_name][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => destination_name, 'operation' => operation, 'operationType' => 'CREATE', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'CLONE', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesClone', 'operation' => operation, } build_excon_response(body) end |
#data ⇒ Object
103 104 105 |
# File 'lib/fog/google/sql.rb', line 103 def data self.class.data[project] end |
#delete_instance(instance_id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fog/google/requests/sql/delete_instance.rb', line 22 def delete_instance(instance_id) if self.data[:instances].has_key?(instance_id) self.data[:instances].delete(instance_id) self.data[:ssl_certs].delete(instance_id) self.data[:backup_runs].delete(instance_id) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'DELETE', 'state' => Fog::Google::SQL::Operation::PENDING_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesDelete', 'operation' => operation, } status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#delete_ssl_cert(instance_id, sha1_fingerprint) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/google/requests/sql/delete_ssl_cert.rb', line 23 def delete_ssl_cert(instance_id, sha1_fingerprint) if self.data[:ssl_certs].has_key?(instance_id) self.data[:ssl_certs][instance_id].delete(sha1_fingerprint) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'UPDATE', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#sslCertsDelete', 'operation' => operation, } status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#export_instance(instance_id, uri, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/google/requests/sql/export_instance.rb', line 31 def export_instance(instance_id, uri, = {}) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'EXPORT', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesExport', 'operation' => operation, } build_excon_response(body) end |
#get_backup_run(instance_id, backup_configuration_id, due_time) ⇒ Object
24 25 26 |
# File 'lib/fog/google/requests/sql/get_backup_run.rb', line 24 def get_backup_run(instance_id, backup_configuration_id, due_time) Fog::Mock.not_implemented end |
#get_instance(instance_id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/google/requests/sql/get_instance.rb', line 22 def get_instance(instance_id) if self.data[:instances].has_key?(instance_id) body = self.data[:instances][instance_id] status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#get_operation(instance_id, operation_id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/google/requests/sql/get_operation.rb', line 23 def get_operation(instance_id, operation_id) if self.data[:operations].has_key?(instance_id) if self.data[:operations][instance_id].has_key?(operation_id) body = self.data[:operations][instance_id][operation_id] status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'operationDoesNotExist', 'message' => 'The Cloud SQL instance operation does not exist.', } ], 'code' => 404, 'message' => 'The Cloud SQL instance operation does not exist.', } } status = 404 end else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#get_ssl_cert(instance_id, sha1_fingerprint) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/google/requests/sql/get_ssl_cert.rb', line 23 def get_ssl_cert(instance_id, sha1_fingerprint) if self.data[:ssl_certs].has_key?(instance_id) if self.data[:ssl_certs][instance_id].has_key?(sha1_fingerprint) body = self.data[:ssl_certs][instance_id][sha1_fingerprint] status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'sslCertificateDoesNotExist', 'message' => 'The SSL certificate does not exist.', } ], 'code' => 404, 'message' => 'The SSL certificate does not exist.', } } status = 404 end else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#import_instance(instance_id, uri, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/google/requests/sql/import_instance.rb', line 30 def import_instance(instance_id, uri, = {}) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'IMPORT', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesImport', 'operation' => operation, } build_excon_response(body) end |
#insert_instance(name, tier, options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/fog/google/requests/sql/insert_instance.rb', line 68 def insert_instance(name, tier, = {}) data = { 'kind' => 'sql#instance', 'instance' => name, 'etag' => Fog::Mock.random_base64(32), 'project' => @project, 'state' => Fog::Google::SQL::Instance::RUNNABLE_STATE , 'databaseVersion' => 'MYSQL_5_5', 'region' => [:region] || 'us-central', 'currentDiskSize' => '86245269', 'maxDiskSize' => '268435456000', 'settings' => { 'kind' => 'sql#settings', 'settingsVersion' => '1', 'tier' => tier, 'backupConfiguration' => [ { 'kind' => 'sql#backupConfiguration', 'startTime' => '04:00', 'enabled' => false, 'id' => Fog::Mock.random_hex(32), 'binaryLogEnabled' => false } ], 'pricingPlan' => [:pricing_plan] || 'PER_USE', 'replicationType' => [:replication_type] || 'SYNCHRONOUS', 'activationPolicy' => [:activation_policy] || 'ON_DEMAND', 'ipConfiguration' => { 'enabled' => false, }, 'locationPreference' => { 'kind' => 'sql#locationPreference', } }, 'serverCaCert' => { 'kind' => 'sql#sslCert', 'instance' => name, 'sha1Fingerprint' => Fog::Mock.random_hex(40), 'commonName' => 'C=US,O=Google\\, Inc,CN=Google Cloud SQL Server CA', 'certSerialNumber' => '0', 'cert' => "-----BEGIN CERTIFICATE-----\nMIIDITCCAgmgAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMSMwIQYDVQQDExpHb29n\nbGUgQ2xvdWQgU1FMIFNlcnZlciBDQTEUMBIGA1UEChMLR29vZ2xlLCBJbmMxCzAJ\nBgNVBAYTAlVTMB4XDTE0MDYwNDA1MjkxMVoXDTI0MDYwMTA1MjkxMVowSDEjMCEG\nA1UEAxMaR29vZ2xlIENsb3VkIFNRTCBTZXJ2ZXIgQ0ExFDASBgNVBAoTC0dvb2ds\nZSwgSW5jMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\nggEBALlRjq3zccH5ed6NMfCFcTYd9XxYXyvLurxxjDIA6A7/ymVM9qdQC0uckf7C\nsi4uMi2yfK+PHZ0jXC+g0uPx5RTm+nbKl4I++VOh2g6oZHeNdFt4rVJpr+jzGUMf\nr67SymUr70TQOTEVpx2Ud3rBB2szulxWUSXEy2AGA3uNUGe/IgENh7p56s00Sr97\nTRP1S5/JVMalncgNVLH2nNqBQJZTx9t9qvGatoUfmHUU0+M//J5sXLbgdzeEeeot\nHJUyoXjA2sRkH1+F/d6PpFrcr1I8dVmCBEbTAnm7HpKh5Mx2nRYi+t/y9D2Mblwx\n9dBRfr3WIJ1JDxzt3L8CtBGZbvUCAwEAAaMWMBQwEgYDVR0TAQH/BAgwBgEB/wIB\nADANBgkqhkiG9w0BAQUFAAOCAQEAmHuBecPc265sbd26B1HXUAD6FHdzoZLrAZVW\n+1eIK4E669P4y6LkLuoCkLd64/YwA4K2FioksqgHOahbYWJJYPymy4ae+IPXzXcY\nPv3gmBsKk++sHb64D9Cj/k5n8BEiVmmrsUCUiL75nJAzK+El3hvKKWWl76XX/qHP\nk8ZAxIrn8bCiVOaj6NR4+p1OmcZSPNWxz7j/EwQxoABRxgPgt+B/YRseevww7an2\n/rGs0sk7RE0QDjLfZblYGh+xVPBBLuLmf4L5JNJkFEoeGSWrxTzvXnS+2LZeHdM/\nJ9nsiKu5JKPhMUS0vOcTymOkh8tJ6Np8gwg6ca4g6dT3llE6uQ==\n-----END CERTIFICATE-----", 'createTime' => Time.now.iso8601, 'expirationTime' => Time.now.iso8601, } } if [:autorized_gae_applications] data['settings']['authorizedGaeApplications'] = Array([:autorized_gae_applications]) end if [:backup_configuration] data['settings']['backupConfiguration'] = [:backup_configuration] end if [:ip_configuration_authorized_networks] data['settings']['ipConfiguration']['authorizedNetworks'] = Array([:ip_configuration_authorized_networks]) end if [:ip_configuration_enabled] data['settings']['ipConfiguration']['enabled'] = [:ip_configuration_enabled] end if [:ip_configuration_require_ssl] data['settings']['ipConfiguration']['requireSsl'] = [:ip_configuration_require_ssl] end if [:location_preference_zone_follow_gae_application] data['settings']['locationPreference']['followGaeApplication'] = [:location_preference_zone_follow_gae_application] end if [:location_preference_zone] data['settings']['locationPreference']['zone'] = [:location_preference_zone] end self.data[:instances][name] = data self.data[:ssl_certs][name] = {} self.data[:backup_runs][name] = {} operation = self.random_operation self.data[:operations][name] ||= {} self.data[:operations][name][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => name, 'operation' => operation, 'operationType' => 'CREATE', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesInsert', 'operation' => operation, } status = 200 build_excon_response(body, status) end |
#insert_ssl_cert(instance_id, common_name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fog/google/requests/sql/insert_ssl_cert.rb', line 26 def insert_ssl_cert(instance_id, common_name) if self.data[:ssl_certs].has_key?(instance_id) sha1_fingerprint = Fog::Mock.random_hex(40) data = { 'kind' => 'sql#sslCert', 'instance' => instance_id, 'sha1Fingerprint' => sha1_fingerprint, 'commonName' => common_name, 'certSerialNumber' => Fog::Mock.random_numbers(9), 'cert' => "-----BEGIN CERTIFICATE-----\nMIIC/zCCAeegAwIBAgIELAk5vzANBgkqhkiG9w0BAQUFADBNMSgwJgYDVQQDEx9H\nb29nbGUgQ2xvdWQgU1FMIENsaWVudCBDQSB0ZXN0MRQwEgYDVQQKEwtHb29nbGUs\nIEluYzELMAkGA1UEBhMCVVMwHhcNMTQwNjA0MDY1MjAwWhcNMjQwNjAxMDY1MjAw\nWjAyMQ0wCwYDVQQDEwR0ZXN0MRQwEgYDVQQKEwtHb29nbGUsIEluYzELMAkGA1UE\nBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9G9ZG19n978EW\n5bQ/TM1Fnb4fd/FRT8XMs2D5C7+dKLEgbeUOvZQt4EsQ6cC+UVhoK7N6DvnXAZ1M\ng+B159Xlqjv8Mh5RihfGjPCdlw2pF7Pu68LyYghvQLhi7yhuNeaN+FBeKvjcW9k0\ni54AM8Ub2a/kxAwMtXm1kGtgc1+qkUlyBxfn1UoKI5Dhvw/InxgI1kS/VUkkk9kv\n0q/oyPrboE/vuSitDq+pHjRFwrIQcS6Pz9DYHhZVyDDkTIh7vLXM0JEQRT1SiA8k\n+4hwXI3WBqPRZRI4H1KmYSSIKvZtci63SbM/rHitXkGipFF1lw0gSqfpM8gG36fl\naITBPI97AgMBAAGjAjAAMA0GCSqGSIb3DQEBBQUAA4IBAQCOvRWYdcaYl/qHgif8\nvD4QEQLiy3+Hn5zSLQEcqP/BymhUw4LSGhu8NJxJ26PvlHzAnWa2/OkTCkgSpM4k\nkebO2vyuU8XY/7FeRO3uNktEAp2Aw1RYJ/IqSDvjpg5/hJTHKADrAkiu2SyCJvoO\nqblzBO7TvLj5BBdvcr1/hfWRuAt5NykOww9AMEAzrfLzrF7f98RntOZzIwwX+UvF\nLXQZwc/b55d97Y249pLRQCBnHdaEtZLQTEQulj1zMx2lkH5CrQWGwDCVFuIyt/rN\nzFJGN09McKrWkBZuwPtkkyb+sBVXZX6cEFgHHA+7D91QRH4lbEjjO8OjQgaA6qWN\n5iGN\n-----END CERTIFICATE-----", 'createTime' => Time.now.iso8601, 'expirationTime' => Time.now.iso8601, } self.data[:ssl_certs][instance_id][sha1_fingerprint] = data body = { 'kind' => 'sql#sslCertsInsert', 'serverCaCert' => { 'kind' => 'sql#sslCert', 'instance' => instance_id, 'sha1Fingerprint' => Fog::Mock.random_hex(40), 'commonName' => 'C=US,O=Google\\, Inc,CN=Google Cloud SQL Server CA', 'certSerialNumber' => '0', 'cert' => "-----BEGIN CERTIFICATE-----\nMIIDITCCAgmgAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMSMwIQYDVQQDExpHb29n\nbGUgQ2xvdWQgU1FMIFNlcnZlciBDQTEUMBIGA1UEChMLR29vZ2xlLCBJbmMxCzAJ\nBgNVBAYTAlVTMB4XDTE0MDYwNDA1MjkxMVoXDTI0MDYwMTA1MjkxMVowSDEjMCEG\nA1UEAxMaR29vZ2xlIENsb3VkIFNRTCBTZXJ2ZXIgQ0ExFDASBgNVBAoTC0dvb2ds\nZSwgSW5jMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\nggEBALlRjq3zccH5ed6NMfCFcTYd9XxYXyvLurxxjDIA6A7/ymVM9qdQC0uckf7C\nsi4uMi2yfK+PHZ0jXC+g0uPx5RTm+nbKl4I++VOh2g6oZHeNdFt4rVJpr+jzGUMf\nr67SymUr70TQOTEVpx2Ud3rBB2szulxWUSXEy2AGA3uNUGe/IgENh7p56s00Sr97\nTRP1S5/JVMalncgNVLH2nNqBQJZTx9t9qvGatoUfmHUU0+M//J5sXLbgdzeEeeot\nHJUyoXjA2sRkH1+F/d6PpFrcr1I8dVmCBEbTAnm7HpKh5Mx2nRYi+t/y9D2Mblwx\n9dBRfr3WIJ1JDxzt3L8CtBGZbvUCAwEAAaMWMBQwEgYDVR0TAQH/BAgwBgEB/wIB\nADANBgkqhkiG9w0BAQUFAAOCAQEAmHuBecPc265sbd26B1HXUAD6FHdzoZLrAZVW\n+1eIK4E669P4y6LkLuoCkLd64/YwA4K2FioksqgHOahbYWJJYPymy4ae+IPXzXcY\nPv3gmBsKk++sHb64D9Cj/k5n8BEiVmmrsUCUiL75nJAzK+El3hvKKWWl76XX/qHP\nk8ZAxIrn8bCiVOaj6NR4+p1OmcZSPNWxz7j/EwQxoABRxgPgt+B/YRseevww7an2\n/rGs0sk7RE0QDjLfZblYGh+xVPBBLuLmf4L5JNJkFEoeGSWrxTzvXnS+2LZeHdM/\nJ9nsiKu5JKPhMUS0vOcTymOkh8tJ6Np8gwg6ca4g6dT3llE6uQ==\n-----END CERTIFICATE-----", 'createTime' => Time.now.iso8601, 'expirationTime' => Time.now.iso8601, }, 'clientCert' => { 'certInfo' => data, 'certPrivateKey' => "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAvRvWRtfZ/e/BFuW0P0zNRZ2+H3fxUU/FzLNg+Qu/nSixIG3l\nDr2ULeBLEOnAvlFYaCuzeg751wGdTIPgdefV5ao7/DIeUYoXxozwnZcNqRez7uvC\n8mIIb0C4Yu8objXmjfhQXir43FvZNIueADPFG9mv5MQMDLV5tZBrYHNfqpFJcgcX\n59VKCiOQ4b8PyJ8YCNZEv1VJJJPZL9Kv6Mj626BP77korQ6vqR40RcKyEHEuj8/Q\n2B4WVcgw5EyIe7y1zNCREEU9UogPJPuIcFyN1gaj0WUSOB9SpmEkiCr2bXIut0mz\nP6x4rV5BoqRRdZcNIEqn6TPIBt+n5WiEwTyPewIDAQABAoIBAH89e6+vDL4P05vU\ncrMkufldac9CpNxREIXrLBRmE0drWcK4Lqb8Z/d2MwvuPAHSOendfaVi7jf8nhod\noamzk/gz0qieEEhM4jJ2Im/mcwqTKD5Z45Gy5Hn20hm/UTTWj4p2yZySzV93bW4t\nguIf80AJ+I+0WWczs/C2e4kqF/RrIf4ff7UF/2TPS+sEmkTA74APWIMqjkr0cjTP\nrIJCp8jFn/639dVLeHcw2abduZSV8PkQSNdqPeH2P+GpqkYLREPMAw/jPGZYoVli\npQ57cB1THj/juYFYMS7dlJ3hr0pDo6Vw30L6EcE63dvXzJvhOfPXtFufdfanPiey\nUSICtAECgYEA/qP7ZJ9ohqg4D5v9TM4fVlUpo68/jMaWlPPoLQwNXZ81rTN4yOxm\nUJLhDvQCWYZie1jwn9+UA1bdp4PceSbEWh4iM0h4TcxmhHmos6pxGYb/uw6jGLw4\nqjCqDP69/Jgmkfobs4u/h9xtZEHo6u5rrbDZIu0EezL7ArMrSOYVRsMCgYEAvh5K\n4H5EVMhiHnjvbpToOzGjMpqoBr0XSq63Cx45U5on5Bp8oc/iQPnCzpwcrJb4vwRV\nVYYtD/PWpdjzhTVy6SgVnkTKoo6N/Y9vFAYCf67eb4Yu4L8MonlYU2IY7bA3SChw\nesHlwsVZdlNqieWmOuacA8IbgXW4ftbtZDzBuOkCgYEArA8rn+simtJxxwJVHp+s\nhw5Wa3bQDxRkzVMdz8p0AY3BnD3KYKFz5P/KOOth5xIp20TWmoBdKAB7F2S/BdHP\nHUF9RH+0YoU5xEvcVUJW17PjeobCZ8VO2Ji3Xr6Gq3Y3oa2JKEHGckvcUsFCW/Qs\nKBn2LmZO/9wLxeBA4CovuDcCgYAVGTWEDl807Xv+F7uykPHox8xtrD4jaU6xagxE\nPplsDrqIlOvp5TEdttoIpciE2shGIov5zscncw8KHrZ/vPvApkMn6kh2m81kK0vP\ndA9I7jYfOEvxgyI60a6cqlFL53drGZnJ9cSyxcX03LMBFKxK8xazUBJPXqoX4XA8\n5IU3KQKBgQDCPVBZbZcwcfI+fGRZX8DLE61tscK1uy0ySQPmz/tm3ixDAdQNgGvD\nXjyPvMCEtHx7+ZbykLS7SJZG4924LKyGxF9bw5AYTPyxietOUfoqaS8v3kJ03Ebu\nkVDmZkAiMk5E+oGchYsD613QRFjF4nlmrHfxtRqTPqa/OpNDimdG+w==\n-----END RSA PRIVATE KEY-----", } } status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#list_backup_runs(instance_id, backup_configuration_id) ⇒ Object
24 25 26 |
# File 'lib/fog/google/requests/sql/list_backup_runs.rb', line 24 def list_backup_runs(instance_id, backup_configuration_id) Fog::Mock.not_implemented end |
#list_flags ⇒ Object
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/fog/google/requests/sql/list_flags.rb', line 19 def list_flags body = { 'kind' => 'sql#flagsList', 'items' => [ { 'kind' => 'sql#flag', 'name' => 'log_output', 'type' => 'STRING', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'allowedStringValues' => ['TABLE', 'NONE'], }, { 'kind' => 'sql#flag', 'name' => 'general_log', 'type' => 'BOOLEAN', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'log_queries_not_using_indexes', 'type' => 'BOOLEAN', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'log_bin_trust_function_creators', 'type' => 'BOOLEAN', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'slow_query_log', 'type' => 'BOOLEAN', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'read_only', 'type' => 'BOOLEAN', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'max_allowed_packet', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '16384', 'maxValue' => '1073741824', }, { 'kind' => 'sql#flag', 'name' => 'long_query_time', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '0', 'maxValue' => '30000000', }, { 'kind' => 'sql#flag', 'name' => 'group_concat_max_len', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '4', 'maxValue' => '17179869184', }, { 'kind' => 'sql#flag', 'name' => 'wait_timeout', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '1', 'maxValue' => '31536000', }, { 'kind' => 'sql#flag', 'name' => 'innodb_lock_wait_timeout', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '1', 'maxValue' => '1073741824', }, { 'kind' => 'sql#flag', 'name' => 'lower_case_table_names', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '0', 'maxValue' => '2', }, { 'kind' => 'sql#flag', 'name' => 'innodb_flush_log_at_trx_commit', 'type' => 'INTEGER', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'minValue' => '0', 'maxValue' => '2', }, { 'kind' => 'sql#flag', 'name' => 'skip_show_database', 'type' => 'NONE', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'event_scheduler', 'type' => 'BOOLEAN', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], }, { 'kind' => 'sql#flag', 'name' => 'character_set_server', 'type' => 'STRING', 'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'], 'allowedStringValues' => ['utf8', 'utf8mb4'], }, ] } build_excon_response(body) end |
#list_instances ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/fog/google/requests/sql/list_instances.rb', line 21 def list_instances body = { 'kind' => 'sql#instancesList', 'items' => self.data[:instances].values, } build_excon_response(body) end |
#list_operations(instance_id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/google/requests/sql/list_operations.rb', line 23 def list_operations(instance_id) if self.data[:operations].has_key?(instance_id) body = { 'kind' => 'sql#operationsList', 'items' => self.data[:operations][instance_id].values, } status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#list_ssl_certs(instance_id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fog/google/requests/sql/list_ssl_certs.rb', line 22 def list_ssl_certs(instance_id) if self.data[:ssl_certs].has_key?(instance_id) body = { 'kind' => 'sql#sslCertsList', 'items' => self.data[:ssl_certs][instance_id].values, } status = 200 else body = { 'error' => { 'errors' => [ { 'domain' => 'global', 'reason' => 'notAuthorized', 'message' => 'The client is not authorized to make this request.', } ], 'code' => 403, 'message' => 'The client is not authorized to make this request.', } } status = 403 end build_excon_response(body, status) end |
#list_tiers ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fog/google/requests/sql/list_tiers.rb', line 21 def list_tiers body = { 'kind' => 'sql#tiersList', 'items' => [ { 'kind' => 'sql#tier', 'tier' => 'D0', 'RAM' => '134217728', 'DiskQuota' => '268435456000', 'region' => ['us-central', 'europe-west1', 'asia-east1'], }, { 'kind' => 'sql#tier', 'tier' => 'D1', 'RAM' => '536870912', 'DiskQuota' => '268435456000', 'region' => ['us-central', 'europe-west1', 'asia-east1'], }, { 'kind' => 'sql#tier', 'tier' => 'D2', 'RAM' => '1073741824', 'DiskQuota' => '268435456000', 'region' => ['us-central', 'europe-west1', 'asia-east1'], }, { 'kind' => 'sql#tier', 'tier' => 'D4', 'RAM' => '2147483648', 'DiskQuota' => '268435456000', 'region' => ['us-central', 'europe-west1', 'asia-east1'], }, { 'kind' => 'sql#tier', 'tier' => 'D8', 'RAM' => '4294967296', 'DiskQuota' => '268435456000', 'region' => ['us-central', 'europe-west1', 'asia-east1'], }, { 'kind' => 'sql#tier', 'tier' => 'D16', 'RAM' => '8589934592', 'DiskQuota' => '268435456000', 'region' => ['us-central', 'europe-west1', 'asia-east1'], }, { 'kind' => 'sql#tier', 'tier' => 'D32', 'RAM' => '17179869184', 'DiskQuota' => '268435456000', 'region' => ['us-central'], }, ] } build_excon_response(body) end |
#random_operation ⇒ Object
111 112 113 |
# File 'lib/fog/google/sql.rb', line 111 def random_operation "operation-#{Fog::Mock.random_numbers(13)}-#{Fog::Mock.random_hex(13)}-#{Fog::Mock.random_hex(8)}" end |
#reset_data ⇒ Object
107 108 109 |
# File 'lib/fog/google/sql.rb', line 107 def reset_data self.class.data.delete(project) end |
#reset_instance_ssl_config(instance_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/google/requests/sql/reset_instance_ssl_config.rb', line 24 def reset_instance_ssl_config(instance_id) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'UPDATE', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesResetSslConfig', 'operation' => operation, } build_excon_response(body) end |
#restart_instance(instance_id) ⇒ Object
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/restart_instance.rb', line 22 def restart_instance(instance_id) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'RESTART', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesRestart', 'operation' => operation, } build_excon_response(body) end |
#restore_instance_backup(identity, backup_configuration, due_time) ⇒ Object
24 25 26 |
# File 'lib/fog/google/requests/sql/restore_instance_backup.rb', line 24 def restore_instance_backup(identity, backup_configuration, due_time) Fog::Mock.not_implemented end |
#set_instance_root_password(instance_id, password) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/google/requests/sql/set_instance_root_password.rb', line 29 def set_instance_root_password(instance_id, password) operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'INJECT_USER', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesSetRootPassword', 'operation' => operation, } build_excon_response(body) end |
#update_instance(instance_id, settings_version, tier, options = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/fog/google/requests/sql/update_instance.rb', line 67 def update_instance(instance_id, settings_version, tier, = {}) data = self.data[:instances][instance_id] data['tier'] = tier if [:activation_policy] data['settings']['activationPolicy'] = [:activation_policy] end if [:autorized_gae_applications] data['settings']['authorizedGaeApplications'] = Array([:autorized_gae_applications]) end if [:backup_configuration] data['settings']['backupConfiguration'] = [:backup_configuration] end if [:ip_configuration_authorized_networks] data['settings']['ipConfiguration'] ||= {} data['settings']['ipConfiguration']['authorizedNetworks'] = Array([:ip_configuration_authorized_networks]) end if [:ip_configuration_enabled] data['settings']['ipConfiguration'] ||= {} data['settings']['ipConfiguration']['enabled'] = [:ip_configuration_enabled] end if [:ip_configuration_require_ssl] data['settings']['ipConfiguration'] ||= {} data['settings']['ipConfiguration']['requireSsl'] = [:ip_configuration_require_ssl] end if [:location_preference_zone_follow_gae_application] data['settings']['locationPreference'] ||= {} data['settings']['locationPreference']['followGaeApplication'] = [:location_preference_zone_follow_gae_application] end if [:location_preference_zone] data['settings']['locationPreference'] ||= {} data['settings']['locationPreference']['zone'] = [:location_preference_zone] end if [:pricing_plan] data['settings']['pricingPlan'] = [:pricing_plan] end if [:replication_type] data['settings']['replicationType'] = [:replication_type] end self.data[:instances][instance_id] = data operation = self.random_operation self.data[:operations][instance_id] ||= {} self.data[:operations][instance_id][operation] = { 'kind' => 'sql#instanceOperation', 'instance' => instance_id, 'operation' => operation, 'operationType' => 'UPDATE', 'state' => Fog::Google::SQL::Operation::DONE_STATE, 'userEmailAddress' => '[email protected]', 'enqueuedTime' => Time.now.iso8601, 'startTime' => Time.now.iso8601, 'endTime' => Time.now.iso8601, } body = { 'kind' => 'sql#instancesUpdate', 'operation' => operation, } status = 200 build_excon_response(body, status) end |