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 +4 -4
- data/README.md +15 -2
- data/lib/kessel/rbac/v2.rb +26 -2
- data/lib/kessel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 136206dbccfc87a36252fa0b635f195d00ebc861f9d26c3a35095403257e971c
|
|
4
|
+
data.tar.gz: 6e1366c5ed2fc78316fd7804f4ff31ac59819817e919fda84e689c7c8023f980
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
208
|
-
|
|
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:
|
data/lib/kessel/rbac/v2.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
data/lib/kessel/version.rb
CHANGED