kessel-sdk 1.9.1 → 1.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da1042aa3891283007d9fd0691e9abafc77e90c35e30e50ffc6cbac5269707cd
4
- data.tar.gz: 6dc8b95b250b2761b2a6efb717ad3ea5f8f5e291dbc2a1657829a0ab9928eaf3
3
+ metadata.gz: 136206dbccfc87a36252fa0b635f195d00ebc861f9d26c3a35095403257e971c
4
+ data.tar.gz: 6e1366c5ed2fc78316fd7804f4ff31ac59819817e919fda84e689c7c8023f980
5
5
  SHA512:
6
- metadata.gz: 677a6982ae2894af54d645a6f383fe7d788558895063f7c155cea67331fe691af449e3edc3a83606aac884e552dec727fe9a025d327a8d79dced3f531b75562e
7
- data.tar.gz: 6548b0ecee560d968a9b46b2dee7823fdc641b3c21e8058a33b89b11ba31fbf3096fef234643763c5a8a1e8d4f8beed7fb91d4e1f36422151b151ada73885a4e
6
+ metadata.gz: 2c015adbcbf6838b582f598b31d7860d31541c4adeb622c60877399b67ae797a516f603185640890f6c711311e0ff9f09ef0968153219b9dddcc070bb75acfeb
7
+ data.tar.gz: 4967035e1789c864e4197e5e6ffcbf7bfe6e2d47dc24b2c1a4823b83e198171f043f0ceb0f9bee4cbbc5ae5f495882c2654b6d6e08989a4cc15fae5de3513a96
data/README.md CHANGED
@@ -196,6 +196,10 @@ end
196
196
 
197
197
  ### List Workspaces (Streaming with Auto-Pagination)
198
198
 
199
+ The `list_workspaces` helper automatically paginates through all workspaces
200
+ a subject can access. Continuation tokens are handled internally, meaning you never
201
+ need to manage them yourself.
202
+
199
203
  ```ruby
200
204
  include Kessel::Inventory::V1beta2
201
205
  include Kessel::RBAC::V2
@@ -204,11 +208,20 @@ client = KesselInventoryService::ClientBuilder.new('localhost:9000')
204
208
  .insecure
205
209
  .build
206
210
 
207
- list_workspaces(client, principal_subject('alice', 'redhat'), 'view_document').each do |response|
208
- puts response
211
+ subject = principal_subject("alice", "redhat")
212
+ consistency = Kessel::Inventory::V1beta2::Consistency.new(minimize_latency: true)
213
+
214
+ # Lazy iteration (constant memory)
215
+ list_workspaces(client, subject, "viewer", consistency: consistency).each do |response|
216
+ puts response.object.resource_id
209
217
  end
218
+
219
+ # Materialise into an Array
220
+ all_workspaces = list_workspaces(client, subject, "viewer", consistency: consistency).to_a
210
221
  ```
211
222
 
223
+ See [`examples/list_workspaces.rb`](./examples/list_workspaces.rb) for a complete working example.
224
+
212
225
  ### Available Services (V1beta2)
213
226
 
214
227
  The primary service is **`KesselInventoryService`** with these RPCs:
@@ -22,7 +22,30 @@ module Kessel
22
22
  fetch_workspace(rbac_base_endpoint, org_id, 'root', auth: auth, http_client: http_client)
23
23
  end
24
24
 
25
- def list_workspaces(inventory, subject, relation, continuation_token = nil)
25
+ # Lists all workspaces that a subject has a specific relation to.
26
+ #
27
+ # Pagination is handled automatically -- continuation tokens are managed
28
+ # internally. The returned +Enumerator+ is lazy; each page is fetched
29
+ # only when the next element is requested.
30
+ #
31
+ # @param inventory [Object] the inventory service client stub
32
+ # @param subject [SubjectReference] the subject to check permissions for
33
+ # @param relation [String] the relationship type (e.g. "member", "admin", "viewer")
34
+ # @param continuation_token [String, nil] optional token to resume listing
35
+ # @param consistency [Consistency, nil] optional consistency requirements for each request
36
+ # @return [Enumerator] a lazy enumerator of +StreamedListObjectsResponse+ objects
37
+ #
38
+ # @example Lazy iteration (constant memory)
39
+ # consistency = Kessel::Inventory::V1beta2::Consistency.new(minimize_latency: true)
40
+ # list_workspaces(inventory, subject, "viewer", consistency: consistency).each do |response|
41
+ # puts response.object.resource_id
42
+ # end
43
+ #
44
+ # @example Materialise into an Array (eager, all results in memory)
45
+ # consistency = Kessel::Inventory::V1beta2::Consistency.new(minimize_latency: true)
46
+ # all_workspaces = list_workspaces(inventory, subject, "viewer", consistency: consistency).to_a
47
+ #
48
+ def list_workspaces(inventory, subject, relation, continuation_token = nil, consistency: nil)
26
49
  Enumerator.new do |yielder|
27
50
  loop do
28
51
  request = StreamedListObjectsRequest.new(
@@ -32,7 +55,8 @@ module Kessel
32
55
  pagination: RequestPagination.new(
33
56
  limit: DEFAULT_PAGE_LIMIT,
34
57
  continuation_token: continuation_token
35
- )
58
+ ),
59
+ consistency: consistency
36
60
  )
37
61
 
38
62
  has_responses = false
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kessel
4
4
  module Inventory
5
- VERSION = '1.9.1'
5
+ VERSION = '1.10.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kessel-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Project Kessel