Class: Google::Cloud::Gemserver::CLI::CloudSQL
- Inherits:
-
Object
- Object
- Google::Cloud::Gemserver::CLI::CloudSQL
- Defined in:
- lib/google/cloud/gemserver/cli/cloud_sql.rb
Overview
CloudSQL
CloudSQL manages the creation of a Cloud SQL instance as well as the necessary database and user creation.
Constant Summary collapse
- SCOPES =
Permits SQL admin operations with the Cloud SQL API.
["https://www.googleapis.com/auth/sqlservice.admin"] .freeze
- SQL =
An alias for the SqladminV1beta4 module.
Google::Apis::SqladminV1beta4
Instance Attribute Summary collapse
-
#db ⇒ String
readonly
The name of the database used to store gemserver data.
-
#inst ⇒ String
readonly
The name of the Cloud SQL instance.
-
#proj_id ⇒ String
readonly
The project ID of the project the gemserver will be deployed to.
-
#pwd ⇒ String
readonly
The password of the default user created to access the database.
-
#service ⇒ Google::Apis::SqladminV1beta4::SQLAdminService
readonly
The Cloud SQL API used to manage Cloud SQL instances.
-
#user ⇒ String
readonly
The name of the default user created to access the database.
Instance Method Summary collapse
-
#initialize(inst = nil) ⇒ CloudSQL
constructor
Creates a CloudSQL object and loads the necessary configuration settings.
-
#run ⇒ Object
Prepares a Cloud SQL instance with a database and user.
Constructor Details
#initialize(inst = nil) ⇒ CloudSQL
Creates a CloudSQL object and loads the necessary configuration settings.
76 77 78 79 80 81 82 83 84 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 76 def initialize inst = nil auth = Google::Auth.get_application_default SCOPES Google::Apis::RequestOptions.default. = auth @config = Configuration.new @service = SQL::SQLAdminService.new @inst = inst || "instance-#{SecureRandom.uuid}".freeze @custom = inst ? true : false load_config end |
Instance Attribute Details
#db ⇒ String (readonly)
The name of the database used to store gemserver data.
44 45 46 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 44 def db @db end |
#inst ⇒ String (readonly)
The name of the Cloud SQL instance.
64 65 66 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 64 def inst @inst end |
#proj_id ⇒ String (readonly)
The project ID of the project the gemserver will be deployed to.
59 60 61 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 59 def proj_id @proj_id end |
#pwd ⇒ String (readonly)
The password of the default user created to access the database.
54 55 56 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 54 def pwd @pwd end |
#service ⇒ Google::Apis::SqladminV1beta4::SQLAdminService (readonly)
The Cloud SQL API used to manage Cloud SQL instances.
69 70 71 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 69 def service @service end |
#user ⇒ String (readonly)
The name of the default user created to access the database.
49 50 51 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 49 def user @user end |
Instance Method Details
#run ⇒ Object
Prepares a Cloud SQL instance with a database and user. Also saves the database settings in the appropriate configuration file.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/google/cloud/gemserver/cli/cloud_sql.rb', line 89 def run create_instance do |instance_op| run_sql_task instance_op if instance_op.class == SQL::Operation update_root_user create_db do |db_op| run_sql_task db_op create_user end end update_config end |