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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/kloudlite.rb +55 -55
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd75a7d6e85fb97fe7f374fda5db6424a9b49d71d620ac9d630532d51faf292a
4
- data.tar.gz: f1c0968d90ac15c46ba486558fc44348c7873b9a8672bb1cbeffd2c59a6d5198
3
+ metadata.gz: e4149e80e442f99d0baff31b078c8eac9eaf115b01946d9041efe01f484de1f8
4
+ data.tar.gz: b0f43efd307e9e954b5f194c6d6b8658a2b4764db836316921e6f73f64def1a9
5
5
  SHA512:
6
- metadata.gz: d5366f04c3488d12699d25b62dc3d2c97ed18144c6b78aaf9815393791a8b79c95997f8bcf82077bc8486fdb3c80f059242c4ca6bbad4894a3f18734ad8ba7b9
7
- data.tar.gz: 91574f8a943ccdf59a555997ad0d50b656e861c78846eb9db4f55f0923b088164a3a846ea881f64115e04d2600dd86cee493be04b7269034972f70e5525c0c9b
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:, session:,
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.2.2"
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 sessions
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, :sessions, :volumes,
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
- @sessions = Sessions.new(self)
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 sessions, over /v1/sessions: some of YOUR workspaces in one team, connected to one
504
- # environment. Many people's sessions connect to the same environment and collaborate through
505
- # it; an intercept a session takes is environment-wide, and the session owns it — only it can
506
- # release it, and removing the workspace or deleting the session releases it.
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 session is named like an environment — "name" (personal) or "team/name" — or by its id
509
- # ("ses-…"); a workspace by its id, name or "team/name", sent verbatim.
510
- class Sessions
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 session's team's: an id, a name or "team/name";
518
- # without one the session connects to nothing until +connect+. +ttl_secs+ (600..=2592000)
519
- # deletes the session after that long unused.
520
- def create(session:, environment: nil, ttl_secs: nil)
521
- team, name = owned(session)
522
- @c.request("POST", "/v1/sessions", body: { name: name, team: team, environment: environment, ttl_secs: ttl_secs })
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 session is deleted (600..=2592000); nil clears it.
526
- def set_ttl(session:, ttl_secs:)
527
- at("PUT", session, "/ttl", body: { ttl_secs: ttl_secs })
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/sessions", query: { team: team })
531
+ @c.request("GET", "/v1/desks", query: { team: team })
532
532
  end
533
533
 
534
- # The session with its +workspaces+ and the +intercepts+ it holds.
535
- def get(session:)
536
- at("GET", session)
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(session:)
541
- at("DELETE", session)
540
+ def delete(desk:)
541
+ at("DELETE", desk)
542
542
  end
543
543
 
544
- # Sets, switches or (nil) clears the session's environment. Its intercepts in the old
545
- # environment are released first; deleting an environment disconnects its sessions the same way.
546
- def connect(session:, environment:)
547
- at("PUT", session, "/environment", body: { environment: environment })
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 session and every workspace in it (202, {"stopped" => [ids]}); capsules and the
550
+ # Stop the desk and every workspace in it (202, {"stopped" => [ids]}); capsules and the
551
551
  # environment are untouched.
552
- def stop(session:)
553
- at("POST", session, "/stop")
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 session, in its team (201). The
557
- # session controls it from then on; it takes the inputs of Workspaces#create.
558
- def create_workspace(session:, workspace:, quota_gb:, image: nil, packages: nil, ttl_secs: nil, env: nil)
559
- at("POST", session, "/workspaces",
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 session manages, releasing its intercepts first (204); snapshots stay.
565
- def delete_workspace(session:, workspace:)
566
- at("DELETE", session, "/workspaces/#{seg(workspace)}")
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 session (202), in its team and reaching its environment.
570
- # Same inputs as Capsules#create (+team+ must be the session's).
571
- def create_capsule(session:, cmd:, **options)
572
- Capsule.new(@c, at("POST", session, "/capsules", body: Capsules.body(cmd: cmd, **options)))
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(session:, service:, workspace:, ports: nil)
579
- at("POST", session, "/intercepts",
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(session:, service:)
585
- at("DELETE", session, "/intercepts/#{seg(service)}")
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, session, tail = "", body: nil)
591
- owner, name = owned(session)
592
- @c.request(method, "/v1/sessions/#{seg(name)}#{tail}", body: body, query: { owner: owner })
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
- # Sessions#create_capsule — not public surface.
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 session's capsule is made with
746
- # Sessions#create_capsule. Unset keywords are omitted, so the server's defaults apply.
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.3.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-07 00:00:00.000000000 Z
11
+ date: 2026-11-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: