kloudlite-sdk 0.3.0 → 0.4.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/kloudlite.rb +55 -55
- 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: e4149e80e442f99d0baff31b078c8eac9eaf115b01946d9041efe01f484de1f8
|
|
4
|
+
data.tar.gz: b0f43efd307e9e954b5f194c6d6b8658a2b4764db836316921e6f73f64def1a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95ab59bf40a2169bfb963c7223705881b8b47efef23b6e2de186ecfc8a5cdca86868d5857cdf2cdff5ebaca2576ef4c97a5573cc28859b231cd45a7facbbaebe
|
|
7
|
+
data.tar.gz: cba7c45cfbd9827cc30154c28a73d8190b8d92c36549c3029873a1a0778b96a621c9aeabd62bf4f3d91829cad931297aec0da8b77ff52bfd874adf4a488eafa7
|
data/kloudlite.rb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# "no Kloudlite login: pass token=, set KLOUDLITE_TOKEN, or run kloudlite login".
|
|
15
15
|
#
|
|
16
16
|
# Every public method takes KEYWORD arguments, so no caller has to remember an order; a
|
|
17
|
-
# resource is always the keyword named after it (workspace:, environment:,
|
|
17
|
+
# resource is always the keyword named after it (workspace:, environment:, desk:,
|
|
18
18
|
# volume:, snapshot:, capsule:, run:), and a new object made from an existing one is to:.
|
|
19
19
|
|
|
20
20
|
raise LoadError, "kloudlite.rb needs Ruby 3.0 or later, found #{RUBY_VERSION}" if RUBY_VERSION < "3.0"
|
|
@@ -25,7 +25,7 @@ require "timeout"
|
|
|
25
25
|
require "uri"
|
|
26
26
|
|
|
27
27
|
module Kloudlite
|
|
28
|
-
VERSION = "0.
|
|
28
|
+
VERSION = "0.4.0"
|
|
29
29
|
USER_AGENT = "kloudlite-sdk-ruby/#{VERSION}".freeze
|
|
30
30
|
NO_LOGIN = "no Kloudlite login: pass token=, set KLOUDLITE_TOKEN, or run kloudlite login"
|
|
31
31
|
|
|
@@ -60,7 +60,7 @@ module Kloudlite
|
|
|
60
60
|
module Names
|
|
61
61
|
private
|
|
62
62
|
|
|
63
|
-
# "name" → [nil, name]; "team/name" → [team, name]. Workspaces, environments and
|
|
63
|
+
# "name" → [nil, name]; "team/name" → [team, name]. Workspaces, environments and desks
|
|
64
64
|
# send the pair as path segment +name+ plus ?owner=team, which the server folds back.
|
|
65
65
|
def owned(s)
|
|
66
66
|
s = s.to_s
|
|
@@ -78,7 +78,7 @@ module Kloudlite
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
class Client
|
|
81
|
-
attr_reader :workspaces, :environments, :
|
|
81
|
+
attr_reader :workspaces, :environments, :desks, :volumes,
|
|
82
82
|
:secrets, :connectors, :capsules, :pipelines
|
|
83
83
|
|
|
84
84
|
def initialize(base_url: nil, token: nil, timeout: 30)
|
|
@@ -97,7 +97,7 @@ module Kloudlite
|
|
|
97
97
|
@timeout = timeout
|
|
98
98
|
@workspaces = Workspaces.new(self)
|
|
99
99
|
@environments = Environments.new(self)
|
|
100
|
-
@
|
|
100
|
+
@desks = Desks.new(self)
|
|
101
101
|
@volumes = Volumes.new(self)
|
|
102
102
|
@secrets = Secrets.new(self)
|
|
103
103
|
@connectors = Connectors.new(self)
|
|
@@ -500,96 +500,96 @@ module Kloudlite
|
|
|
500
500
|
end
|
|
501
501
|
end
|
|
502
502
|
|
|
503
|
-
# Working
|
|
504
|
-
# environment. Many people's
|
|
505
|
-
# it; an intercept a
|
|
506
|
-
# release it, and removing the workspace or deleting the
|
|
503
|
+
# Working desks, over /v1/desks: some of YOUR workspaces in one team, connected to one
|
|
504
|
+
# environment. Many people's desks connect to the same environment and collaborate through
|
|
505
|
+
# it; an intercept a desk takes is environment-wide, and the desk owns it — only it can
|
|
506
|
+
# release it, and removing the workspace or deleting the desk releases it.
|
|
507
507
|
#
|
|
508
|
-
# A
|
|
509
|
-
# ("
|
|
510
|
-
class
|
|
508
|
+
# A desk is named like an environment — "name" (personal) or "team/name" — or by its id
|
|
509
|
+
# ("desk-…"); a workspace by its id, name or "team/name", sent verbatim.
|
|
510
|
+
class Desks
|
|
511
511
|
include Names
|
|
512
512
|
|
|
513
513
|
def initialize(client)
|
|
514
514
|
@c = client
|
|
515
515
|
end
|
|
516
516
|
|
|
517
|
-
# +environment+, when given, must be the
|
|
518
|
-
# without one the
|
|
519
|
-
# deletes the
|
|
520
|
-
def create(
|
|
521
|
-
team, name = owned(
|
|
522
|
-
@c.request("POST", "/v1/
|
|
517
|
+
# +environment+, when given, must be the desk's team's: an id, a name or "team/name";
|
|
518
|
+
# without one the desk connects to nothing until +connect+. +ttl_secs+ (600..=2592000)
|
|
519
|
+
# deletes the desk after that long unused.
|
|
520
|
+
def create(desk:, environment: nil, ttl_secs: nil)
|
|
521
|
+
team, name = owned(desk)
|
|
522
|
+
@c.request("POST", "/v1/desks", body: { name: name, team: team, environment: environment, ttl_secs: ttl_secs })
|
|
523
523
|
end
|
|
524
524
|
|
|
525
|
-
# Seconds unused before the
|
|
526
|
-
def set_ttl(
|
|
527
|
-
at("PUT",
|
|
525
|
+
# Seconds unused before the desk is deleted (600..=2592000); nil clears it.
|
|
526
|
+
def set_ttl(desk:, ttl_secs:)
|
|
527
|
+
at("PUT", desk, "/ttl", body: { ttl_secs: ttl_secs })
|
|
528
528
|
end
|
|
529
529
|
|
|
530
530
|
def list(team: nil)
|
|
531
|
-
@c.request("GET", "/v1/
|
|
531
|
+
@c.request("GET", "/v1/desks", query: { team: team })
|
|
532
532
|
end
|
|
533
533
|
|
|
534
|
-
# The
|
|
535
|
-
def get(
|
|
536
|
-
at("GET",
|
|
534
|
+
# The desk with its +workspaces+ and the +intercepts+ it holds.
|
|
535
|
+
def get(desk:)
|
|
536
|
+
at("GET", desk)
|
|
537
537
|
end
|
|
538
538
|
|
|
539
539
|
# Releases its intercepts and lets its workspaces go — never deletes a workspace.
|
|
540
|
-
def delete(
|
|
541
|
-
at("DELETE",
|
|
540
|
+
def delete(desk:)
|
|
541
|
+
at("DELETE", desk)
|
|
542
542
|
end
|
|
543
543
|
|
|
544
|
-
# Sets, switches or (nil) clears the
|
|
545
|
-
# environment are released first; deleting an environment disconnects its
|
|
546
|
-
def connect(
|
|
547
|
-
at("PUT",
|
|
544
|
+
# Sets, switches or (nil) clears the desk's environment. Its intercepts in the old
|
|
545
|
+
# environment are released first; deleting an environment disconnects its desks the same way.
|
|
546
|
+
def connect(desk:, environment:)
|
|
547
|
+
at("PUT", desk, "/environment", body: { environment: environment })
|
|
548
548
|
end
|
|
549
549
|
|
|
550
|
-
# Stop the
|
|
550
|
+
# Stop the desk and every workspace in it (202, {"stopped" => [ids]}); capsules and the
|
|
551
551
|
# environment are untouched.
|
|
552
|
-
def stop(
|
|
553
|
-
at("POST",
|
|
552
|
+
def stop(desk:)
|
|
553
|
+
at("POST", desk, "/stop")
|
|
554
554
|
end
|
|
555
555
|
|
|
556
|
-
# Create a workspace +workspace+ (a bare name) managed by the
|
|
557
|
-
#
|
|
558
|
-
def create_workspace(
|
|
559
|
-
at("POST",
|
|
556
|
+
# Create a workspace +workspace+ (a bare name) managed by the desk, in its team (201). The
|
|
557
|
+
# desk controls it from then on; it takes the inputs of Workspaces#create.
|
|
558
|
+
def create_workspace(desk:, workspace:, quota_gb:, image: nil, packages: nil, ttl_secs: nil, env: nil)
|
|
559
|
+
at("POST", desk, "/workspaces",
|
|
560
560
|
body: { name: workspace, quota_gb: quota_gb, image: image, packages: packages,
|
|
561
561
|
ttl_secs: ttl_secs, env: env }.compact)
|
|
562
562
|
end
|
|
563
563
|
|
|
564
|
-
# Delete a workspace the
|
|
565
|
-
def delete_workspace(
|
|
566
|
-
at("DELETE",
|
|
564
|
+
# Delete a workspace the desk manages, releasing its intercepts first (204); snapshots stay.
|
|
565
|
+
def delete_workspace(desk:, workspace:)
|
|
566
|
+
at("DELETE", desk, "/workspaces/#{seg(workspace)}")
|
|
567
567
|
end
|
|
568
568
|
|
|
569
|
-
# Create a capsule managed by the
|
|
570
|
-
# Same inputs as Capsules#create (+team+ must be the
|
|
571
|
-
def create_capsule(
|
|
572
|
-
Capsule.new(@c, at("POST",
|
|
569
|
+
# Create a capsule managed by the desk (202), in its team and reaching its environment.
|
|
570
|
+
# Same inputs as Capsules#create (+team+ must be the desk's).
|
|
571
|
+
def create_capsule(desk:, cmd:, **options)
|
|
572
|
+
Capsule.new(@c, at("POST", desk, "/capsules", body: Capsules.body(cmd: cmd, **options)))
|
|
573
573
|
end
|
|
574
574
|
|
|
575
575
|
# Send everything that calls +service+ in the environment to +workspace+ (a member), +ports+
|
|
576
576
|
# mapping each service port to the workspace port that answers it ({ 8080 => 3000 }); an
|
|
577
577
|
# unmapped port answers on the same number.
|
|
578
|
-
def intercept(
|
|
579
|
-
at("POST",
|
|
578
|
+
def intercept(desk:, service:, workspace:, ports: nil)
|
|
579
|
+
at("POST", desk, "/intercepts",
|
|
580
580
|
body: { service: service, workspace: workspace,
|
|
581
581
|
ports: (ports || {}).map { |s, w| { service: Integer(s), workspace: Integer(w) } } })
|
|
582
582
|
end
|
|
583
583
|
|
|
584
|
-
def release(
|
|
585
|
-
at("DELETE",
|
|
584
|
+
def release(desk:, service:)
|
|
585
|
+
at("DELETE", desk, "/intercepts/#{seg(service)}")
|
|
586
586
|
end
|
|
587
587
|
|
|
588
588
|
private
|
|
589
589
|
|
|
590
|
-
def at(method,
|
|
591
|
-
owner, name = owned(
|
|
592
|
-
@c.request(method, "/v1/
|
|
590
|
+
def at(method, desk, tail = "", body: nil)
|
|
591
|
+
owner, name = owned(desk)
|
|
592
|
+
@c.request(method, "/v1/desks/#{seg(name)}#{tail}", body: body, query: { owner: owner })
|
|
593
593
|
end
|
|
594
594
|
end
|
|
595
595
|
|
|
@@ -721,7 +721,7 @@ module Kloudlite
|
|
|
721
721
|
include Names
|
|
722
722
|
|
|
723
723
|
# The POST /v1/capsules body; refuses a missing +cmd+ before anything is sent. Shared with
|
|
724
|
-
#
|
|
724
|
+
# Desks#create_capsule — not public surface.
|
|
725
725
|
def self.body(cmd:, image: nil, packages: nil, from_workspace: nil, from_snapshot: nil, team: nil,
|
|
726
726
|
tty: nil, stdin: nil, timeout_s: nil, network: nil, env: nil, cpu: nil,
|
|
727
727
|
memory_gb: nil, disk_gb: nil)
|
|
@@ -742,8 +742,8 @@ module Kloudlite
|
|
|
742
742
|
# is the program then its arguments. +tty+ runs it on a pty; +stdin+ keeps input open for
|
|
743
743
|
# attach. +timeout_s+ is 10..=86400. +from_workspace+ is an id, "name" or "team/name";
|
|
744
744
|
# +from_snapshot+ a volume name, "name@N" or snapshot id (exclusive with it). +network+ is
|
|
745
|
-
# "internet" or "none"; +cpu+ 1..=8, +memory_gb+ 1..=32. A
|
|
746
|
-
#
|
|
745
|
+
# "internet" or "none"; +cpu+ 1..=8, +memory_gb+ 1..=32. A desk's capsule is made with
|
|
746
|
+
# Desks#create_capsule. Unset keywords are omitted, so the server's defaults apply.
|
|
747
747
|
def create(cmd:, **options)
|
|
748
748
|
Capsule.new(@c, @c.request("POST", "/v1/capsules", body: Capsules.body(cmd: cmd, **options)))
|
|
749
749
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kloudlite-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kloudlite
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|