Class: Cadenya::Resources::Tenants

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/tenants.rb,
lib/cadenya/resources/tenants/subjects.rb,
sig/cadenya/resources/tenants.rbs,
sig/cadenya/resources/tenants/subjects.rbs

Overview

Read and erase tenants and the subjects under them. Tenants and subjects are created by assertion — on objective creation or widget session mint — never directly, so this service has no create or update: it exists to enumerate what assertions have produced, and to destroy it on request.

Defined Under Namespace

Classes: Subjects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tenants

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tenants.

Parameters:



136
137
138
139
# File 'lib/cadenya/resources/tenants.rb', line 136

def initialize(client:)
  @client = client
  @subjects = Cadenya::Resources::Tenants::Subjects.new(client: client)
end

Instance Attribute Details

#subjectsCadenya::Resources::Tenants::Subjects (readonly)

Read and erase tenants and the subjects under them. Tenants and subjects are created by assertion — on objective creation or widget session mint — never directly, so this service has no create or update: it exists to enumerate what assertions have produced, and to destroy it on request.



15
16
17
# File 'lib/cadenya/resources/tenants.rb', line 15

def subjects
  @subjects
end

Instance Method Details

#delete(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::Tenant

Some parameter documentations has been truncated, see Models::TenantDeleteParams for more details.

Destroys the tenant, its subjects, every objective associated with it and everything reachable from those objectives, and its widget sessions. This is the full erasure hammer, wider than DELETE /widget_sessions, which removes only what widget sessions created. The work runs in the background: this returns the tenant in STATE_ERASING rather than a count of what was removed, since a large tenant's history cannot be destroyed inside a request. Poll the tenant to follow it — STATE_ERASING while it runs, NotFound once it finishes. Erasure is terminal; a tenant cannot be recovered once it starts.

Parameters:

  • id (String)

    Tenant to destroy. Accepts the canonical tenant_… form or the

  • workspace_id (String)

    Workspace ID.

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/cadenya/resources/tenants.rb', line 119

def delete(id, params = {})
  parsed, options = Cadenya::TenantDeleteParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :delete,
    path: ["v1/workspaces/%1$s/tenants/%2$s", workspace_id, id],
    model: Cadenya::Tenant,
    options: options
  )
end

#list(workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, query: nil, sort_order: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Tenant>

Some parameter documentations has been truncated, see Models::TenantListParams for more details.

Lists the tenants asserted in a workspace, newest first. query matches against a tenant's name and its external_id, for type-ahead filters.

Parameters:

  • workspace_id (String)

    Path param: Workspace ID.

  • cursor (String)

    Query param: Pagination cursor from previous response.

  • include_info (Boolean)

    Query param: When true, the info field on each returned tenant is populated. T

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Query param: Maximum number of results to return.

  • query (String)

    Query param: Substring match against the tenant's name and external_id. Built fo

  • sort_order (String)

    Query param: Sort order for results (asc or desc by creation time).

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/cadenya/resources/tenants.rb', line 79

def list(params = {})
  parsed, options = Cadenya::TenantListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/tenants", workspace_id],
    query: query.transform_keys(include_info: "includeInfo", sort_order: "sortOrder"),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Tenant,
    options: options
  )
end

#retrieve(id, workspace_id: nil, include_info: nil, request_options: {}) ⇒ Cadenya::Models::Tenant

Some parameter documentations has been truncated, see Models::TenantRetrieveParams for more details.

Retrieves a tenant by its canonical id or by the external_id:<value> form the customer asserted it under.

Parameters:

  • id (String)

    Path param: Tenant ID. Accepts the canonical tenant_… form or the

  • workspace_id (String)

    Path param: Workspace ID.

  • include_info (Boolean)

    Query param: When true, the info field is populated.

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cadenya/resources/tenants.rb', line 36

def retrieve(id, params = {})
  parsed, options = Cadenya::TenantRetrieveParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/tenants/%2$s", workspace_id, id],
    query: query.transform_keys(include_info: "includeInfo"),
    model: Cadenya::Tenant,
    options: options
  )
end