# Copyright 2015 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'google/apis/core/base_service' require 'google/apis/core/json_representation' require 'google/apis/core/hashable' require 'google/apis/errors' module Google module Apis module SqlV1beta4 # Cloud SQL Admin API # # API for Cloud SQL database instance management # # @example # require 'google/apis/sql_v1beta4' # # Sql = Google::Apis::SqlV1beta4 # Alias the module # service = Sql::SQLAdminService.new # # @see https://developers.google.com/cloud-sql/ class SQLAdminService < Google::Apis::Core::BaseService # @return [String] # API key. Your API key identifies your project and provides you with API access, # quota, and reports. Required unless you provide an OAuth 2.0 token. attr_accessor :key # @return [String] # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. attr_accessor :quota_user def initialize super('https://sqladmin.googleapis.com/', '') @batch_path = 'batch' end # Deletes the backup taken by a backup run. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Cloud SQL instance ID. This does not include the project ID. # @param [Fixnum] id # The ID of the Backup Run to delete. To find a Backup Run ID, use the list # method. # @param [String] resource_name # The name of the backupRun to delete. # Format: # projects/`project`/locations/`location`/instances/`instance`/backupRuns/` # backupRun` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::Operation] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::Operation] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def delete_backup_run(project, instance, id, resource_name: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:delete, 'sql/v1beta4/projects/{project}/instances/{instance}/backupRuns/{id}', options) command.response_representation = Google::Apis::SqlV1beta4::Operation::Representation command.response_class = Google::Apis::SqlV1beta4::Operation command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.params['id'] = id unless id.nil? command.query['resourceName'] = resource_name unless resource_name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Retrieves a resource containing information about a backup run. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Cloud SQL instance ID. This does not include the project ID. # @param [Fixnum] id # The ID of this Backup Run. # @param [String] resource_name # Name of the resource backupRun. # Format: # projects/`project`/locations/`location`/instances/`instance`/backupRuns/` # backupRun` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::BackupRun] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::BackupRun] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def get_backup_run(project, instance, id, resource_name: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'sql/v1beta4/projects/{project}/instances/{instance}/backupRuns/{id}', options) command.response_representation = Google::Apis::SqlV1beta4::BackupRun::Representation command.response_class = Google::Apis::SqlV1beta4::BackupRun command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.params['id'] = id unless id.nil? command.query['resourceName'] = resource_name unless resource_name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Creates a new backup run on demand. This method is applicable only to # Second Generation instances. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Cloud SQL instance ID. This does not include the project ID. # @param [Google::Apis::SqlV1beta4::BackupRun] backup_run_object # @param [String] parent # The parent resource where Cloud SQL should create this backupRun. # Format: projects/`project`/locations/`location`/instances/`instance` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::Operation] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::Operation] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def insert_backup_run(project, instance, backup_run_object = nil, parent: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'sql/v1beta4/projects/{project}/instances/{instance}/backupRuns', options) command.request_representation = Google::Apis::SqlV1beta4::BackupRun::Representation command.request_object = backup_run_object command.response_representation = Google::Apis::SqlV1beta4::Operation::Representation command.response_class = Google::Apis::SqlV1beta4::Operation command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.query['parent'] = parent unless parent.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Lists all backup runs associated with a given instance and configuration in # the reverse chronological order of the backup initiation time. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Cloud SQL instance ID. This does not include the project ID. # @param [Fixnum] max_results # Maximum number of backup runs per response. # @param [String] page_token # A previously-returned page token representing part of the larger set of # results to view. # @param [String] parent # The parent, which owns this collection of backupRuns. # Format: projects/`project`/locations/`location`/instances/`instance` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::BackupRunsListResponse] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::BackupRunsListResponse] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def list_backup_runs(project, instance, max_results: nil, page_token: nil, parent: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'sql/v1beta4/projects/{project}/instances/{instance}/backupRuns', options) command.response_representation = Google::Apis::SqlV1beta4::BackupRunsListResponse::Representation command.response_class = Google::Apis::SqlV1beta4::BackupRunsListResponse command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.query['maxResults'] = max_results unless max_results.nil? command.query['pageToken'] = page_token unless page_token.nil? command.query['parent'] = parent unless parent.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Deletes a database from a Cloud SQL instance. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Database instance ID. This does not include the project ID. # @param [String] database # Name of the database to be deleted in the instance. # @param [String] resource_name # The name of the database to delete. # Format: # projects/`project`/locations/`location`/instances/`instance`/databases/` # database` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::Operation] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::Operation] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def delete_database(project, instance, database, resource_name: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:delete, 'sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}', options) command.response_representation = Google::Apis::SqlV1beta4::Operation::Representation command.response_class = Google::Apis::SqlV1beta4::Operation command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.params['database'] = database unless database.nil? command.query['resourceName'] = resource_name unless resource_name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Retrieves a resource containing information about a database inside a Cloud # SQL instance. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Database instance ID. This does not include the project ID. # @param [String] database # Name of the database in the instance. # @param [String] resource_name # Name of the resource database. # Format: # projects/`project`/locations/`location`/instances/`instance`/databases/` # database` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::Database] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::Database] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def get_database(project, instance, database, resource_name: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}', options) command.response_representation = Google::Apis::SqlV1beta4::Database::Representation command.response_class = Google::Apis::SqlV1beta4::Database command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.params['database'] = database unless database.nil? command.query['resourceName'] = resource_name unless resource_name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Inserts a resource containing information about a database inside a Cloud # SQL instance. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Database instance ID. This does not include the project ID. # @param [Google::Apis::SqlV1beta4::Database] database_object # @param [String] parent # The parent resource where Cloud SQL should add this database. # Format: projects/`project`/locations/`location`/instances/`instance` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::Operation] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::Operation] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def insert_database(project, instance, database_object = nil, parent: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'sql/v1beta4/projects/{project}/instances/{instance}/databases', options) command.request_representation = Google::Apis::SqlV1beta4::Database::Representation command.request_object = database_object command.response_representation = Google::Apis::SqlV1beta4::Operation::Representation command.response_class = Google::Apis::SqlV1beta4::Operation command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.query['parent'] = parent unless parent.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Lists databases in the specified Cloud SQL instance. # @param [String] project # Project ID of the project that contains the instance. # @param [String] instance # Cloud SQL instance ID. This does not include the project ID. # @param [String] parent # The parent, which owns this collection of databases. # Format: projects/`project`/locations/`location`/instances/`instance` # @param [String] fields # Selector specifying which fields to include in a partial response. # @param [String] quota_user # Available to use for quota purposes for server-side applications. Can be any # arbitrary string assigned to a user, but should not exceed 40 characters. # @param [Google::Apis::RequestOptions] options # Request-specific options # # @yield [result, err] Result & error if block supplied # @yieldparam result [Google::Apis::SqlV1beta4::DatabasesListResponse] parsed result object # @yieldparam err [StandardError] error object if request failed # # @return [Google::Apis::SqlV1beta4::DatabasesListResponse] # # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification # @raise [Google::Apis::AuthorizationError] Authorization is required def list_databases(project, instance, parent: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'sql/v1beta4/projects/{project}/instances/{instance}/databases', options) command.response_representation = Google::Apis::SqlV1beta4::DatabasesListResponse::Representation command.response_class = Google::Apis::SqlV1beta4::DatabasesListResponse command.params['project'] = project unless project.nil? command.params['instance'] = instance unless instance.nil? command.query['parent'] = parent unless parent.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end # Partially updates a resource containing information about a database inside # a Cloud SQL instance. This method supports patch semantics. #