Module: Backend::Api::Cloud — Documentation by YARD 0.9.12

# Module: Backend::Api::Cloud

Extended by:
  ConnectionHelper

Defined in:
  api/cloud.rb

## Class Method Summary collapse

- .destroy(id) ⇒ String

  Destroys (killing the process) the upload job.

- .log(id) ⇒ String

  Returns the log file of the cloud upload job.

- .status(user) ⇒ String

  Returns the status of the cloud upload jobs of a user.

- .upload(params) ⇒ String

  Triggers a cloud upload job.

## Class Method Details

### .destroy(id) ⇒ `String`

Destroys (killing the process) the upload job. The backend will not delete the log files etc for history reasons. It will return the status of the job or raise an exception.

Returns:

- (`String`)

    31
    32
    33
    # File 'api/cloud.rb', line 31

    def self.destroy(id)
      http_post(['/cloudupload/:id', id], params: { cmd: :kill })
    end

### .log(id) ⇒ `String`

Returns the log file of the cloud upload job

Returns:

- (`String`)

    23
    24
    25
    # File 'api/cloud.rb', line 23

    def self.log(id)
      http_get(['/cloudupload/:id/_log', id], params: { nostream: 1, start: 0 })
    end

### .status(user) ⇒ `String`

Returns the status of the cloud upload jobs of a user

Returns:

- (`String`)

    17
    18
    19
    # File 'api/cloud.rb', line 17

    def self.status(user)
      http_get('/cloudupload', params: { name: user.upload_jobs.pluck(:job_id) }, expand: [:name])
    end

### .upload(params) ⇒ `String`

Triggers a cloud upload job

Returns:

- (`String`)

    7
    8
    9
    10
    11
    12
    13
    # File 'api/cloud.rb', line 7

    def self.upload(params)
      data = params.slice(:region, :virtualization_type, :ami_name)
      user = params[:user]
      params = params.except(:region, :virtualization_type, :ami_name).merge(user: user.login, target: params[:target])
      data = user.ec2_configuration.attributes.except('id', 'created_at', 'updated_at').merge(data).to_json
      http_post('/cloudupload', params: params, data: data)
    end