Class: Cadenya::Resources::Tenants

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/tenants.rb

Instance Method Summary collapse

Constructor Details

#initialize(core) ⇒ Tenants

Returns a new instance of Tenants.



8
9
10
# File 'lib/cadenya/resources/tenants.rb', line 8

def initialize(core)
  @core = core
end

Instance Method Details

#delete(id, workspace_id: nil, request_options: nil) ⇒ Object

Erase a tenant



44
45
46
47
48
49
# File 'lib/cadenya/resources/tenants.rb', line 44

def delete(id, workspace_id: nil, request_options: nil)
  workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id)
  _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/tenants/#{Util.path_param('id', id)}"
  _data = @core.request(:delete, _path, request_options: request_options)
  Types::Tenant.from_json(_data)
end

#list(workspace_id: nil, limit: nil, cursor: nil, query: nil, labels: nil, sort_order: nil, include_info: nil, request_options: nil) ⇒ Object

List tenants



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cadenya/resources/tenants.rb', line 13

def list(workspace_id: nil, limit: nil, cursor: nil, query: nil, labels: nil, sort_order: nil, include_info: nil, request_options: nil)
  workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id)
  _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/tenants"
  _query = {
    "limit" => limit,
    "cursor" => cursor,
    "query" => query,
    "labels" => labels,
    "sortOrder" => sort_order,
    "includeInfo" => include_info,
  }
  _data = @core.request(:get, _path, query: _query, request_options: request_options) || {}
  _items = (_data["items"] || []).map { |item| Types::Tenant.from_json(item) }
  _next_cursor = (((_data)["pagination"] || {}))["nextCursor"].to_s
  Page.new(_items, _next_cursor) do |_c|
    list(workspace_id: workspace_id, limit: limit, cursor: _c, query: query, labels: labels, sort_order: sort_order, include_info: include_info, request_options: request_options)
  end
end

#list_subjects(tenant_id, workspace_id: nil, limit: nil, cursor: nil, query: nil, sort_order: nil, include_info: nil, request_options: nil) ⇒ Object

List a tenant's subjects



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cadenya/resources/tenants.rb', line 52

def list_subjects(tenant_id, workspace_id: nil, limit: nil, cursor: nil, query: nil, sort_order: nil, include_info: nil, request_options: nil)
  workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id)
  _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/tenants/#{Util.path_param('tenantId', tenant_id)}/subjects"
  _query = {
    "limit" => limit,
    "cursor" => cursor,
    "query" => query,
    "sortOrder" => sort_order,
    "includeInfo" => include_info,
  }
  _data = @core.request(:get, _path, query: _query, request_options: request_options) || {}
  _items = (_data["items"] || []).map { |item| Types::Subject.from_json(item) }
  _next_cursor = (((_data)["pagination"] || {}))["nextCursor"].to_s
  Page.new(_items, _next_cursor) do |_c|
    list_subjects(tenant_id, workspace_id: workspace_id, limit: limit, cursor: _c, query: query, sort_order: sort_order, include_info: include_info, request_options: request_options)
  end
end

#retrieve(id, workspace_id: nil, include_info: nil, request_options: nil) ⇒ Object

Get a tenant by ID



33
34
35
36
37
38
39
40
41
# File 'lib/cadenya/resources/tenants.rb', line 33

def retrieve(id, workspace_id: nil, include_info: nil, request_options: nil)
  workspace_id = @core.resolve_default("workspaceId", "CADENYA_WORKSPACE_ID", workspace_id)
  _path = "/v1/workspaces/#{Util.path_param('workspaceId', workspace_id)}/tenants/#{Util.path_param('id', id)}"
  _query = {
    "includeInfo" => include_info,
  }
  _data = @core.request(:get, _path, query: _query, request_options: request_options)
  Types::Tenant.from_json(_data)
end