kloudlite-sdk 0.4.0 → 0.5.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 +53 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4149e80e442f99d0baff31b078c8eac9eaf115b01946d9041efe01f484de1f8
4
- data.tar.gz: b0f43efd307e9e954b5f194c6d6b8658a2b4764db836316921e6f73f64def1a9
3
+ metadata.gz: f3cc583a7ea00949b98460f9f2a3eac30312baee4f1c98c29a9f9f7db9008615
4
+ data.tar.gz: b728e4a16fcb7100d37feea60d4d742a9637e38488ebb92c9650bd545b5738e4
5
5
  SHA512:
6
- metadata.gz: 95ab59bf40a2169bfb963c7223705881b8b47efef23b6e2de186ecfc8a5cdca86868d5857cdf2cdff5ebaca2576ef4c97a5573cc28859b231cd45a7facbbaebe
7
- data.tar.gz: cba7c45cfbd9827cc30154c28a73d8190b8d92c36549c3029873a1a0778b96a621c9aeabd62bf4f3d91829cad931297aec0da8b77ff52bfd874adf4a488eafa7
6
+ metadata.gz: 8f60ad7c782fe168ccee264ae3d8589ad54fb07647a9adb85746ac35bea8ab55ac6f822480fc4900d536128a12ed966e977231f287921dc26e1085d921130a33
7
+ data.tar.gz: 1b83d507f815ed688db12e664202a335a019eb3cc5f4da33140190426a15f283a58283188c6101e55fbda3205b0e93d4c0ebbd1102885efe713430fbf5eebe92
data/kloudlite.rb CHANGED
@@ -25,7 +25,7 @@ require "timeout"
25
25
  require "uri"
26
26
 
27
27
  module Kloudlite
28
- VERSION = "0.4.0"
28
+ VERSION = "0.5.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
 
@@ -56,7 +56,7 @@ module Kloudlite
56
56
  # A client-side wait ran out. A ::Timeout::Error, so a generic rescue still catches it.
57
57
  class TimeoutError < ::Timeout::Error; end
58
58
 
59
- # The naming rules every module shares. Mixed in privately; never part of the public surface.
59
+ # The naming rules (and the push body) every module shares. Mixed in privately; never part of the public surface.
60
60
  module Names
61
61
  private
62
62
 
@@ -75,6 +75,12 @@ module Kloudlite
75
75
  def seg(s)
76
76
  URI.encode_www_form_component(s.to_s).gsub("+", "%20")
77
77
  end
78
+
79
+ # The body of a workspace or environment push, shared so the two never drift apart.
80
+ def snapshot_body(message, volume, description, labels, branch, ttl_secs, never)
81
+ { message: message, volume: volume, description: description, labels: labels,
82
+ branch: branch, ttl_secs: ttl_secs, never: never }.compact
83
+ end
78
84
  end
79
85
 
80
86
  class Client
@@ -217,9 +223,15 @@ module Kloudlite
217
223
  # Push a SNAPSHOT of the working copy — the one durable, restorable state (202). +volume+
218
224
  # names the volume and is required on its first push; +ttl_secs+ (3600..=31536000) or
219
225
  # never: true set its expiry. +push+ is the old name.
220
- def take_snapshot(workspace:, message: nil, volume: nil, ttl_secs: nil, never: nil)
226
+ # The push is a storage commit of the volume. +description+ and +labels+ describe the volume
227
+ # (a given one replaces the stored one). +branch+ creates that branch at the new commit or
228
+ # moves it there, and the workspace then has it checked out; without it the checked-out branch
229
+ # fast-forwards, and the answer carries +branch+ and, when the branch had moved meanwhile,
230
+ # +detached+.
231
+ def take_snapshot(workspace:, message: nil, volume: nil, description: nil, labels: nil,
232
+ branch: nil, ttl_secs: nil, never: nil)
221
233
  at("POST", workspace, "/snapshots",
222
- body: { message: message, volume: volume, ttl_secs: ttl_secs, never: never }.compact)
234
+ body: snapshot_body(message, volume, description, labels, branch, ttl_secs, never))
223
235
  end
224
236
  alias_method :push, :take_snapshot
225
237
 
@@ -229,8 +241,9 @@ module Kloudlite
229
241
  at("POST", workspace, "/clone", body: { name: to, task: task })
230
242
  end
231
243
 
232
- # A new workspace +to+ grafted onto a PUSHED +snapshot+ (a volume name, "name@N" or a snapshot
233
- # id) — also one whose workspace is long gone. +team+ (or to: "team/name") is required for a
244
+ # A new workspace +to+ grafted onto a PUSHED +snapshot+ (a volume name — its "base" branch,
245
+ # else its newest storage commit — "name@N", "name@<branch>" or a snapshot id) — also one
246
+ # whose workspace is long gone. +team+ (or to: "team/name") is required for a
234
247
  # team's volume. Absent overrides mean "whatever the snapshot froze".
