# Module: Backend::Api::Sources::Package

Extended by:
  ConnectionHelper

Defined in:
  api/sources/package.rb

## Overview

Class that connect to endpoints related to source packages

## Class Method Summary collapse

- .attributes(project_name, package_name, revision) ⇒ String

  Returns the attributes content.

- .branch(target_project, target_package, source_project, source_package, user, options = {}) ⇒ Object

  Branch a package into another project.

- .copy(target_project_name, target_package_name, source_project_name, source_package_name, user_login, options = {}) ⇒ String

  Copy a package into another project.

- .delete(project_name, package_name, options = {}) ⇒ Object

  Deletes the package and all the source files inside.

- .delete_file(project_name, package_name, file_name, options = {}) ⇒ String

  Deletes a file from the sources of a package.

- .file(project_name, package_name, file_name) ⇒ String

  Returns the content of the source file.

- .files(project_name, package_name, options = {}) ⇒ String

  Returns a file list of the sources for a package.

- .link_info(project, package) ⇒ Object

  Returns the link information of a package.

- .merge_service(project_name, package_name, user_login) ⇒ String

  Runs the command mergeservice for that project/package.

- .meta(project_name, package_name) ⇒ String

  Returns the meta file from a package.

- .rebuild(project_name, package_name, options = {}) ⇒ String

  Runs the command rebuild for that package.

- .revisions(project_name, package_name) ⇒ String

  Returns the revisions (mrev) list for a package.

- .run_service(project_name, package_name, user_login) ⇒ String

  Runs the command runservice for that project/package.

- .source_diff(project_name, package_name, options = {}) ⇒ String

  Returns the source diff.

- .trigger_services(project_name, package_name, user_login) ⇒ String

  It triggers all the services of a package.

- .wait_service(project_name, package_name) ⇒ String

  Runs the command waitservice for that project/package.

- .write_attributes(project_name, package_name, user_login, content, comment) ⇒ String

  Writes the content in xml for attributes.

- .write_file(project_name, package_name, file_name, content = '') ⇒ String

  Writes the content of the source file.

- .write_link(project_name, package_name, user_login, content) ⇒ String

  Writes the link information of a package.

- .write_patchinfo(project_name, package_name, user_login, content, comment = nil) ⇒ String

  Writes the patchinfo.

## Class Method Details

### .attributes(project_name, package_name, revision) ⇒ `String`

Returns the attributes content

Parameters:

- revision (`String`) —

  Revision hash/number.

Returns:

- (`String`)

    11
    12
    13
    14
    15
    # File 'api/sources/package.rb', line 11

    def self.attributes(project_name, package_name, revision)
      params = { meta: 1 }
      params[:rev] = revision if revision
      http_get(['/source/:project/:package/_attribute', project_name, package_name || '_project'], params: params)
    end

### .branch(target_project, target_package, source_project, source_package, user, options = {}) ⇒ `Object`

Branch a package into another project

    97
    98
    99
    100
    101
    # File 'api/sources/package.rb', line 97

    def self.branch(target_project, target_package, source_project, source_package, user, options = {})
      http_post(['/source/:project/:package', source_project, source_package],
                defaults: { cmd: :branch, oproject: target_project, opackage: target_package, user: user },
                params: options, accepted: [:keepcontent, :comment, :requestid, :noservice])
    end

### .copy(target_project_name, target_package_name, source_project_name, source_package_name, user_login, options = {}) ⇒ `String`

Copy a package into another project

Parameters:

- options (`Hash`) (defaults to: `{}`) —

  a customizable set of options

Options Hash (`options`):

- :keeplink (`String`) —

  Stay on revision after copying.

- :comment (`String`) —

  Comment to attach to this operation.

- :expand (`String`) —

  Expand sources.

Returns:

