Welcome to mirror list, hosted at ThFree Co, Russian Federation.

get_importable_data_service.rb « bulk_imports « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07e0b3976a1db7c93c5bd7272330fab0ddd2bfe4 (plain)
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
# frozen_string_literal: true

module BulkImports
  class GetImportableDataService
    def initialize(params, query_params, credentials)
      @params = params
      @query_params = query_params
      @credentials = credentials
    end

    def execute
      {
        version_validation: version_validation,
        response: importables
      }
    end

    private

    def importables
      client.get('groups', @query_params)
    end

    def version_validation
      {
        features: {
          project_migration: {
            available: client.compatible_for_project_migration?,
            min_version: BulkImport.min_gl_version_for_project_migration.to_s
          },
          source_instance_version: client.instance_version.to_s
        }
      }
    end

    def client
      @client ||= BulkImports::Clients::HTTP.new(
        url: @credentials[:url],
        token: @credentials[:access_token],
        per_page: @params[:per_page],
        page: @params[:page]
      )
    end
  end
end