Class: Knockapi::Resources::Tenants

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

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:



126
127
128
129
# File 'lib/knockapi/resources/tenants.rb', line 126

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

Instance Attribute Details

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



7
8
9
# File 'lib/knockapi/resources/tenants.rb', line 7

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:

Returns:

  • (nil)

See Also:



51
52
53
54
55
56
57
58
# File 'lib/knockapi/resources/tenants.rb', line 51

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:



76
77
78
79
80
81
82
83
84
85
# File 'lib/knockapi/resources/tenants.rb', line 76

def get(id, params = {})
  parsed, options = Knockapi::TenantGetParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/tenants/%1$s", id],
    query: parsed,
    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:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/knockapi/resources/tenants.rb', line 28

def list(params = {})
  parsed, options = Knockapi::TenantListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "v1/tenants",
    query: parsed,
    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:



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/knockapi/resources/tenants.rb', line 110

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