Sha256: b8480857b5173f62625a8f3d557ced328b5cea137a8f4269e0fa91f56d84a4ad

Contents?: true

Size: 1.65 KB

Versions: 14

Compression:

Stored size: 1.65 KB

Contents

module Fog
  module Google
    class SQL
      ##
      # Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file
      #
      # @see https://developers.google.com/cloud-sql/docs/admin-api/v1beta3/instances/export

      class Real
        def export_instance(instance_id, uri, options = {})
          api_method = @sql.instances.export
          parameters = {
            "project" => @project,
            "instance" => instance_id
          }

          body = {
            "exportContext" => {
              "kind" => 'sql#exportContext',
              "uri" => uri,
              "database" => Array(options[:databases]),
              "table" => Array(options[:tables])
            }
          }

          request(api_method, parameters, body)
        end
      end

      class Mock
        def export_instance(instance_id, _uri, _options = {})
          operation = random_operation
          data[:operations][instance_id] ||= {}
          data[:operations][instance_id][operation] = {
            "kind" => 'sql#instanceOperation',
            "instance" => instance_id,
            "operation" => operation,
            "operationType" => "EXPORT",
            "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#instancesExport',
            "operation" => operation
          }

          build_excon_response(body)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.5.5 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.5.4 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.5.3 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.5.2 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.5.1 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.5.0 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.4.2 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.4.1 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.4.0 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.3.2 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.3.1 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.3.0 lib/fog/google/requests/sql/export_instance.rb
fog-google-0.2.0 lib/fog/google/requests/sql/export_instance.rb