Class: Knockapi::Resources::Tenants

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

Overview

A tenant represents a top-level entity from your system, like a company, organization, account, or workspace.

Defined Under Namespace

Classes: Bulk

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:



133
134
135
136
# File 'lib/knockapi/resources/tenants.rb', line 133

def initialize(client:)
  @client = client
  @bulk = Knockapi::Resources::Tenants::Bulk.new(client: client)
end

Instance Attribute Details

#bulkKnockapi::Resources::Tenants::Bulk (readonly)

A bulk operation is a set of changes applied across zero or more records triggered via a call to the Knock API and performed asynchronously.



11
12
13
# File 'lib/knockapi/resources/tenants.rb', line 11

def bulk
  @bulk
end

Instance Method Details

#delete(id, request_options: {}) ⇒ nil

Delete a tenant and all associated data. This operation cannot be undone.

Parameters:

  • id (String)

    The unique identifier for the tenant.

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

Returns:

  • (nil)

See Also:



56
57
58
59
60
61
62
63
# File 'lib/knockapi/resources/tenants.rb', line 56

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/tenants/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get(id, resolve_full_preference_settings: nil, request_options: {}) ⇒ Knockapi::Models::Tenant

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

Get a tenant by ID.

Parameters:

  • id (String)

    The unique identifier for the tenant.

  • resolve_full_preference_settings (Boolean)

    When true, merges environment-level default preferences into the tenant's `setti

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

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/knockapi/resources/tenants.rb', line 81

def get(id, params = {})
  parsed, options = Knockapi::TenantGetParams.dump_request(params)
  query = Knockapi::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/tenants/%1$s", id],
    query: query,
    model: Knockapi::Tenant,
    options: options
  )
end

#list(after: nil, before: nil, name: nil, page_size: nil, tenant_id: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Tenant>

List tenants for the current environment.

Parameters:

  • after (String)

    The cursor to fetch entries after.

  • before (String)

    The cursor to fetch entries before.

  • name (String)

    Filter tenants by name.

  • page_size (Integer)

    The number of items per page (defaults to 50).

  • tenant_id (String)

    Filter tenants by ID.

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

Returns:

See Also:



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

def list(params = {})
  parsed, options = Knockapi::TenantListParams.dump_request(params)
  query = Knockapi::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/tenants",
    query: query,
    page: Knockapi::Internal::EntriesCursor,
    model: Knockapi::Tenant,
    options: options
  )
end

#set(id, resolve_full_preference_settings: nil, channel_data: nil, name: nil, settings: nil, request_options: {}) ⇒ Knockapi::Models::Tenant

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

Sets a tenant within an environment, performing an upsert operation. Any existing properties will be merged with the incoming properties.

Parameters:

Returns:

See Also:



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/knockapi/resources/tenants.rb', line 116

def set(id, params = {})
  query_params = [:resolve_full_preference_settings]
  parsed, options = Knockapi::TenantSetParams.dump_request(params)
  query = Knockapi::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :put,
    path: ["v1/tenants/%1$s", id],
    query: query,
    body: parsed.except(*query_params),
    model: Knockapi::Tenant,
    options: options
  )
end