Sha256: 120eb55d417b2a4c3d948715fb70eeda911787ac7268e1b5f6fdfc9dbb195672

Contents?: true

Size: 1.61 KB

Versions: 22

Compression:

Stored size: 1.61 KB

Contents

module Fog
  module Google
    class SQL
      ##
      # Imports data into a Cloud SQL instance from a MySQL dump file in Google Cloud Storage
      #
      # @see https://developers.google.com/cloud-sql/docs/admin-api/v1beta3/instances/import

      class Real
        def import_instance(instance_id, uri, options = {})
          api_method = @sql.instances.import
          parameters = {
            'project' => @project,
            'instance' => instance_id,
          }

          body = {
            'importContext' => {
              'kind' => 'sql#importContext',
              'uri' => Array(uri),
              'database' => options[:database],
            }
          }

          request(api_method, parameters, body)
        end
      end

      class Mock
        def import_instance(instance_id, uri, options = {})
          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' => 'google_client_email@developer.gserviceaccount.com',
            'enqueuedTime' => Time.now.iso8601,
            'startTime' => Time.now.iso8601,
            'endTime' => Time.now.iso8601,
          }

          body = {
            'kind' => 'sql#instancesImport',
            'operation' => operation,
          }

          build_excon_response(body)
        end
      end
    end
  end
end

Version data entries

22 entries across 20 versions & 5 rubygems

Version Path
nsidc-fog-1.24.1 lib/fog/google/requests/sql/import_instance.rb
fog-1.24.0 lib/fog/google/requests/sql/import_instance.rb