- (`String`)

    90
    91
    92
    93
    94
    # File 'api/sources/package.rb', line 90

    def self.copy(target_project_name, target_package_name, source_project_name, source_package_name, user_login, options = {})
      http_post(['/source/:project/:package', target_project_name, target_package_name],
                defaults: { cmd: :copy, oproject: source_project_name, opackage: source_package_name, user: user_login },
                params: options, accepted: [:orev, :keeplink, :expand, :comment, :requestid, :withacceptinfo, :dontupdatesource, :noservice])
    end

### .delete(project_name, package_name, options = {}) ⇒ `Object`

Deletes the package and all the source files inside

    151
    152
    153
    # File 'api/sources/package.rb', line 151

    def self.delete(project_name, package_name, options = {})
      http_delete(['/source/:project/:package', project_name, package_name], params: options, accepted: [:user, :comment, :requestid])
    end

### .delete_file(project_name, package_name, file_name, options = {}) ⇒ `String`

Deletes a file from the sources of a package

Parameters:

- options (`Hash`) (defaults to: `{}`) —

  Parameters to pass to the backend.

Returns:

- (`String`)

    36
    37
    38
    39
    # File 'api/sources/package.rb', line 36

    def self.delete_file(project_name, package_name, file_name, options = {})
      http_delete(['/source/:project/:package/:filename', project_name, package_name, file_name], params: options,
                  accepted: [:user, :comment, :meta, :rev, :linkrev, :keeplink])
    end

### .file(project_name, package_name, file_name) ⇒ `String`

Returns the content of the source file

Returns:

- (`String`)

    140
    141
    142
    # File 'api/sources/package.rb', line 140

    def self.file(project_name, package_name, file_name)
      http_get(['/source/:project/:package/:filename', project_name, package_name, file_name])
    end

### .files(project_name, package_name, options = {}) ⇒ `String`

Returns a file list of the sources for a package

Parameters:

- options (`Hash`) (defaults to: `{}`) —

  Parameters to pass to the backend.

Returns:

- (`String`)

    29
    30
    31
    # File 'api/sources/package.rb', line 29

    def self.files(project_name, package_name, options = {})
      http_get(['/source/:project/:package', project_name, package_name], params: options, accepted: [:expand, :rev, :view])
    end

### .link_info(project, package) ⇒ `Object`

Returns the link information of a package

    104
    105
    106
    # File 'api/sources/package.rb', line 104

    def self.link_info(project, package)
      http_get(['/source/:project/:package/_link', project, package])
    end

### .merge_service(project_name, package_name, user_login) ⇒ `String`

Runs the command mergeservice for that project/package

Returns:

- (`String`)

    75
    76
    77
    # File 'api/sources/package.rb', line 75

    def self.merge_service(project_name, package_name, user_login)
      http_post(['/source/:project/:package', project_name, package_name], params: { cmd: :mergeservice, user: user_login })
    end

### .meta(project_name, package_name) ⇒ `String`

Returns the meta file from a package

Returns:

- (`String`)

    49
    50
    51
    # File 'api/sources/package.rb', line 49

    def self.meta(project_name, package_name)
      http_get(['/source/:project/:package/_meta', project_name, package_name])
    end

### .rebuild(project_name, package_name, options = {}) ⇒ `String`

Runs the command rebuild for that package

Parameters:

- options (`Hash`) (defaults to: `{}`) —

  a customizable set of options

Options Hash (`options`):

- :repository (`String`) —

  Build only for that repository.

- :arch (`String`) —

  Build only for that architecture.

Returns:

- (`String`)

    133
    134
    135
    136
    # File 'api/sources/package.rb', line 133

    def self.rebuild(project_name, package_name, options = {})
      http_post(['/build/:project', project_name], defaults: { cmd: :rebuild, package: package_name },
                params: options, accepted: [:repository, :arch])
    end

### .revisions(project_name, package_name) ⇒ `String`

Returns the revisions (mrev) list for a package

Returns:

- (`String`)

    43
    44
    45
    # File 'api/sources/package.rb', line 43

    def self.revisions(project_name, package_name)
      http_get(['/source/:project/:package/_history', project_name, package_name], params: { meta: 1, deleted: 1 })
    end