235
248
  def restore(snapshot:, to:, team: nil, image: nil, packages: nil, quota_gb: nil)
236
249
  owner, name = owned(to)
@@ -461,11 +474,13 @@ module Kloudlite
461
474
  at("DELETE", environment)
462
475
  end
463
476
 
464
- # Push a SNAPSHOT of every service's data and the service list (202). +volume+ names the
465
- # volume and is required on its first push. +push+ is the old name.
466
- def take_snapshot(environment:, message: nil, volume: nil, ttl_secs: nil, never: nil)
477
+ # Push a SNAPSHOT of every service's data and the service list, a storage commit (202).
478
+ # +volume+ names the volume and is required on its first push; +description+, +labels+ and
479
+ # +branch+ are as in Workspaces#take_snapshot. +push+ is the old name.
480
+ def take_snapshot(environment:, message: nil, volume: nil, description: nil, labels: nil,
481
+ branch: nil, ttl_secs: nil, never: nil)
467
482
  at("POST", environment, "/snapshots",
468
- body: { message: message, volume: volume, ttl_secs: ttl_secs, never: never }.compact)
483
+ body: snapshot_body(message, volume, description, labels, branch, ttl_secs, never))
469
484
  end
470
485
  alias_method :push, :take_snapshot
471
486
 
@@ -657,9 +672,10 @@ module Kloudlite
657
672
  @c = client
658
673
  end
659
674
 
660
- # +kind+ is "workspace" or "environment"; +owner+ a handle or team slug.
661
- def list(kind: nil, owner: nil)
662
- @c.request("GET", "/v1/volumes", query: { kind: kind, owner: owner })
675
+ # +kind+ is "workspace" or "environment"; +owner+ a handle or team slug; +label+ keeps the
676
+ # volumes that carry it.
677
+ def list(kind: nil, owner: nil, label: nil)
678
+ @c.request("GET", "/v1/volumes", query: { kind: kind, owner: owner, label: label })
663
679
  end
664
680
 
665
681
  # The chain of PUSHED snapshots, newest first — each row a restore target.
@@ -682,12 +698,32 @@ module Kloudlite
682
698
  @c.request("DELETE", "/v1/volumes/#{seg(volume)}")
683
699
  end
684
700
 
685
- # One named volume; +owner+ is your handle or a team slug.
701
+ # One named volume; +owner+ is your handle or a team slug. It carries +description+,
702
+ # +labels+ and +branches+ (each branch with the storage commit number it points at).
686
703
  def get(owner:, name:)
687
704
  @c.request("GET", named(owner, name))
688
705
  end
689
706
 
690
- # The versions of a named volume, newest first.
707
+ # Set or clear the description and the labels; nil leaves a field as it is, "" removes the
708
+ # description and [] the labels. Answers the volume.
709
+ def describe(owner:, name:, description: nil, labels: nil)
710
+ @c.request("PATCH", named(owner, name),
711
+ body: { description: description, labels: labels }.compact)
712
+ end
713
+
714
+ # Create +branch+ on a storage commit, or move it there (like git branch -f): give +version+
715
+ # (the commit number) or +snapshot+ (a snapshot id), not both. Answers the volume.
716
+ def set_branch(owner:, name:, branch:, version: nil, snapshot: nil)
717
+ @c.request("PUT", named(owner, name, "/branches/#{seg(branch)}"),
718
+ body: { version: version, snapshot: snapshot }.compact)
719
+ end
720
+
721
+ # Remove a branch (204); its storage commit stays.
722
+ def delete_branch(owner:, name:, branch:)
723
+ @c.request("DELETE", named(owner, name, "/branches/#{seg(branch)}"))
724
+ end
725
+
726
+ # The storage commits of a named volume, newest first; each row carries the +branches+ on it.
691
727
  def versions(owner:, name:)
692
728
  @c.request("GET", named(owner, name, "/versions"))
693
729
  end
@@ -697,7 +733,8 @@ module Kloudlite
697
733
  @c.request("DELETE", named(owner, name))
698
734
  end
699
735
 
700
- # Delete version +n+ (204); deleting the last one deletes the volume.
736
+ # Delete storage commit +n+ (204); deleting the last one deletes the volume. A branch's
737
+ # commit is refused (409).
701
738
  def delete_version(owner:, name:, n:)
702
739
  @c.request("DELETE", named(owner, name, "/versions/#{Integer(n)}"))
703
740
  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.0
4
+ version: 0.5.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-09 00:00:00.000000000 Z
11
+ date: 2026-11-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: