Class: OctaSpace::Resources::Services::MachineRental

Inherits:
Base
  • Object
show all
Defined in:
lib/octaspace/resources/services/machine_rental.rb

Overview

Machine Rental (MR) service endpoints

Examples:

client.services.mr.list
client.services.mr.create(
  node_id: 123,
  disk_size: 10,
  image: "ubuntu:24.04",
  app: "249b4cb3-3db1-4c06-98a4-772ba88cd81c"
)

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from OctaSpace::Resources::Base

Instance Method Details

#create(**attrs) ⇒ OctaSpace::Response

Create (start) a machine rental POST /services/mr

Parameters:

  • attrs (Hash)

    rental parameters

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/octaspace/resources/services/machine_rental.rb', line 29

def create(**attrs)
  item = {
    id: 0,
    node_id: attrs.fetch(:node_id),
    disk_size: attrs.fetch(:disk_size),
    image: attrs.fetch(:image),
    app: attrs[:app].to_s,
    envs: attrs[:envs] || {},
    ports: attrs[:ports] || [],
    http_ports: attrs[:http_ports] || [],
    start_command: attrs[:start_command].to_s,
    entrypoint: attrs[:entrypoint].to_s
  }

  item[:organization_id] = attrs[:organization_id] if attrs.key?(:organization_id)
  item[:project_id] = attrs[:project_id] if attrs.key?(:project_id)

  response = post("/services/mr", body: [item])
  raise_if_rejected!(response)
  response
end

#list(**params) ⇒ OctaSpace::Response

List available marketplace machines for rent GET /services/mr

Parameters:

  • params (Hash)

    optional filter params

Returns:



21
22
23
# File 'lib/octaspace/resources/services/machine_rental.rb', line 21

def list(**params)
  get("/services/mr", params:)
end