### .run_service(project_name, package_name, user_login) ⇒ `String`

Runs the command runservice for that project/package

Returns:

- (`String`)

    81
    82
    83
    # File 'api/sources/package.rb', line 81

    def self.run_service(project_name, package_name, user_login)
      http_post(['/source/:project/:package', project_name, package_name], params: { cmd: :runservice, user: user_login })
    end

### .source_diff(project_name, package_name, options = {}) ⇒ `String`

Returns the source diff

Parameters:

- options (`Hash`) (defaults to: `{}`) —

  a customizable set of options

Options Hash (`options`):

- :rev (`String`) —

  Revision Hash/Number.

- :orev (`String`) —

  Origin revision Hash/Number.

- :opackage (`String`) —

  Origin package name.

- :oproject (`String`) —

  Origin project name.

- :linkrev (`String`) —

  Use the revision of the linked package.

- :olinkrev (`String`) —

  Use the origin revision of the linked package.

- :expand (`String`) —

  Expand sources.

- :filelimit (`String`) —

  Sets the maximum lines of the diff which will be returned (0 = all lines)

Returns:

- (`String`)

    124
    125
    126
    127
    # File 'api/sources/package.rb', line 124

    def self.source_diff(project_name, package_name, options = {})
      http_post(['/source/:project/:package', project_name, package_name], defaults: { cmd: :diff, view: :xml, withissues: 1 },
                params: options, accepted: [:rev, :orev, :opackage, :oproject, :linkrev, :olinkrev, :expand, :filelimit, :tarlimit])
    end

### .trigger_services(project_name, package_name, user_login) ⇒ `String`

It triggers all the services of a package

Returns:

- (`String`)

    55
    56
    57
    # File 'api/sources/package.rb', line 55

    def self.trigger_services(project_name, package_name, user_login)
      http_post(['/source/:project/:package', project_name, package_name], params: { cmd: :runservice, user: user_login })
    end

### .wait_service(project_name, package_name) ⇒ `String`

Runs the command waitservice for that project/package

Returns:

- (`String`)

    69
    70
    71
    # File 'api/sources/package.rb', line 69

    def self.wait_service(project_name, package_name)
      http_post(['/source/:project/:package', project_name, package_name], params: { cmd: :waitservice })
    end

### .write_attributes(project_name, package_name, user_login, content, comment) ⇒ `String`

Writes the content in xml for attributes

Returns:

- (`String`)

    19
    20
    21
    22
    23
    24
    # File 'api/sources/package.rb', line 19

    def self.write_attributes(project_name, package_name, user_login, content, comment)
      params = { meta: 1, user: user_login }
      params[:comment] = comment if comment
      http_put(['/source/:project/:package/_attribute', project_name, package_name || '_project'],
               data: content, params: params)
    end

### .write_file(project_name, package_name, file_name, content = '') ⇒ `String`

Writes the content of the source file

Returns:

- (`String`)

    146
    147
    148
    # File 'api/sources/package.rb', line 146

    def self.write_file(project_name, package_name, file_name, content = '')
      http_put(['/source/:project/:package/:filename', project_name, package_name, file_name], data: content)
    end

### .write_link(project_name, package_name, user_login, content) ⇒ `String`

Writes the link information of a package

Returns:

- (`String`)

    110
    111
    112
    # File 'api/sources/package.rb', line 110

    def self.write_link(project_name, package_name, user_login, content)
      http_put(['/source/:project/:package/_link', project_name, package_name], data: content, params: { user: user_login })
    end

### .write_patchinfo(project_name, package_name, user_login, content, comment = nil) ⇒ `String`

Writes the patchinfo

Returns:

- (`String`)

    61
    62
    63
    64
    65
    # File 'api/sources/package.rb', line 61

    def self.write_patchinfo(project_name, package_name, user_login, content, comment = nil)
      params = { user: user_login }
      params[:comment] = comment if comment
      http_put(['/source/:project/:package/_patchinfo', project_name, package_name], data: content, params: params)
    end