pipeops-rexec 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/rexec/client.rb +11 -4
- data/lib/rexec/container.rb +31 -25
- data/lib/rexec/version.rb +1 -1
- data/lib/rexec.rb +9 -8
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7ba59743a1e821530bd403adb43dcba9aff15c995197741c9f2c309325b1599
|
|
4
|
+
data.tar.gz: 902155d9d6f68d257668356fb6854b8b3470271f2f23f9b1905cef0822d5c7cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f22905b095e20c123f27b0b4958881f9020e25569856b9112c1d16725fb6bca8acf2b7b9c20a4b1389d17ea57d3a27f75122669df06ff2fd1e8cb7b091f1c56
|
|
7
|
+
data.tar.gz: 32d3ec942eac748f79adad09d21cc9d004ea85d0050846656b70b35981286e3884b8783f5ee4b7a56569e2f1bac3a090234dd3a9784c4621ff986cef1942bc70
|
data/README.md
CHANGED
|
@@ -25,7 +25,7 @@ client = Rexec::Client.new("https://your-instance.com", "your-token")
|
|
|
25
25
|
|
|
26
26
|
# Create a container
|
|
27
27
|
container = client.containers.create(
|
|
28
|
-
image: "ubuntu
|
|
28
|
+
image: "ubuntu",
|
|
29
29
|
name: "my-sandbox"
|
|
30
30
|
)
|
|
31
31
|
puts "Created container: #{container.id}"
|
|
@@ -74,7 +74,7 @@ container = client.containers.get("container-id")
|
|
|
74
74
|
|
|
75
75
|
# Create a container
|
|
76
76
|
container = client.containers.create(
|
|
77
|
-
image: "ubuntu
|
|
77
|
+
image: "ubuntu",
|
|
78
78
|
name: "my-container",
|
|
79
79
|
environment: { "MY_VAR" => "value" },
|
|
80
80
|
labels: { "project" => "demo" }
|
|
@@ -176,7 +176,7 @@ def create_batch(client, count)
|
|
|
176
176
|
futures = (0...count).map do |i|
|
|
177
177
|
Concurrent::Future.execute do
|
|
178
178
|
client.containers.create(
|
|
179
|
-
image: "ubuntu
|
|
179
|
+
image: "ubuntu",
|
|
180
180
|
name: "worker-#{i}"
|
|
181
181
|
)
|
|
182
182
|
end
|
data/lib/rexec/client.rb
CHANGED
|
@@ -7,11 +7,18 @@ module Rexec
|
|
|
7
7
|
# Main client for interacting with Rexec API.
|
|
8
8
|
#
|
|
9
9
|
# @example
|
|
10
|
-
# client = Rexec::Client.new("https://
|
|
11
|
-
#
|
|
10
|
+
# client = Rexec::Client.new("https://rexec.sh", "your-token")
|
|
11
|
+
# sandboxes = client.sandboxes.list
|
|
12
|
+
# # Legacy: client.containers is the same service
|
|
12
13
|
#
|
|
13
14
|
class Client
|
|
14
|
-
attr_reader :base_url, :
|
|
15
|
+
attr_reader :base_url, :sandboxes, :files, :terminal
|
|
16
|
+
|
|
17
|
+
# Deprecated alias for {#sandboxes}.
|
|
18
|
+
# @return [SandboxService]
|
|
19
|
+
def containers
|
|
20
|
+
sandboxes
|
|
21
|
+
end
|
|
15
22
|
|
|
16
23
|
# Initialize a new Rexec client.
|
|
17
24
|
#
|
|
@@ -32,7 +39,7 @@ module Rexec
|
|
|
32
39
|
f.headers["Accept"] = "application/json"
|
|
33
40
|
end
|
|
34
41
|
|
|
35
|
-
@
|
|
42
|
+
@sandboxes = SandboxService.new(self)
|
|
36
43
|
@files = FileService.new(self)
|
|
37
44
|
@terminal = TerminalService.new(self)
|
|
38
45
|
end
|
data/lib/rexec/container.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Rexec
|
|
4
|
-
# Represents a Rexec
|
|
5
|
-
class
|
|
4
|
+
# Represents a Rexec sandbox (isolated Linux environment).
|
|
5
|
+
class Sandbox
|
|
6
6
|
attr_reader :id, :name, :image, :status, :created_at, :started_at, :labels, :environment
|
|
7
7
|
|
|
8
8
|
def initialize(data)
|
|
@@ -25,42 +25,45 @@ module Rexec
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
#
|
|
29
|
-
|
|
28
|
+
# @deprecated Use {Sandbox}
|
|
29
|
+
Container = Sandbox
|
|
30
|
+
|
|
31
|
+
# Service for managing sandboxes. HTTP paths remain /api/containers.
|
|
32
|
+
class SandboxService
|
|
30
33
|
def initialize(client)
|
|
31
34
|
@client = client
|
|
32
35
|
end
|
|
33
36
|
|
|
34
|
-
# List all
|
|
37
|
+
# List all sandboxes.
|
|
35
38
|
#
|
|
36
|
-
# @return [Array<
|
|
39
|
+
# @return [Array<Sandbox>]
|
|
37
40
|
def list
|
|
38
41
|
data = @client.request(:get, "/api/containers")
|
|
39
42
|
# API returns { "containers" => [...], "count" => N, "limit" => M }
|
|
40
43
|
items = data.is_a?(Array) ? data : (data && data["containers"]) || []
|
|
41
|
-
items.map { |c|
|
|
44
|
+
items.map { |c| Sandbox.new(c) }
|
|
42
45
|
end
|
|
43
46
|
|
|
44
|
-
# Get a
|
|
47
|
+
# Get a sandbox by ID.
|
|
45
48
|
#
|
|
46
|
-
# @param id [String]
|
|
47
|
-
# @return [
|
|
49
|
+
# @param id [String] Sandbox ID
|
|
50
|
+
# @return [Sandbox]
|
|
48
51
|
def get(id)
|
|
49
52
|
data = @client.request(:get, "/api/containers/#{id}")
|
|
50
|
-
|
|
53
|
+
Sandbox.new(data)
|
|
51
54
|
end
|
|
52
55
|
|
|
53
|
-
# Create a new
|
|
56
|
+
# Create a new sandbox.
|
|
54
57
|
#
|
|
55
|
-
# @param image [String]
|
|
56
|
-
# @param name [String, nil] Optional
|
|
58
|
+
# @param image [String] Image alias (e.g. "ubuntu")
|
|
59
|
+
# @param name [String, nil] Optional sandbox name
|
|
57
60
|
# @param environment [Hash] Environment variables
|
|
58
|
-
# @param labels [Hash]
|
|
59
|
-
# @return [
|
|
61
|
+
# @param labels [Hash] Labels
|
|
62
|
+
# @return [Sandbox]
|
|
60
63
|
#
|
|
61
64
|
# @example
|
|
62
|
-
#
|
|
63
|
-
# image: "ubuntu
|
|
65
|
+
# sandbox = client.sandboxes.create(
|
|
66
|
+
# image: "ubuntu",
|
|
64
67
|
# name: "my-sandbox",
|
|
65
68
|
# environment: { "MY_VAR" => "value" }
|
|
66
69
|
# )
|
|
@@ -71,31 +74,34 @@ module Rexec
|
|
|
71
74
|
body[:labels] = labels unless labels.empty?
|
|
72
75
|
|
|
73
76
|
data = @client.request(:post, "/api/containers", body: body)
|
|
74
|
-
|
|
77
|
+
Sandbox.new(data)
|
|
75
78
|
end
|
|
76
79
|
|
|
77
|
-
# Delete a
|
|
80
|
+
# Delete a sandbox.
|
|
78
81
|
#
|
|
79
|
-
# @param id [String]
|
|
82
|
+
# @param id [String] Sandbox ID
|
|
80
83
|
def delete(id)
|
|
81
84
|
@client.request(:delete, "/api/containers/#{id}")
|
|
82
85
|
nil
|
|
83
86
|
end
|
|
84
87
|
|
|
85
|
-
# Start a
|
|
88
|
+
# Start a sandbox.
|
|
86
89
|
#
|
|
87
|
-
# @param id [String]
|
|
90
|
+
# @param id [String] Sandbox ID
|
|
88
91
|
def start(id)
|
|
89
92
|
@client.request(:post, "/api/containers/#{id}/start")
|
|
90
93
|
nil
|
|
91
94
|
end
|
|
92
95
|
|
|
93
|
-
# Stop a
|
|
96
|
+
# Stop a sandbox.
|
|
94
97
|
#
|
|
95
|
-
# @param id [String]
|
|
98
|
+
# @param id [String] Sandbox ID
|
|
96
99
|
def stop(id)
|
|
97
100
|
@client.request(:post, "/api/containers/#{id}/stop")
|
|
98
101
|
nil
|
|
99
102
|
end
|
|
100
103
|
end
|
|
104
|
+
|
|
105
|
+
# @deprecated Use {SandboxService}
|
|
106
|
+
ContainerService = SandboxService
|
|
101
107
|
end
|
data/lib/rexec/version.rb
CHANGED
data/lib/rexec.rb
CHANGED
|
@@ -7,19 +7,20 @@ require_relative "rexec/container"
|
|
|
7
7
|
require_relative "rexec/file_service"
|
|
8
8
|
require_relative "rexec/terminal"
|
|
9
9
|
|
|
10
|
-
# Rexec Ruby SDK
|
|
10
|
+
# Rexec Ruby SDK — official client for AI-native sandboxes.
|
|
11
11
|
#
|
|
12
12
|
# @example Basic usage
|
|
13
13
|
# client = Rexec::Client.new("https://your-instance.com", "your-token")
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
# puts "Created: #{
|
|
17
|
-
#
|
|
18
|
-
# terminal = client.terminal.connect(
|
|
14
|
+
#
|
|
15
|
+
# sandbox = client.sandboxes.create(image: "ubuntu")
|
|
16
|
+
# puts "Created: #{sandbox.id}"
|
|
17
|
+
#
|
|
18
|
+
# terminal = client.terminal.connect(sandbox.id)
|
|
19
19
|
# terminal.write("echo hello\n")
|
|
20
20
|
# terminal.on_data { |data| puts data }
|
|
21
|
-
#
|
|
22
|
-
# client.
|
|
21
|
+
#
|
|
22
|
+
# client.sandboxes.delete(sandbox.id)
|
|
23
|
+
# # Legacy: client.containers is the same service
|
|
23
24
|
#
|
|
24
25
|
module Rexec
|
|
25
26
|
class << self
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pipeops-rexec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PipeOpsHQ
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|