File: export_instance.rb

package info (click to toggle)
ruby-fog-google 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,568 kB
  • sloc: ruby: 16,775; makefile: 3
file content (55 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
module Fog
  module Google
    class SQL
      ##
      # Exports data from a Cloud SQL instance to a Google Cloud Storage
      # bucket as a MySQL dump or CSV file.
      #
      # @see https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export
      class Real
        def export_instance(instance_id, uri,
                            databases: [],
                            sql_export_options: {},
                            csv_export_options: {},
                            file_type: nil)
          data = {
            :kind => "sql#exportContext",
            :uri => uri,
            :databases => databases
          }

          unless file_type.nil?
            data[:file_type] = file_type
          end

          unless csv_export_options.empty?
            data[:csv_export_options] =
              ::Google::Apis::SqladminV1beta4::ExportContext::CsvExportOptions.new(**csv_export_options)
          end

          unless sql_export_options.nil?
            data[:sql_export_options] =
              ::Google::Apis::SqladminV1beta4::ExportContext::SqlExportOptions.new(**sql_export_options)
          end

          export_context = ::Google::Apis::SqladminV1beta4::ExportContext.new(export_context)
          @sql.export_instance(
            @project,
            instance_id,
            ::Google::Apis::SqladminV1beta4::ExportInstancesRequest.new(
              export_context: export_context
            )
          )
        end
      end

      class Mock
        def export_instance(_instance_id, _uri, _options: {})
          # :no-coverage:
          Fog::Mock.not_implemented
          # :no-coverage:
        end
      end
    end
  end
end