module Gitlab::Client::ProjectExports

Defines methods related to project exports. @see docs.gitlab.com/ce/api/project_import_export.html

Public Instance Methods

export_project(id, options = {}) click to toggle source

Start a new export

@example

Gitlab.export_project(2)

@param [Integer, String] id The ID or path of a project. @param [Hash] options A customizable set of options. @option options [String] description(optional) Overrides the project description @option options [hash] upload(optional) Hash that contains the information to upload the exported project to a web server @option options [String] upload TThe URL to upload the project @option options [String] upload(optional) The HTTP method to upload the exported project. Only PUT and POST methods allowed. Default is PUT @return [Gitlab::ObjectifiedHash]

# 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) click to toggle source

Get the status of export

@example

Gitlab.export_project_status(2)

@param [Integer, String] id The ID or path of a project. @return [Gitlab::ObjectifiedHash]

# 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) click to toggle source

Download the finished export

@example

Gitlab.exported_project_download(2)

@param [Integer, String] id The ID or path of a project. @return [Gitlab::FileResponse]

# 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