Module: Gitlab::Client::ProjectExports

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/project_exports.rb

Overview

Defines methods related to project exports.

Instance Method Summary collapse

Instance Method Details

#export_project(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Start a new export

Examples:

Gitlab.export_project(2)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • description(optional) (String)

    Overrides the project description

  • upload(optional) (hash)

    Hash that contains the information to upload the exported project to a web server

  • upload[url] (String)

    TThe URL to upload the project

  • upload[http_method](optional) (String)

    The HTTP method to upload the exported project. Only PUT and POST methods allowed. Default is PUT

Returns:



19
20
21
# File 'lib/gitlab/client/project_exports.rb', line 19

def export_project(id, options = {})
  post("/projects/#{url_encode id}/export", body: options)
end

#export_project_status(id) ⇒ Gitlab::ObjectifiedHash

Get the status of export

Examples:

Gitlab.export_project_status(2)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:



30
31
32
# File 'lib/gitlab/client/project_exports.rb', line 30

def export_project_status(id)
  get("/projects/#{url_encode id}/export")
end

#exported_project_download(id) ⇒ Gitlab::FileResponse

Download the finished export

Examples:

Gitlab.exported_project_download(2)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gitlab/client/project_exports.rb', line 41

def exported_project_download(id)
  get("/projects/#{url_encode id}/export/download",
      format: nil,
      headers: { Accept: 'application/octet-stream' },
      parser: proc { |body, _|
        if body.encoding == Encoding::ASCII_8BIT # binary response
          ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
        else # error with json response
          ::Gitlab::Request.parse(body)
        end
      })
end